-
-
Notifications
You must be signed in to change notification settings - Fork 547
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(typeorm): correct quotes for column identifiers when driver is ‘mariadb‘ #546
base: master
Are you sure you want to change the base?
Conversation
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.
I tested the fix in a project that had the bug and it fixed it. I think it can be merged!
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.
I think this is better:
const i = ['mysql','mariadb'].includes(this.dbName) ? '`' : '"';
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
@adrianobnu personally I feel with only two comparisons the explicit code is better and more readable. but honestly whatever as long as a bug gets fixed, I'm fine with it… :) |
Yes, it works anyway, but this alternative only makes 1 comparison (instead of 2 or more if you have other databases in the same situation), and I see no difficulties in those who see the code understand what it does. |
@zMotivat0r Can you do the review and approve the merge of this small fix? |
@adrianobnu actually, Array.prototype.includes() must make 2 comparisons to make sure the item isn't in array, and an additional function call. :) if you're thinking about doing micro-optimisations, I think regexp would be a couple nanoseconds faster here… |
Having same error. [Nest] 11360 - 2021-04-09 23:09:08 [ExceptionsHandler] You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the right syntax to use near '."id" = 1)' at line 1 +30543ms |
Would love to see this merged. |
any update on this?? |
This worked for me why is not merged? |
Merged via rewiko#5 |
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.
This change works!! Merge immediately
#531 #545
TypeOrmCrudService.getFieldWithAlias
escapes identifiers using backticks or double quotes.it only uses backticks when
this.dbName === 'mysql'
but TypeORM also uses'mariadb'
to address a few subtle implementation differences.this causes service to use double quotes in SQL and that fails with
You have an error in your SQL syntax…