question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SqlServerDialect should always quote identifiers

See original GitHub issue

Description

Microsoft SQL Server has reserved keywords such as order that cannot be used as identifiers unless they are quoted

This works in spring-data 2.1.x. Unfortunately in #914 identifiers quoting was disabled by default for this dialect. That made it impossible to migrate from 2.1.x to 2.2+

When I declare an entity like this:

@Table
data class MyEntity(
    @Id
    val id: Long? = null,
    val order: Int,
)

then SQL Servers throws exceptions like this one: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'order'.

Solution proposal

I suggest create new IdentifierProcessing type QUOTED = create(Quoting.ANSI, LetterCasing.AS_IS) and use it in SqlServerDialect.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
schaudercommented, Dec 7, 2022

I ported it back to 2.4. It will be released with 2.4.7

0reactions
neutrino1911commented, Dec 6, 2022

I see that quoting was introduced in 3.0.0, in 2.4.x it doesn’t quote identifiers. Any chances it might be backported to 2.4.x?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SET QUOTED_IDENTIFIER (Transact-SQL) - Microsoft Learn
When SET QUOTED_IDENTIFIER is OFF, identifiers cannot be quoted and must follow all Transact-SQL rules for identifiers. For more information, ...
Read more >
SET QUOTED_IDENTIFIER settings in SQL Server
This article gives an overview of the QUOTED_IDENTIFIER set option and its behaviour in SQL Server queries with single and double-quotes.
Read more >
Quote SQL identifiers only when necessary? #11147 - GitHub
The identifier must not be a Transact-SQL reserved word. SQL Server reserves both the uppercase and lowercase versions of reserved words.
Read more >
sql server - Can you quote variable identifiers and parameter ...
Any quotes are taken from Database Identifiers. Variables follow the rules for "regular identifiers". These are classed as:.
Read more >
How Does QUOTED_IDENTIFIER Works in SQL Server?
When I have QUOTED IDENTIFIER OFF, the query will identify the double quotes and will display the valid string between the double quotes....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found