Please sign in to comment.
Allow Models to use the RETURNING clause when inserting records on Po…
…stgreSQL This commit makes model.save! check for an insert_select method on the dataset. If it exists, it calls that method and uses the result as the values, instead of inserting and then reloading the values from the database. This should be faster as well as less error prone. It changes a recent commit to the PostgreSQL adapter so that insert_sql does not use the RETURNING clause by default. You need to call the insert_returning_sql method if you want the RETURNING clause. That is what Dataset#insert now does on PostgreSQL servers 8.2 and higher. This caused some issues with prepared statements, but this commit takes care of that as well. This commit also contains a small speedup to Dataset#single_value, as well as a missing spec for Database#raise_error.
- Loading branch information...
Showing with 108 additions and 25 deletions.
- +2 −0 CHANGELOG
- +7 −0 lib/sequel_core/adapters/jdbc/postgresql.rb
- +1 −0 lib/sequel_core/adapters/postgres.rb
- +29 −9 lib/sequel_core/adapters/shared/postgres.rb
- +1 −1 lib/sequel_core/database.rb
- +1 −1 lib/sequel_core/dataset/convenience.rb
- +15 −9 lib/sequel_model/record.rb
- +23 −4 spec/adapters/postgres_spec.rb
- +16 −1 spec/sequel_core/database_spec.rb
- +13 −0 spec/sequel_model/record_spec.rb