aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* `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.
* Remove most uses of `Column#cast_type`Sean Griffin2015-01-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to remove the type object from the column, and remove columns from the type casting process entirely. The primary motivation for this is clarity. The connection adapter does not have sufficient type information, since the type we want to work with might have been overriden at the class level. By taking this object from the column, it is easy to mistakenly think that the column object which exists on the connection adapter is sufficient. It isn't. A concrete example of this is `serialize`. In 4.2 and earlier, `where` worked in a very inconsistent and confusing manner. If you passed a single value to `where`, it would serialize it before querying, and do the right thing. However, passing it as part of an array, hash, or range would cause it to not work. This is because it would stop using prepared statements, so the type casting would come from arel. Arel would have no choice but to get the column from the connection adapter, which would treat it as any other string column, and query for the wrong value. There are a handful of cases where using the column object to find the cast type is appropriate. These are cases where there is not actually a class involved, such as the migration DSL, or fixtures. For all other cases, the API should be designed as such that the type is provided before we get to the connection adapter. (For an example of this, see the work done to decorate the arel table object with a type caster, or the introduction of `QueryAttribute` to `Relation`). There are times that it is appropriate to use information from the column to change behavior in the connection adapter. These cases are when the primitive used to represent that type before it goes to the database does not sufficiently express what needs to happen. An example of this that affects every adapter is binary vs varchar, where the primitive used for both is a string. In this case it is appropriate to look at the column object to determine which quoting method to use, as this is something schema dependent. An example of something which would not be appropriate is to look at the type and see that it is a datetime, and performing string parsing when given a string instead of a date. This is the type of logic that should live entirely on the type. The value which comes out of the type should be a sufficiently generic primitive that the adapter can be expected to know how to work with it. The one place that is still using the column for type information which should not be necessary is the connection adapter type caster which is sometimes given to the arel table when we can't find the associated table. This will hopefully go away in the near future.
* Remove Relation#bind_paramsSean Griffin2015-01-271-3/+3
| | | | | | | | `bound_attributes` is now used universally across the board, removing the need for the conversion layer. These changes are mostly mechanical, with the exception of the log subscriber. Additional, we had to implement `hash` on the attribute objects, so they could be used as a key for query caching.
* Don't default to YAML dumping when quoting valuesSean Griffin2015-01-141-1/+7
| | | | | | | This behavior exists only to support fixtures, so we should handle it there. Leaving it in `#quote` can cause very subtle bugs to slip through, by things appearing to work when they should be blowing up loudly, such as #18385.
* Stop passing a column to `quote` in `insert_fixture`Sean Griffin2015-01-101-4/+4
| | | | | | | I'm planning on deprecating the column argument to mirror the deprecation in [arel]. [arel]: https://github.com/rails/arel/commit/6160bfbda1d1781c3b08a33ec4955f170e95be11
* Restore query cache on rollbackFlorian Weingarten2014-12-011-1/+12
|
* remove never called method `limited_update_conditions`Andrey Deryabin2014-11-111-4/+0
|
* Remove duplicate 'select' database statementclaudiob2014-10-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `select` method has the same definition in almost all database adapters, so it can be moved from the database-specific adapters (PostgreSQl, MySQL, SQLite) to the abstract `database_statement`: ```ruby def select(sql, name = nil, binds = []) exec_query(sql, name, binds) end ``` --- More details about this commit: the only two DB-specific adapters that have a different definition of `select` are MySQLAdapter and MySQL2Adapter. In MySQLAdapter, `select` invokes `exec_query(sql, name, binds)`, so calling `super` achieves the same goal with less repetition. In MySQL2Adapter, `select` invokes `exec_query(sql, name)`, that is, it does not pass the `binds` parameter like other methods do. However, [MySQL2Adapter's `exec_query`](https://github.com/rails/rails/blob/74a527cc63ef56f3d0a42cf638299958dc7cb08c/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb#L228L231) works exactly the same whether this parameters is passed or not, so the output does not change: ```ruby def exec_query(sql, name = 'SQL', binds = []) result = execute(sql, name) ActiveRecord::Result.new(result.fields, result.to_a) end ```
* add a truncate method to the connectionAaron Patterson2014-09-221-0/+5
| | | | | | it doesn't work on SQLite3 since it doesn't support truncate, but that's OK. If you call truncate on the connection, you're now bound to that database (same as if you use hstore or any other db specific feature).
* Transactions refactoringArthur Neves2014-07-281-38/+6
| | | | | | | Add a transaction manager per connection, so it can controls the connection responsibilities. Delegate transaction methods to transaction_manager
* /mysql/i -> MySQL, Spell correct in continuation to #15555Akshay Vishnoi2014-06-141-3/+3
|
* Keep closer to other methods that touch @transactionArthur Neves2014-05-281-0/+4
|
* cache scope building on associationsAaron Patterson2014-04-141-1/+5
| | | | SQL statements for querying associations are now cached
* Merge branch 'master' into adequaterecordAaron Patterson2014-04-141-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (70 commits) [ci skip] Added link to ruby-lang.org installation. Use the index on hidden field `collection_check_boxes` respects `:index` option for the hidden filed name. docs, double meaning of `serialize` argument. Closes #14284. Just call read_attribute, no need to use `send`. - Fix lingering reference to `:text` instead of the newer `:plain` - Section references `form_tag` instead of the `form_for` used in the example again, read_attribute is public, so just call it read_attribute is public, so we should just call it Disable assest cache store in docs [ci skip] Make counter cache decrementation on destroy idempotent Write the failing test case for concurrent counter cache [ci skip] Use plain underscore instead of "\_". Update documentation to use Rails.application instead Add a changelog entry for #14546 [ci skip] Move tests for deep_dup and duplicable to object directory Missing 'are' in note - [ci skip] CollectionHelpers now accepts a readonly option Fix a few typos [ci skip] Bundle tzinfo-data on :x64_mingw (64-bit Ruby on Windows). don't bother with an offset if the offset is zero ...
| * please use Ruby, not ActiveSupportAaron Patterson2014-04-111-1/+1
| |
* | working against arel/collector branchAaron Patterson2014-04-091-1/+2
| |
* | fix bind collecting for mysqlAaron Patterson2014-04-091-1/+0
| |
* | add a bind collector, remove the bind visitorAaron Patterson2014-04-091-3/+1
| |
* | use the compile method so we do not have to specify the collectors in this caseAaron Patterson2014-04-091-2/+1
| |
* | working against arel/collector branchAaron Patterson2014-04-091-1/+2
| |
* | Merge branch 'master' into adequaterecordAaron Patterson2014-04-071-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (122 commits) Rails.application should be set inside before_configuration hook remove check for present? from delete_all Remove useless begin..end Build the reverse_order on its proper method. Use connection-specific bytea escaping Ignore order when doing count. make enums distinct per class Remove unused `subclass_controller_with_flash_type_bar` var from flash test. fix CollectionProxy delete_all documentation Added OS X specific commands to installation guide [ci skip] Recommended using homebrew for installing MySQL and PostgreSQL Fix setup of adding _flash_types test. Use SVG version of travis build status badge [skip ci] W3C CSP document moved to gihub.io URL [ci skip] sprockets-rails was released Fix the test defining the models in the right place Add CHANGELOG entry for #11650 [ci skip] Declare the assets dependency Use sass-rails 4.0.3 Make possible to use sprockets-rails 2.1 add missing parentheses to validates_with documentation [skip ci] ...
| * Replace trivial regexp with string or index, twice as fastKelley Reynolds2014-03-281-1/+1
| |
* | Merge branch 'master' into adequaterecordAaron Patterson2014-03-251-12/+9
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (96 commits) clarify CHANGELOG [ci skip]. Fix Generation of proper migration when ActiveRecord::Base.pluralize_table_names = false. update comments to reflect that options support is not available synchronize changelogs and 4.1 release notes. [ci skip] do not rely on method_missing hitting arel use ARel factory methods for building AST nodes Fix date_select option overwriting html classes - Rename `increment_or_decrement` to an apt `set_cache_value` since it actually doesn't increment/decrement in localstore. Check if any sqlite files are not included in the gitignore Remove sqlite3 lines from .gitignore if the application is not using sqlite3. Adding active_model in Rails::Info Clean up tables after each test. Swapped parameters of assert_equal in assert_select Update test helper to use latest Digestor API Digestor should just rely on the finder to know about the format and the variant -- trying to pass it back in makes a mess of things (oh, and doesnt work) Log the full path, including variant, that the digestor is trying to find Fix for digestor to consider variants for partials -- this still needs more testing!! fix log_tags request object grammar Extract with_example_table into helper method. test for structure:dump without schema information table. refs eafec46 ... Conflicts: activerecord/test/cases/relation/where_chain_test.rb