fix(mssql): columnInfo() now works with case-sensitive database [fixes #4573] #4633
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before, the SQL used to implement
columnInfo()
for the mssql driver referencedinformation_schema.columns
.But in a database with a case-sensitive collation, both of those parts must be capitalized, as
INFORMATION_SCHEMA.COLUMNS
, or you just get an error [#4573]. (It doesn't seem sensitive to how you capitalize the column names, though. 🤷 )Now, that capitalized form is used when interacting with mssql.
Question for Reviewer: Should I just switch the default mssql test database to use a case-sensitive collation?
In order to test this change, I needed to create a new database with a case-sensitive collation, then tear it down. This required digging around to grab the database config used in the integration test suite.
It would be cleaner to change the default test database for MSSQL to be created with a case-sensitive collation, in which case, every test would be a test of case-sensitive behavior. This does create a risk of writing SQL that relies on case-sensitivity in its function, which then fails under case-insensitive collations, but I consider that rather less likely than case-insensitive code that fails when case-sensitivity is enabled.
If we did change it to use a case-sensitive collation, I think we could remove the dedicated test suite I added, though each of those tests did turn out to be required to beat this functionality into shape, because I repeatedly missed various ways this could go wrong:
Finally I came around to, "We just have to check and add/update based on what we find each time," which is the implementation you see here.