-
Notifications
You must be signed in to change notification settings - Fork 34
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
Escape column name #159
Escape column name #159
Conversation
@cmd410 escaping is a different operation than quoting. It replaces chars with other chars, we don't want that. Instead, you could just use """ & fld & """. |
@moigagoo yep, makes sense, fixed this |
Pls update the tests. |
@cmd410 thanks for the update! Now, the only thing left that I'll have to ask you to do is, please add a changelog entry for your change. And thank you again for you contribution! 🙏 |
@cmd410 some tests are failing. |
truthfully, I got no clue why they fail... error messages are confusing, saying some field does not exist. The other is like |
@cmd410 most errors have to do with incorrect column names:
These should be easy to fix. It's either an error in the tests or in query generation for e.g. foreign key queries. The |
I've taken a look at the errors here as well and the issue this opens up seems non trivial. Notice the extra quotation marks around the fields. Edit: I noticed that, in fact, only the model fields must be in quotation marks. See |
The field there now requires quotation marks around itself. This is likely because in the SELECT bit of the query the fields are also provided with quotation marks.
On linux, databases tend to be case-sensitive with their tests. This test failed in part because the column is `userId` not `userid`
In the 3 ways a Foreign Key Constraint may be generated the field does not get escaped. This causes issues in the tests.
This appears to now be mandatorily necessary
…l fields For some reason the tests of tcount fail, because the model in there has another model in it, which generates an FK field that then looks like this: ""favToy"" Which causes SQL errors.
Renamed "isContainer" to "isRefObject" Added documentation to utility procs
Due to the tables in postgres being created in a case-sensitive manner they require quotation marks around them and must be case-sensitive correct. This is only the case with postgres, not sqlite. https://stackoverflow.com/questions/43111996/why-postgresql-does-not-like-uppercase-table-names
This is a fix for fields that match SQL keywords to cause syntax error in the query.
For example:
Will cause
Error: unhandled exception: near "group": syntax error [DbError]
asgroup
matches an SQL keyword.However it is possible to create such fields delimiting them with quotes:
So this fix uses
strutils.escape
proc to achieve that, though not sure if its a proper way to do this...