fix column names quotation in keyset
This PR should fix the problem with column names quotes in MySQL introduced by this commit.
Demo of the problem:
irb(main):002> scope = Service.order(id: :desc)
irb(main):003> page = Pagy::Keyset.new(scope, limit: 3000)
irb(main):004> page.records.count
Service Load (25.3ms) SELECT `services`.* FROM `services` ORDER BY `services`.`id` DESC LIMIT 3001
irb(main):006> page = Pagy::Keyset.new(scope, limit: 3000, page: page.next)
Service Load (2.9ms) SELECT `services`.* FROM `services` /* loading for pp */ ORDER BY `services`.`id` DESC LIMIT 11
=>
#<Pagy::Keyset::ActiveRecord:0x0000000109b270f0
...
irb(main):007> page.records.count
Service Load (2.3ms) SELECT `services`.* FROM `services` WHERE (( "services"."id" < '7002' )) ORDER BY `services`.`id` DESC LIMIT 3001
(irb):7:in `<main>': Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '."id" < '7002' )) ORDER BY `services`.`id` DESC LIMIT 3001' at line 1 (ActiveRecord::StatementInvalid)
/Users/alexeyt/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `_query': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '."id" < '7002' )) ORDER BY `services`.`id` DESC LIMIT 3001' at line 1 (Mysql2::Error)
Thank you! I totally overlooked that different DBs like to do things their ways. 😬
That is actually a bug that was persisting in the upcoming version, now fixed also for sequel datasets in dev.
Please, extrapolate the changes in 81b4222 (new code) to the current version and I will be glad to merge and release it ASAP. Also, please ensure that all tests pass.
Thank you!
@ddnexus thanks for your comment! I checked out your commit and took the implementation from there
@ddnexus could you have a look pls?
@t0ch1k I am terribly late on all the PRs... sorry, but I have been abroad solving a few family problems, and focusing on the development of the new major version. You can see the rc1 here.
Will do next.