SqlServerDialect should always quote identifiers
See original GitHub issueDescription
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:
- Created a year ago
- Comments:7 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I ported it back to 2.4. It will be released with 2.4.7
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?