rails icon indicating copy to clipboard operation
rails copied to clipboard

SQLite3 support use returning statement

Open OuYangJinTing opened this issue 2 years ago • 6 comments

Summary

SQLite(3.35.0) release information The SQLite add support for the RETURNING clause on DELETE, INSERT, and UPDATE statements. This PR used this feature, as follows:

  • ActiveRecord::InsertAll support use to returning of feature if your SQLite version >= 3.35.0.
  • ActiveRecord::ConnectionAdapters::AbstractAdapter#exec_insert support return primary key of value directly. If you want to keep original behavior, you can set insert_returning: false in connection configuration of database.

PS: English is not my native language; please excuse typing errors.

OuYangJinTing avatar Aug 06 '21 11:08 OuYangJinTing

I have a look CI test and I do not found SQLite's version information. It may not be able to test fot the SQLite‘s returning caluse feature and maybe need use newer SQLite.

I run test is pass locally and I use 3.36.0 SQLite.

OuYangJinTing avatar Aug 06 '21 12:08 OuYangJinTing

If I understand it well, CI is running in Docker image based on Debian 11 and installing Sqlite3 using system package.

https://packages.debian.org/bullseye/sqlite3

Currently it is using 3.34.1-3 version.

simi avatar Aug 29 '21 14:08 simi

If I understand it well, CI is running in Docker image based on Debian 11 and installing Sqlite3 using system package.

https://packages.debian.org/bullseye/sqlite3

Currently it is using 3.34.1-3 version.

Thanks for your reply. Maybe we should wait for the sqlite3 version to upgrade, and then look at this PR.

OuYangJinTing avatar Oct 19 '21 09:10 OuYangJinTing

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

rails-bot[bot] avatar Jan 17 '22 10:01 rails-bot[bot]

Reopened another closed by stale label.

yahonda avatar May 23 '22 04:05 yahonda

@OuYangJinTing Would you rebase this pull request based on the latest main branch if you are still interested in. Thanks.

yahonda avatar May 23 '22 04:05 yahonda

@yahonda I re-checked and updated the commit. Can you help to re-review? thank you! I will add returning statement ability for mariadb if this PR can be merged

OuYangJinTing avatar Nov 04 '22 17:11 OuYangJinTing

Hey folks, I'd like to see if https://github.com/rails/rails/pull/49290 achieved everything we aimed for in this PR so this one could be closed.

nvasilevski avatar Sep 26 '23 07:09 nvasilevski

@nvasilevski: I opened #50468 to add the documentation improvements, but everything else in this PR was captured by #49290. Once #50468 is merged, this can be closed. @OuYangJinTing, I made sure to make you a co-author of the #50468 PR. Thanks for your good work here.

fractaledmind avatar Dec 28 '23 08:12 fractaledmind

Closing as completed by #49290 and #50468

skipkayhil avatar Dec 28 '23 17:12 skipkayhil