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

SQL quotes replaced to support Postgresql #734

Merged
merged 1 commit into from
Apr 26, 2022
Merged

SQL quotes replaced to support Postgresql #734

merged 1 commit into from
Apr 26, 2022

Conversation

marcheffels
Copy link

Hey,

tested with MySQL and PostgreSQL.

Greeting Marc

@rappasoft
Copy link
Owner

Are these quotes not working?

@marcheffels
Copy link
Author

Are these quotes not working?

It worked for MySQL but there is a SQL syntax error for PostgreSQL. With this quotes it will works for both.

@rappasoft rappasoft added the Awaiting Next Release Currently merged into development awaiting a release to master label Apr 26, 2022
@rappasoft rappasoft merged commit 4dfe74e into rappasoft:master Apr 26, 2022
@damiandejong
Copy link

Hi,

Unfortunately, this commit made that sorting in my application is not working anymore. I am using standard Laravel Sail for my local environment (comes with MySQL 8.0).

The only way I can make it work is by reverting the change in this commit. If there are some other things I could try, please let me know.

With kind regards,
Damian

@rappasoft
Copy link
Owner

Hi,

Unfortunately, this commit made that sorting in my application is not working anymore. I am using standard Laravel Sail for my local environment (comes with MySQL 8.0).

The only way I can make it work is by reverting the change in this commit. If there are some other things I could try, please let me know.

With kind regards, Damian

I have no sorting issues with this commit. I would think we would have heard more fuss in the last 9 days if this broke anything. The demo is also working. Are you getting any errors?

@damiandejong
Copy link

damiandejong commented May 4, 2022

Are you getting any errors?

I don't get any errors, it just won't sort on a nested column. Perhaps an example can clearify the issue I am running into. Below is the query that I got from the function $this->getQuerySql():

select `models`.`id` as `id`, `article_types`.`name` as `article_type.name`, `brands`.`name` as `brand.name`, `models`.`name` as `name`, `models`.`code` as `code`, `models`.`year` as `year`, `models`.`colors` as `colors`, `countries`.`name` as `country.name`, `models`.`created_at` as `created_at`, `models`.`updated_at` as `updated_at` from `models` left join `article_types` on `models`.`article_type_id` = `article_types`.`id` left join `brands` on `models`.`brand_id` = `brands`.`id` left join `countries` on `models`.`country_id` = `countries`.`id` where `active` = true and `models`.`deleted_at` is null order by "brand.name" asc, `year` desc, `code` asc

The result, also when I run the query directly in MySQL, is that the data is only sorted on the second and third columns in the ORDER BY clause. When I change the double quotes around brand.name to backticks, the result gets sorted properly.

It thought it might have to do with the fact that MySQL does not necesarily treat double quotes the same as backticks. As far as I understand correctly, it only sees a string enclosed in double quotes as an identifier in case the SQL mode ANSI_QUOTES is enabled (see: https://dev.mysql.com/doc/refman/8.0/en/string-literals.html). However, after having enabled that mode, I still get the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Next Release Currently merged into development awaiting a release to master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants