fix(mssql): cast sql_variant in query generator#11994
Merged
Merged
Conversation
sys.extended_properties.value is a column of type sql_variant.
If used with msnodesqlv8, the driver will crash when executing this
query without casting the sql_variant to nvarchar.
this will be relevant when syncing the model with {alter: true}
sushantdhiman
approved these changes
Mar 16, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
sys.extended_properties.value is a column of type sql_variant. If used with msnodesqlv8, the driver will crash when executing this query without casting the sql_variant to nvarchar.
The issue is only relevant if a model is synced with
{alter: true}option. In this case, the Application will just exit without any error. The "real" error is probably in the c++ driver of msnodesqlv8, since I was not able to debug it any further. However, I was able to isolate the query which is causing the bug. Running the same query without sequelize causes the same problem. I started modifying the query and found it that it is related to the extended_properties value column. Casting it to NVARCHAR solves the issue.This is a really small fix. I tested it locally in my project. I don't want to install all the test environments. I think a new test would be overkill or impossible, since there is nothing to try/catch, since the application exits without any error! Please let me know what you think. I would be very happy if the change could be implemented.