aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract
Commit message (Collapse)AuthorAgeFilesLines
* Add missing parantheses in index_exists?Yannick Schutz2014-02-251-1/+1
|
* Distinguish ConnectionNotEstablished messages: no conn pool for the class, ↵Jeremy Kemper2014-02-221-1/+4
| | | | or no conn available from the pool
* Reaper has access to threadsafe active? callKevin Casey2014-02-081-1/+1
|
* docs, AR already auto-detects primary keys. Closes #13946. [ci skip]Yves Senn2014-02-051-3/+3
| | | | | This behavior was introduced since Rails 3.1 (207f266ccaaa9cd04cd2a7513ae5598c4358b510) but the docs were still out of date.
* Fix regression on `.select_*` methods.Arthur Neves2014-01-301-3/+14
| | | | | | | | | | | | | | | | | | This was a common pattern: ``` query = author.posts.select(:title) connection.select_one(query) ``` However `.select` returns a ActiveRecord::AssociationRelation, which has the bind information, so we can use that to get the right sql query. Also fix select_rows on postgress and sqlite3 that were not using the binds [fixes #7538] [fixes #12017] [related #13731] [related #12056]
* Restore ActiveRecord states after a rollback for models w/o callbacksGodfrey Chan2014-01-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression (#13744) that was caused by 67d8bb9. In 67d8bb9, we introduced lazy rollback for records, such that the record's internal states and attributes are not restored immediately after a transaction rollback, but deferred until they are first accessed. This optimization is only performed when the model does not have any transactional callbacks (e.g. `after_commit` and `after_create`). Unfortunately, the models used to test the affected codepaths all comes with some sort of transactional callbacks. Therefore this codepath remains largely untested until now and as a result there are a few issues in the implementation that remains hidden until now. First, the `sync_with_transaction_state` (or more accurately, `update_attributes_from_transaction_state`) would perform the synchronization prematurely before a transaction is finalized (i.e. comitted or rolled back). As a result, when the actuall rollback happens, the record will incorrectly assumes that its internal states match the transaction state, and neglect to perform the restore. Second, `update_attributes_from_transaction_state` calls `committed!` in some cases. This in turns checks for the `destroyed?` state which also requires synchronization with the transaction stae, which causes an infnite recurrsion. This fix works by deferring the synchronization until the transaction has been finalized (addressing the first point), and also unrolled the `committed!` and `rolledback!` logic in-place (addressing the second point). It should be noted that the primary purpose of the `committed!` and `rolledback!` methods are to trigger the relevant transactional callbacks. Since this code path is only entered when there are no transactional callbacks on the model, this shouldn't be necessary. By unrolling the method calls, the intention here (to restore the states when necessary) becomes more clear.
* Revert "ask the fixture set for the sql statements"Aaron Patterson2014-01-091-5/+1
| | | | | | | | | This reverts commit 026d0555685087845b74dd87a0417b5a164b1c13. Conflicts: activerecord/lib/active_record/fixtures.rb Fixes #13383
* Make change_table use object of current database adapterNishant Modak2014-01-071-5/+5
| | | | | | | | | - Earlier, change_table was creating database-agnostic object. - After this change, it will create correct object based on current database adapter. - This will ensure that create_table and change_table will get same objects. - This makes update_table_definition method public and nodoc. - Fixes #13577 and #13503
* quoting: Check if id is a valid method before using itArthur Neves2013-12-191-1/+3
| | | | | Need to check if valud also respond_to :id before calling it, otherwise things could explode.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-12-202-2/+2
|\
| * Typos. return -> returns. [ci skip]Lauro Caetano2013-12-032-2/+2
| |
* | Fix missing closing rdoc tag [ci skip]Carlos Antonio da Silva2013-12-161-1/+1
| |
* | support creating temporary tables from queriesCody Cutrer2013-12-143-15/+32
| | | | | | | | | | also override drop_table in AbstractMySQLAdapter to properly drop temporary tables without committing the transaction
* | `connection.type_to_sql` returns a `String` for unmapped types.Yves Senn2013-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | Closes #13146. This fixes an error when using: ``` change_colum :table, :column, :bigint, array: true ```
* | Currently, we clear query_cache in cache block finish, even if we may ↵Vipul A M2013-12-031-1/+1
| | | | | | | | | | | | already have cache true. This commit takes into account the last cache_enabled value, before clearing query_cache.
* | Remove `DatabaseStatements#case_sensitive_equality_operator`. It has been ↵Ryuta Kamizono2013-11-291-4/+0
| | | | | | | | deprecated already.
* | `rename_index`: add the new index before removing the old one.Yves Senn2013-11-261-2/+2
|/ | | | | | | | | | | This prevents the following error when a MySQL index on a foreign key column is renamed: ``` ActiveRecord::StatementInvalid: Mysql2::Error: Cannot drop index 'index_engines_on_car_id': needed in a foreign key constraint: DROP INDEX `index_engines_on_car_id` ON `engines` ``` refs: #13038.
* Move `SchemaCreation` to its own file instead of `AbstractAdapter`.Vipul A M2013-11-121-0/+83
|
* ask the fixture set for the sql statementsAaron Patterson2013-11-041-1/+5
|
* Remove confusing generated-code commentaryJeremy Kemper2013-10-281-4/+4
|
* extract adapter savepoint implementations into `abstract/savepoints.rb`.Yves Senn2013-09-301-0/+21
|
* Check if the SQL is not a prepared statementRafael Mendonça França2013-09-111-1/+1
| | | | | | | | | When the adapter is with prepared statement disabled and the binds array is not empty the connection adapter will try to set the binds values and will fail. Now we are checking if the adapter has the prepared statement disabled. Fixes #12023
* Revert "Do not dup the binds when visiting the AST"Rafael Mendonça França + Kassio Borges2013-08-311-1/+2
| | | | | | This reverts commit 71ff7d9c6592b93e2c810a1f464943dd7bd02c7f. Reason: I need to check with @jeremy if we can do this.
* Do not dup the binds when visiting the ASTRafael Mendonça França2013-08-311-2/+1
| | | | | | | The visitor have to consume the bind parameters to make the statements work when the prepared statement option is disabled. Fixes #12023
* Merge pull request #11827 from vipulnsward/remove_extra_caseSantiago Pastorino2013-08-261-1/+0
|\ | | | | Remove extra case.
| * Remove extra case.Vipul A M2013-08-101-1/+0
| |
* | drop extra variableVipul A M2013-08-121-2/+2
|/
* Remove redundant `string_to_binary` from type-castingVipul A M2013-08-092-4/+0
|
* Merge pull request #11331 from vipulnsward/remove_conditionalAaron Patterson2013-08-071-8/+1
|\ | | | | Remove conditional, results are always an instance of `ActiveRecord::Result`
| * Remove conditional, since results are always an instance of ↵Vipul A M2013-07-061-8/+1
| | | | | | | | `ActiveRecord::Result`
* | Fix indentation.kennyj2013-07-241-8/+8
| |
* | Simplify select_one method.kennyj2013-07-241-2/+1
| | | | | | | | | | | | The select_all method always returns ActiveRecord::Result instance, and the ActiveRecord::Result includes Enumerable mixin. If #empty?, #first method returns nil. Thus we can simplify this method.
* | Defines the return type of select / select_all method.kennyj2013-07-231-4/+2
| |
* | rescue from all exceptions in `ConnectionManagement#call`Vipul A M2013-07-221-1/+1
| | | | | | | | | | | | | | | | | | Fixes #11497 As `ActiveRecord::ConnectionAdapters::ConnectionManagement` middleware does not rescue from Exception (but only from StandardError), the Connection Pool quickly runs out of connections when multiple erroneous Requests come in right after each other. Recueing from all exceptions and not just StandardError, fixes this behaviour.
* | Move initializing process for query cache to ↵kennyj2013-07-161-0/+6
|/ | | | ActiveRecord::ConnectionAdapters::QueryCache module.
* Removed deprecated method `columns_for_remove`Neeraj Singh2013-07-031-6/+0
|
* Remove deprecated SchemaStatements#distinctFrancesco Rodriguez2013-07-021-9/+0
|
* Remove deprecated AR::Connection#clear_stale_cached_connections! methodFrancesco Rodriguez2013-07-011-5/+0
|
* Fix documents for create_join_tableSatoshi Ebisawa2013-06-211-2/+2
|
* Merge pull request #10425 from ↵Rafael Mendonça França2013-06-132-11/+3
|\ | | | | | | | | ranjaykrishna/push_add_column_options_to_schema_creation Push add column options to schema creation
| * Moving add_column_options! up to SchemaCreationjeran2013-06-122-11/+3
| | | | | | | | | | | | | | | | removed two instances of add_column_options! from abstract_mysql_adapter reworked rename_column_sql to remove add_column_options from schema_statements changed to use new hash syntax.
* | Fixes #10432 add_column not creating array columns in PostgreSQLAdam Anderson2013-06-041-0/+1
| | | | | | | | | | | | When then PostgreSQL visitor was [added](https://github.com/rails/rails/commit/6b7fdf3bf3675a14eae74acc5241089308153a34) `add_column` was no longer receiving the column options directly. This caused the options to be lost along the way.
* | Remove behavior that deals with a string as third argument of `add_index`, ↵kennyj2013-06-021-28/+14
| | | | | | | | | | | | because this was deprecated. Some testcases is failed, so I replaced nil to empty hash in add_reference.
* | Merge pull request #10556 from Empact/deprecate-schema-statements-distinctRafael Mendonça França2013-05-121-1/+2
| | | | | | | | | | | | Deprecate SchemaStatements#distinct, and make SchemaStatements#columns_for_distinct nodoc. Conflicts: activerecord/CHANGELOG.md
* | Merge pull request #10572 from nertzy/dont-modify-options-hash-in-primary-keyRafael Mendonça França2013-05-111-2/+1
| | | | | | | | Don't modify args in TableDefinition#primary_key
* | Fix that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"Ben Woosley2013-05-101-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | The combination of a :uniq => true association and the #distinct call in #construct_limited_ids_condition combine to create invalid SQL, because we're explicitly selecting DISTINCT, and also sending #distinct on to AREL, via the relation#distinct_value. Rather than build a select distinct clause in #construct_limited_ids_condition, I set #distinct! and pass just the columns into the select statement. This requires introducing a #columns_for_distinct method to return the select columns but not the statement itself.
* | Move method used only in the test to the test code itselfIvan Kataitsev2013-04-251-8/+0
| |
* | Make references with index:true pass Hash options to add_index.Victor Costan2013-04-011-1/+1
| |
* | Refactor index algorithm lookup so that it only builds the available options ↵Carlos Antonio da Silva2013-03-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | once This way the available options are only built for actually fetching the algorithm in case the option is given. The options are going to be necessary a second time only in case the option is given but does not exist, which is supposed to be due to a typo or something like that, so no problem.
* | Make docs a little bit more consistent with colons [ci skip]Carlos Antonio da Silva2013-03-301-9/+9
| |