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

[BUG]: Issue using model columns starting with not* #16277

Closed
wurst-hans opened this issue Feb 4, 2023 · 4 comments
Closed

[BUG]: Issue using model columns starting with not* #16277

wurst-hans opened this issue Feb 4, 2023 · 4 comments
Assignees
Labels
bug A bug report status: unverified Unverified

Comments

@wurst-hans
Copy link

Currently using v4.1.0, so I don't know, if this issue persists in newer versions.

I have some database models using a colum, for example notification_date. When querying database using

$result = Orders::find([
    'conditions' => 'notification_date IS NULL',
]);

I get an error from Phalcon, saying (you can see, that Phalcon cuts off not):

"Column 'ification_date' doesn't belong to any of the selected models (1), when preparing: SELECT [App\\Models\\Orders].* FROM [App\\Models\\Orders] WHERE notification_date IS NULL"

Even when using backticks in conditions `notification_date` I'm getting another error:

"Scanning error before 'notification_date...' when parsing: SELECT [App\\Models\\Orders].* FROM [App\\Models\\Orders] WHERE `notification_date` IS NULL"

The only solution is to rename column to anything not starting with not.

@wurst-hans wurst-hans added bug A bug report status: unverified Unverified labels Feb 4, 2023
@dcolt
Copy link

dcolt commented Feb 5, 2023

You can fix it by doing the PHQL "escaping" in your queries

$result = Orders::find([
    'conditions' => '[notification_date] IS NULL',
]);

@wurst-hans
Copy link
Author

I'm only aware of the backticks used by MySQL, so I'm wondering about the square brackets. So this is a Phalcon specific thing?

BTW: I understand that keywords like NOT, LIKE and UPDATE have to be escaped. Nevertheless, Phalcon (i.e. PHQL) seems to ignore word boundaries, because an error on using notification_date is nothing I would expect.

@ALameLlama
Copy link
Contributor

reported in #14641

@niden
Copy link
Sponsor Member

niden commented Dec 27, 2023

Closing this as duplicate #14641

@niden niden closed this as completed Dec 27, 2023
@niden niden self-assigned this Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: unverified Unverified
Projects
Status: Unverified - Wont Fix - Duplicates
Development

No branches or pull requests

4 participants