You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently added a Sequel adapter for trilogy: jeremyevans/sequel@0701217. I found trilogy very easy to use and that made the adapter quite easy to create. Thank you for that!
One issue I ran into is that trilogy does not return the number of matched rows in an update statement, it returns the number of rows modified. For example:
c=Trilogy.new(...)c.query('CREATE TABLE t(a integer)')c.query('INSERT INTO t VALUES (1)')c.query('UPDATE t SET a = 1').affected_rows# => 0 # instead of 1
I think this is MySQL default behavior, so it seems reasonable, but most other databases do not operate this way, instead returning the number of matched rows. It there a way to get the above code to return 1? The mysql2 gem supports this using flags: Mysql2::Client::FOUND_ROWS (which looks like it comes from CLIENT_FOUND_ROWS in the mysql driver). If there is not currently a way, could support be added for it?
This affects Sequel because by default, Sequel checks during model instance updates that one row was updated. If zero rows were updated, that by default indicates to Sequel that the underlying database record was already deleted, in which case Sequel should raise an exception. I disabled that part in Sequel when trilogy is used, but it would be nice to be able to enable it.
There are a few other parts of Sequel that don't work perfectly with trilogy, but those are also issues with mysql2, or deliberately unsupported by trilogy (lack of application_timezone).
The text was updated successfully, but these errors were encountered:
I recently added a Sequel adapter for trilogy: jeremyevans/sequel@0701217. I found trilogy very easy to use and that made the adapter quite easy to create. Thank you for that!
One issue I ran into is that trilogy does not return the number of matched rows in an update statement, it returns the number of rows modified. For example:
I think this is MySQL default behavior, so it seems reasonable, but most other databases do not operate this way, instead returning the number of matched rows. It there a way to get the above code to return
1
? The mysql2 gem supports this usingflags: Mysql2::Client::FOUND_ROWS
(which looks like it comes fromCLIENT_FOUND_ROWS
in the mysql driver). If there is not currently a way, could support be added for it?This affects Sequel because by default, Sequel checks during model instance updates that one row was updated. If zero rows were updated, that by default indicates to Sequel that the underlying database record was already deleted, in which case Sequel should raise an exception. I disabled that part in Sequel when trilogy is used, but it would be nice to be able to enable it.
There are a few other parts of Sequel that don't work perfectly with trilogy, but those are also issues with mysql2, or deliberately unsupported by trilogy (lack of application_timezone).
The text was updated successfully, but these errors were encountered: