aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #26217 from kamipo/revert_23067Rafael França2016-08-191-1/+1
|\ | | | | Revert "`sql_for_insert` returns values for passing to `exec_insert`"
| * 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.
* | Added nil case handling to allow rollback migration in case oftravis.h.oneill@gmail.com2016-08-172-2/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | invalid column type /activerecord/lib/active_record/connection_adapters /abstract/schema_definitions.rb:306 type = type.to_sym Changed to the following to handle nil case: type = type.to_sym if type Added regression test for this case: /activerecord/test/cases/migration_test.rb:554 if current_adapter?(:SQLite3Adapter) def test_allows_sqlite3_rollback_on_invalid_column_type Person.connection.create_table :something, force: true do |t| t.column :number, :integer t.column :name, :string t.column :foo, :bar end assert Person.connection.column_exists?(:something, :foo) assert_nothing_raised { Person.connection.remove_column :something, :foo, :bar } assert !Person.connection.column_exists?(:something, :foo) assert Person.connection.column_exists?(:something, :name) assert Person.connection.column_exists?(:something, :number) ensure Person.connection.drop_table :something, if_exists: true end end
* 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 array column documentationoss922016-08-161-0/+4
| |
* | Merge pull request #26151 from kamipo/avoid_to_allow_unused_splat_argsRafael França2016-08-161-3/+1
|\ \ | | | | | | Avoid to allow unused splat args for `t.timestamps` in `create_table`
| * | Avoid to allow unused splat args for `t.timestamps` in `create_table`Ryuta Kamizono2016-08-141-3/+1
| | | | | | | | | | | | | | | | | | Unfortunately `t.timestamps` in `create_table` allows unused splat args. But the same one in `change_table` does not allow them. This commit fixes the inconsistent behavior.
* | | Merge pull request #26155 from kamipo/refactor_quoted_columns_for_indexRafael Mendonça França2016-08-161-13/+16
|\ \ \ | | | | | | | | | | | | Refactor `quoted_columns_for_index` by extracted `add_options_for_index_columns`
| * | | Refactor `quoted_columns_for_index` by extracted `add_options_for_index_columns`Ryuta Kamizono2016-08-141-13/+16
| |/ /
* | | Merge pull request #26019 from agrobbin/schema-load-unique-column-indicesRafael França2016-08-162-3/+3
|\ \ \ | | | | | | | | Support multiple indexes on the same column when loading the schema
| * | | support multiple indexes on the same column when loading the schemaAlex Robbin2016-08-022-3/+3
| | | |
* | | | Add three new rubocop rulesRafael Mendonça França2016-08-163-13/+13
| |/ / |/| | | | | | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | | Fix a NoMethodError schema_statements.rbGenadi Samokovarov2016-08-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you call `remove_index` with wrong options, say a type, like I did, you get: ``` == 20160810072541 RemoveUniqueIndexOnGoals: migrating ========================= -- remove_index(:goal, {:coulmn=>:kid_id, :unique=>true}) rails aborted! StandardError: An error has occurred, this and all later migrations canceled: undefined method `ArgumentError' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x007fb7dec91b28> ``` What happened is that I mistyped column (coulmn) and got a `NoMethodError`, because of a missing comma during the raise. This made Ruby think we're calling the method `ArgumentError`.
* | | applies remaining conventions across the projectXavier Noria2016-08-063-7/+0
| | |
* | | normalizes indentation and whitespace across the projectXavier Noria2016-08-066-338/+338
| | |
* | | modernizes hash syntax in activerecordXavier Noria2016-08-063-5/+5
| | |
* | | applies new string literal convention in activerecord/libXavier Noria2016-08-068-31/+31
| |/ |/| | | | | | | 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 extra connection pool creationArthur Neves2016-08-021-1/+0
| |
* | Merge branch 'master' of github.com:rails/docrailsVijay Dev2016-08-021-1/+1
|\ \ | |/ |/|
| * Fix documentation of `index` option for the `add_reference` method [ci skip]Prathamesh Sonpatki2016-07-161-1/+1
| | | | | | | | - Followup of https://github.com/rails/rails/pull/23179.
* | Remove `prepare_binds_for_database` internal methodRyuta Kamizono2016-07-282-5/+1
| | | | | | | | To avoid relying on the connection adapter for type casting binds.
* | Merge pull request #25938 from ↵Rafael França2016-07-271-3/+4
|\ \ | | | | | | | | | | | | kamipo/decouple_statement_cache_from_connection_adapter Decouple statement cache from connection adapter
| * | 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.
* | | Merge pull request #25408 from kamipo/should_not_reuse_quoted_trueYves Senn2016-07-271-4/+4
|\ \ \ | | | | | | | | Quoting booleans should return a frozen string
| * | | Quoting booleans should return a frozen stringRyuta Kamizono2016-07-271-4/+4
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If reuse `QUOTED_TRUE` and `QUOTED_FALSE` without frozen, causing the following issue. ``` Loading development environment (Rails 5.1.0.alpha) irb(main):001:0> ActiveRecord::Base.connection.quote(true) << ' foo' => "1 foo" irb(main):002:0> ActiveRecord::Base.connection.quote(true) << ' foo' => "1 foo foo" irb(main):003:0> type = ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::MysqlString.new => #<ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::MysqlString:0x007fd40c15e018 @precision=nil, @scale=nil, @limit=nil> irb(main):004:0> type.serialize(true) << ' bar' => "1 foo foo bar" irb(main):005:0> type.cast(true) << ' bar' => "1 foo foo bar bar" ```
* / / Extract `type_casted_binds` methodRyuta Kamizono2016-07-261-0/+4
|/ / | | | | | | | | Because `type_cast` against `binds` always requires `attr.value_for_database` and this pattern appears frequently.
* | Merge pull request #25578 from ↵Rafael França2016-07-201-8/+3
|\ \ | | | | | | | | | | | | kamipo/move_warning_about_composite_primary_key_to_attribute_methods_primary_key Move the warning about composite primary key to `AttributeMethods::PrimaryKey`
| * | Move the warning about composite primary key to `AttributeMethods::PrimaryKey`Ryuta Kamizono2016-07-021-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Actually schema dumper/creation supports composite primary key (#21614). Therefore it should not show the warning about composite primary key in connection adapter. This change moves the warning to `AttributeMethods::PrimaryKey` and suppress the warning for habtm join table. Fixes #25388.
* | | Merge pull request #25889 from kamipo/do_not_dup_binds_in_to_sqlRafael França2016-07-201-1/+1
|\ \ \ | | | | | | | | Do not `binds.dup` in `connection#to_sql`
| * | | Do not `binds.dup` in `connection#to_sql`Ryuta Kamizono2016-07-191-1/+1
| | | | | | | | | | | | | | | | Because `connection#to_sql` does not mutate `binds`.
* | | | Merge pull request #25869 from kamipo/specificiation_id_was_renamed_to_spec_nameRafael França2016-07-201-1/+1
|\ \ \ \ | | | | | | | | | | `specificiation_id` was renamed to `spec_name`
| * | | | `specificiation_id` was renamed to `spec_name`Ryuta Kamizono2016-07-181-1/+1
| |/ / /
* / / / Fix `payload[:class_name]` to `payload[:spec_name]`Ryuta Kamizono2016-07-171-1/+1
|/ / / | | | | | | | | | | | | | | | Follow up to #20818. `retrieve_connection` is passed `spec_name` instead of `klass` since #24844.
* | | Merge pull request #20818 from ↵Rafael França2016-07-171-0/+15
|\ \ \ | | | | | | | | | | | | | | | | jeremywadsack/use_transactional_fixtures_all_databases Use notification to ensure that lazy-loaded model classes have transactions
| * | | Create connection.active_record notification and use that to ensure that lazy-Jeremy Wadsack2016-07-121-0/+15
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | loaded model classes have their connections wrapped in transactions. See #17776 In Rails 4 config.eager_load was changed to false in the test environment. This means that model classes that connect to alternate databases with establish_connection are not loaded at start up. If use_transactional_fixtures is enabled, transactions are wrapped around the connections that have been established only at the start of the test suite. So model classes loaded later don't have transactions causing data created in the alternate database not to be removed. This change resolves that by creating a new connection.active_record notification that gets fired whenever a connection is established. I then added a subscriber after we set up transactions in the test environment to listen for additional connections and wrap those in transactions as well.
* / | Add newline between each migration in `structure.sql`Grey Baker2016-07-141-2/+2
|/ / | | | | | | | | | | Keeps schema migration inserts as a single commit, so we still get all of the benefits of https://github.com/rails/rails/commit/42dd2336b31a8d98776d039a2b9fd7f834156a78, but allows for easier git diff-ing. Fixes #25504.
* | [ci skip] Update documentation in AR SchemaStatementsAlex Kitchens2016-07-071-12/+12
| | | | | | | | This includes minor grammar fixes throughout the file.
* | Merge pull request #25707 from matthewd/double-reapMatthew Draper2016-07-071-9/+15
|\ \ | | | | | | Don't reap connections that have already been reassigned
| * | Make connection stealing more explicitMatthew Draper2016-07-061-4/+9
| | |
| * | Reduce locking by taking ownership of stale connectionsMatthew Draper2016-07-061-9/+8
| | | | | | | | | | | | | | | | | | This way, we aren't racing other threads, so we don't need to re-check the conditional. And we no longer need to hold the lock while calling remove (which can choose to make a new connection while we wait).
| * | Re-check that the connection is still stale before we reap itMatthew Draper2016-07-061-0/+2
| |/ | | | | | | | | | | | | A concurrent thread may have also detected it to be stale, and already released (or even reassigned) it by now. Fixes #25585
* / [ci skip] Update ConnectionPool documentation for readabilityAlex Kitchens2016-07-061-21/+21
|/
* Reuse existing validate_index_length! methodPrathamesh Sonpatki2016-06-091-7/+7
| | | | - Followup of https://github.com/rails/rails/commit/1ea6cc11211dc89e3e14b2b641a3cca8a0a91d55.
* Fix failing testsSean Griffin2016-06-021-4/+5
| | | | | | | | | | | | | | | | | | | Currently CI is broken due to 56a61e0 and c4cb686. This occurred because the failures are not present on SQLite which is what I normally run locally before pushing. The optimizations to our YAML size were dropping mutations, as `with_type` didn't set the previous value if it'd already been read (that method was never really designed to be used with values on individual objects, it was previously only used for defaults). I'm questioning whether there's a better place to be handling the exclusion of the type, but this will fix the failing build. Additionally, there was a bug in `remove_foreign_key` if you passed it an options hash containing `to_table`. This now occurs whenever removing a reference, as we always normalize to a hash. [Sean Griffin & Ryuta Kamizono]
* Respect options passed to `foreign_key` when reverting `add_reference`Sean Griffin2016-05-311-4/+9
| | | | | | | | | | | | The code incorrectly assumes that the option was written as `foreign_key: true`, but that is not always the case. This now mirrors the behavior of reverting `add_foreign_key`. The code was changed to use kwargs while I was touching it, as well. This could really use a refactoring to go through the same code paths as `add_refernce` in the future, so we don't duplicate default values. Fixes #25169
* Add to_hash to specificationArthur Neves2016-05-251-2/+1
|
* Remove `name` from `establish_connection`Arthur Neves2016-05-241-10/+7
| | | | | Instead of passing a separete name variable, we can make the resolver merge a name on the config, and use that before creating the Specification.
* Move establish_connection to handlerArthur Neves2016-05-241-1/+9
|