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: use different default schema per dialect, escape quotes in identifiers instead of removing them, normalize Model.getTableName #15274
Merged
Conversation
This file contains 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
ephys
commented
Nov 12, 2022
ephys
changed the title
fix: cleanup query generator
fix: use different default schema per dialect, escape quotes in identifiers instead of removing them
Nov 12, 2022
ephys
changed the title
fix: use different default schema per dialect, escape quotes in identifiers instead of removing them
fix: use different default schema per dialect, escape quotes in identifiers instead of removing them, normalize Model.getTableName
Nov 12, 2022
ephys
commented
Nov 12, 2022
ephys
commented
Nov 12, 2022
ephys
commented
Nov 12, 2022
ephys
commented
Nov 12, 2022
WikiRik
reviewed
Nov 13, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
WikiRik
reviewed
Nov 15, 2022
SQLite unit tests fail since I included a test for the schema, but we've said that sqlite does not support schemas so we'll need to see how to deal with that |
WikiRik
approved these changes
Nov 17, 2022
6 tasks
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.
Description Of Change
This PR is yet-another preliminary PR for #14687 in order to prevent that other PR from growing endlessly.
The goal of this PR is to:
AbstractQueryGeneratorTypeScript
and migrate some base QueryGenerator methods to TypeScriptgetDefaultSchema
, and rewritingextractTableDetails
. We should eventually arrive at a state where all query generator methods default the table schema to either the schema set through Sequelize's options, or the per-dialect default schema.quoteIdentifier
with one very important change:queryGenerator.quoteIdentifier('"abc"')
previously unquoted then quoted its input. Quotes are actually valid as identifiers, as long as they're escaped. Instead of returning"abc"
, this method will now return"""abc"""
(triple " because one is the actual identifier delimiter, and two consecutive""
is how we escape"
).addTicks
,removeTicks
, andTICK_CHAR
,wrapSingleQuote
for the above reasonBecause
quoteIdentifier
doesn't remove existing quotes anymore, I had to tweak parts of queryGenerator. Functions likeselectQuery
passed its identifiers toquoteIdentifier
multiple times. Causing duplicate quotes.My current plan for
AbstractQueryGeneratorTypeScript
is to only move APIs once they are considered stable & suitable for public use.