crud icon indicating copy to clipboard operation
crud copied to clipboard

fix(typeorm): correct quotes for column identifiers when driver is ‘mariadb‘

Open constb opened this issue 4 years ago • 10 comments

#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…

constb avatar Jun 16 '20 07:06 constb

@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… :)

constb avatar Mar 04 '21 03:03 constb

@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.

adrianobnu avatar Mar 04 '21 12:03 adrianobnu

@zMotivat0r Can you do the review and approve the merge of this small fix?

adrianobnu avatar Mar 04 '21 20:03 adrianobnu

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.

@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…

constb avatar Mar 06 '21 13:03 constb

Having same error. This issue has been opened for 10 months now, it's a small fix, and it works fine for all MariaDB's users. Can we merge it? How can we help?

[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

jeremyhalin avatar Apr 09 '21 21:04 jeremyhalin

Would love to see this merged.

jspizziri avatar May 11 '21 22:05 jspizziri

any update on this??

sgClaudia98 avatar Jul 05 '21 00:07 sgClaudia98

This worked for me why is not merged?

sgClaudia98 avatar Jul 10 '21 18:07 sgClaudia98

I am trying to help and have forked this repo (can't reach the owner of this repo and do not have the credential for the npm repo).

See #710 (comment)

We can hopefully merge it via rewiko#5

rewiko avatar Nov 28 '21 09:11 rewiko

Merged via https://github.com/rewiko/crud/issues/5

rewiko avatar Nov 28 '21 10:11 rewiko