Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mssql): cast sql_variant in query generator #11994

Merged
merged 1 commit into from Mar 16, 2020

Conversation

killerfurbel
Copy link
Contributor

@killerfurbel killerfurbel commented Mar 12, 2020

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving? description see below
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)? not applicable
  • Did you update the typescript typings accordingly (if applicable)? not applicable
  • Did you follow the commit message conventions explained in [CONTRIBUTING.md] hope so (https://github.com/sequelize/sequelize/blob/master/CONTRIBUTING.md)?

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.

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 sushantdhiman merged commit cc836ba into sequelize:master Mar 16, 2020
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants