aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate `supports_statement_cache?`Ryuta Kamizono2017-05-011-2/+3
| | | | | | | | | | | | | | `supports_statement_cache?` was introduced in 3.1.0.beta1 (104d0b2) for bind parameter substitution, but it is no longer used in 3.1.0.rc1 (73ff679). Originally it should respect `prepared_statements` rather than `supports_statement_cache?` (fd39847). One more thing, named `supports_statement_cache?` is pretty misreading. We have `StatementCache` and `StatementPool`. However, `supports_statement_cache?` doesn't mean `StatementCache`, but `StatementPool` unlike its name. https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/statement_cache.rb https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/connection_adapters/statement_pool.rb
* Fix `select_rows` method signature for consistencyRyuta Kamizono2017-01-041-6/+4
| | | | | | | | Related #22973, #24708. `select_all`, `select_one`, `select_value`, and `select_values` method signature is `(arel, name = nil, binds = [])`. But `select_rows` is `(sql, name = nil, binds = [])`.
* Remove deprecated `#insert_sql`, `#update_sql`, and `#delete_sql`Ryuta Kamizono2016-12-301-6/+0
|
* Remove deprecated support to query using commas on LIMITRafael Mendonça França2016-12-291-6/+1
|
* Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-281-6/+6
| | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-241-7/+7
|
* fix QueryCache nil dupRichard Monette2016-12-151-2/+2
| | | | | | | | | | | | | | make sql statements frozen dup if arel is not our string expect runtime error dont wrap runtime error in invalid log errors will now be treated as runtime errors update changelog
* Add missing `+` around a some literals.bogdanvlviv2016-10-271-1/+1
| | | | | | Mainly around `nil` [ci skip]
* Force correct namespace when using TransactionManagerArthur Neves2016-09-161-1/+1
| | | | [fixes #26441]
* Revert "`sql_for_insert` returns values for passing to `exec_insert`"Ryuta Kamizono2016-08-191-1/+1
| | | | | | | This reverts #23067. #23067 is for propagating `pk` value from `sql_for_insert` to `exec_insert` (avoiding extra query for pg adapter). Now `exec_insert` includes `sql_for_insert` since #26002 therefore this propagating is no longer needed.
* Merge pull request #26002 from ↵Rafael França2016-08-171-2/+2
|\ | | | | | | | | kamipo/sql_for_insert_should_be_called_inside_exec_insert `sql_for_insert` should be called inside `exec_insert`
| * `sql_for_insert` should be called inside `exec_insert`Ryuta Kamizono2016-08-061-2/+2
| | | | | | | | | | `exec_insert` cannot return last inserted id if `use_insert_returning?` is true. `sql_for_insert` should be called inside `exec_insert`.
* | Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | applies new string literal convention in activerecord/libXavier Noria2016-08-061-4/+4
|/ | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Make `name` and `binds` to optional args for `exec_{insert,update,delete}`Ryuta Kamizono2016-08-041-3/+3
| | | | | | `insert`, `update`, `delete`, and `exec_query` have a default value against `name` and `binds`. But `exec_insert`, `exec_update`, and `exec_delete` not have. It is an inconvenience and inconsistent.
* Remove `prepare_binds_for_database` internal methodRyuta Kamizono2016-07-281-1/+1
| | | | To avoid relying on the connection adapter for type casting binds.
* Decouple statement cache from connection adapterRyuta Kamizono2016-07-241-3/+4
| | | | | | `StatementCache` is hard-coded in `cacheable_query` and be passed `visitor` and `collector` from connection adapter. Simply it is enough to pass a collected value.
* Do not `binds.dup` in `connection#to_sql`Ryuta Kamizono2016-07-191-1/+1
| | | | Because `connection#to_sql` does not mutate `binds`.
* Include the Savepoints module in all adapters.Vipul A M2016-04-241-3/+0
| | | | | Adapters override `#supports_savepoints?` to return `true` if they support transaction savepoints. Defaults to `false`.
* Merge pull request #24708 from ↵Jeremy Daer2016-04-231-1/+1
|\ | | | | | | | | | | kamipo/move_select_rows_implementation_to_super_class Move `select_rows` implementation to super class
| * Move `select_rows` implementation to super classRyuta Kamizono2016-04-241-1/+1
| |
* | Remove in the doc about MySQL versions below 5 [ci skip]Ryuta Kamizono2016-04-241-3/+1
|/ | | | | Follow up to #23458. Active Record supports MySQL >= 5.0 now.
* `undef_method` is not neededRyuta Kamizono2016-04-191-2/+3
|
* Deprecate `{insert|update|delete}_sql` in `DatabaseStatements`Ryuta Kamizono2016-03-021-0/+3
| | | | | Originally, `{insert|update|delete}_sql` is protected methods. We can use the `{insert|update|delete}` public methods instead.
* Fix NoMethodError preparable for Arel::Visitors in case prepared statements ↵Azzurrio2016-02-221-1/+1
| | | | is falsy
* Ensure prepared statement caching still occurs with Adequate RecordSean Griffin2016-02-111-2/+2
| | | | | | | | | | | | | In Rails 5, we're much more restrictive about when we do or don't cache a prepared statement. In particular, we never cache when we are sending an IN statement or a SQL string literal However, in the case of Adequate Record, we are *always* sending a raw SQL string, and we *always* want to cache the result. Fixes #23507 /cc @tgxworld
* Clarify DatabaseStatements#execute docs re: memory usage.James Coleman2016-01-221-1/+5
|
* `sql_for_insert` returns values for passing to `exec_insert`Ryuta Kamizono2016-01-151-10/+6
|
* fix regression when loading fixture files with symbol keys.Yves Senn2016-01-131-2/+3
| | | | Closes #22584.
* Merge pull request #22973 from kamipo/fix_select_values_method_signatureRafael França2016-01-081-2/+2
|\ | | | | Fix `select_values` method signature for consistency
| * Fix `select_values` method signature for consistencyRyuta Kamizono2016-01-081-2/+2
| |
* | `{update|delete}_sql` are almost the same as `{update|delete}`Ryuta Kamizono2016-01-081-10/+2
|/ | | | Simply `{update|delete}_sql` aliases to `{update|delete}`.
* Refactor `connection.insert_sql`Ryuta Kamizono2016-01-071-9/+8
| | | | `connection.insert_sql` is almost the same as `connection.insert`.
* Fix `connection#create` in PG adapterRyuta Kamizono2016-01-051-0/+1
| | | | | | Originally `connection#create` had aliased to `connection#insert` in PG adapter. But it was broken by #7447. Re-alias `create` to `insert` for fixing it.
* Merge pull request #22620 from kamipo/join_to_delete_is_same_as_join_to_updateRafael França2015-12-221-8/+2
|\ | | | | `join_to_delete` is same as `join_to_update`
| * `join_to_delete` is same as `join_to_update`Ryuta Kamizono2015-12-171-8/+2
| | | | | | | | Reapply #22615.
* | Remove legacy mysql adapterRyuta Kamizono2015-12-211-1/+1
|/ | | | Follow up to #22642.
* Revert "Merge pull request #22615 from ↵Rafael Mendonça França2015-12-171-2/+8
| | | | | | | | | | kamipo/join_to_delete_is_same_as_join_to_update" This reverts commit 4d06ea9a829de8f6f5a345589828e182eacab6a3, reversing changes made to e9d15072a94e2ae4dec5b7a121c84a5db38547b8. Reason: This will break oracle-enhanced, see https://github.com/rsim/oracle-enhanced/blob/3c42131db82b64ac41645db3affc6e4650289df6/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb#L1254
* `join_to_delete` is same as `join_to_update`Ryuta Kamizono2015-12-171-8/+2
|
* Do not cache prepared statements that are unlikely to have cache hitsSean Griffin2015-10-201-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit, Rails makes no differentiation between whether a query uses bind parameters, and whether or not we cache that query as a prepared statement. This leads to the cache populating extremely fast in some cases, with the statements never being reused. In particular, the two problematic cases are `where(foo: [1, 2, 3])` and `where("foo = ?", 1)`. In both cases we'll end up quoting the values rather than using a bind param, causing a cache entry for every value ever used in that query. It was noted that we can probably eventually change `where("foo = ?", 1)` to use a bind param, which would resolve that case. Additionally, on PG we can change our generated query to be `WHERE foo = ANY($1)`, and pass an array for the bind param. I hope to accomplish both in the future. For SQLite and MySQL, we still end up preparing the statements anyway, we just don't cache it. The statement will be cleaned up after it is executed. On postgres, we skip the prepare step entirely, as an API is provided to execute with bind params without preparing the statement. I'm not 100% happy on the way this ended up being structured. I was hoping to use a decorator on the visitor, rather than mixing a module into the object, but the way Arel has it's visitor pattern set up makes it very difficult to extend without inheritance. I'd like to remove the duplication from the various places that are extending it, but that'll require a larger restructuring of that initialization logic. I'm going to take another look at the structure of it soon. This changes the signature of one of the adapter's internals, and will require downstream changes from third party adapters. I'm not too worried about this, as worst case they can simply add the parameter and always ignore it, and just keep their previous behavior. Fixes #21992.
* applies new doc guidelines to Active Record.Yves Senn2015-10-141-1/+1
| | | | | | | | | | | | | | | | | | | The focus of this change is to make the API more accessible. References to method and classes should be linked to make it easy to navigate around. This patch makes exzessiv use of `rdoc-ref:` to provide more readable docs. This makes it possible to document `ActiveRecord::Base#save` even though the method is within a separate module `ActiveRecord::Persistence`. The goal here is to bring the API closer to the actual code that you would write. This commit only deals with Active Record. The other gems will be updated accordingly but in different commits. The pass through Active Record is not completely finished yet. A follow up commit will change the spots I haven't yet had the time to update. /cc @fxn
* Updated MySQL documentation link to MySQL latest version 5.7 everywhere [ci ↵amitkumarsuroliya2015-09-101-2/+2
| | | | | skip] Bumps from `5.6` to `5.7`
* descriptive error message when fixtures contian a missing column.Yves Senn2015-08-131-2/+6
| | | | Closes #21201.
* Updated postgresql documentation link to use latest version [ci skip]Ronak Jangir2015-05-201-1/+1
|
* Use `select_rows` instead of `select_one` in `select_value`Ryuta Kamizono2015-05-051-2/+3
| | | | | `select_one` create `ActiveRecord::Result` instance. It is better to use `select_rows` instead of `select_one` for performance.
* Updated MySQL documentation link to MySQL latest version 5.6 everywhere [ci ↵amitkumarsuroliya2015-03-191-2/+2
| | | | skip]
* Revert "delete unused method"Carlos Antonio da Silva2015-03-021-0/+4
| | | | | | | | This reverts commit a38732c8e6ab76ea0db4e1a617a1fa84b53a9750. Since the mutation logic was reverted in 07278519bb6db5579171fea70bccdfee1306f1d4, we must bring the reader method back as well, since the implementation relies on it.
* delete unused methodAaron Patterson2015-03-021-4/+0
|
* Use keyword argument in `transaction`Ryuta Kamizono2015-02-111-6/+4
| | | | | The keys are already validated, so it is better to use the built-in feature to do this.
* push add to transaction logic down to the instanceAaron Patterson2015-02-011-0/+4
| | | | | the transaction object shouldn't know so much about active record objects, so let's push the conditionals in to the instance.