aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* 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 #25396 from ↵Rafael França2016-08-171-1/+1
|\ | | | | | | | | kamipo/fix_error_message_for_out_of_range_integer_value Fix error message for out of range byte size integer value for consistency
| * Fix error message for out of range byte size integer value for consistencyRyuta Kamizono2016-08-071-1/+1
| | | | | | | | Related f27a932, #25391.
* | Merge pull request #26002 from ↵Rafael França2016-08-172-8/+12
|\ \ | | | | | | | | | | | | 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-062-8/+12
| | | | | | | | | | | | | | | `exec_insert` cannot return last inserted id if `use_insert_returning?` is true. `sql_for_insert` should be called inside `exec_insert`.
* | | Extract `PredicateBuilder::CaseSensitiveHandler`Ryuta Kamizono2016-08-162-10/+9
| | | | | | | | | | | | | | | | | | Currently uniqueness validator is coupled with building Arel ASTs. This commit extracts `PredicateBuilder::CaseSensitiveHandler` for decouple the building Arel ASTs.
* | | 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-162-29/+25
|\ \ \ \ | | | | | | | | | | | | | | | 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-142-29/+25
| |/ / /
* | | | 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-169-30/+30
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | | | Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-2/+4
| | | | | | | | | | | | | | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* | | | Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
| |_|/ |/| |
* | | Merge pull request #26073 from kamipo/revert_passing_splat_binds_for_arel_nodeSean Griffin2016-08-062-6/+2
|\ \ \ | | | | | | | | Revert passing arel node with splat binds for `where`
| * | | Don't passing a nil value to `case_sensitive_comparison`Ryuta Kamizono2016-08-062-6/+2
| | |/ | |/| | | | | | | | | | A `value` is only used for checking `value.nil?`. It is unnecessary if immediately return when `value.nil?`.
* | | applies remaining conventions across the projectXavier Noria2016-08-068-70/+62
| | |
* | | normalizes indentation and whitespace across the projectXavier Noria2016-08-0636-1092/+1092
| | |
* | | remove redundant curlies from hash argumentsXavier Noria2016-08-061-6/+4
| | |
* | | modernizes hash syntax in activerecordXavier Noria2016-08-067-18/+18
| | |
* | | applies new string literal convention in activerecord/libXavier Noria2016-08-0636-395/+395
|/ / | | | | | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* | Merge pull request #26051 from kamipo/make_name_and_binds_to_optional_argsEileen M. Uchitelle2016-08-053-6/+6
|\ \ | | | | | | Make `name` and `binds` to optional args for `exec_{insert,update,delete}`
| * | Make `name` and `binds` to optional args for `exec_{insert,update,delete}`Ryuta Kamizono2016-08-043-6/+6
| | | | | | | | | | | | | | | | | | `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.
* | | Leave internal pgsql name intact as const referenceDavid Heinemeier Hansson2016-08-041-2/+2
| | |
* | | The problem isn't the detection but the deadlock itselfDavid Heinemeier Hansson2016-08-042-4/+4
|/ /
* | Merge pull request #25107 from Erol/introduce-new-ar-transaction-error-classesRafael Mendonça França2016-08-032-2/+5
|\ \ | | | | | | | | | | | | | | | Introduce new ActiveRecord transaction error classes Closes #26018
| * | Introduce new ActiveRecord transaction error classesErol Fornoles2016-05-242-2/+5
| | |
* | | 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.
* | | Merge pull request #25937 from kamipo/remove_prepare_binds_for_databaseRafael França2016-07-283-6/+2
|\ \ \ | | | | | | | | Remove `prepare_binds_for_database` internal method
| * | | Remove `prepare_binds_for_database` internal methodRyuta Kamizono2016-07-283-6/+2
| | | | | | | | | | | | | | | | To avoid relying on the connection adapter for type casting binds.
* | | | Merge pull request #25340 from kamipo/prevent_table_comment_queryRafael França2016-07-282-3/+13
|\ \ \ \ | | | | | | | | | | Prevent `table_comment` query if a table doesn't have a comment
| * | | | Prevent `table_comment` query if a table doesn't have a commentRyuta Kamizono2016-06-102-3/+13
| | | | |
* | | | | Merge pull request #25974 from ↵Rafael França2016-07-281-2/+4
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | kamipo/avoid_calling_current_database_in_table_comment Avoid calling `current_database` in `table_comment`
| * | | | | Avoid calling `current_database` in `table_comment`Ryuta Kamizono2016-07-281-2/+4
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | `current_database` executes a query and `table_comment` is called to all tables even if a table does not have a comment. Using `current_database` increases extra queries.
* / | | | `@quoted_{column,table}_names` should cache a frozen stringRyuta Kamizono2016-07-283-5/+5
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Caching a mutable string causes the following issue. ``` Loading development environment (Rails 5.1.0.alpha) irb(main):001:0> ActiveRecord::Base.connection.quote_table_name('foo') << '!!' => "`foo`!!" irb(main):002:0> ActiveRecord::Base.connection.quote_table_name('foo') << '!!' => "`foo`!!!!" irb(main):003:0> ActiveRecord::Base.connection.quote_table_name('foo') << '!!' => "`foo`!!!!!!" ```
* | | | Add the TABLE_SCHEMA condition to the SELECT statement in table_comment (#25945)Takeshi AKIMA2016-07-271-1/+2
| | | | | | | | | | | | [Rafael Mendonça França + Takeshi AKIMA]
* | | | 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-272-5/+5
|\ \ \ \ \ | | | | | | | | | | | | Quoting booleans should return a frozen string
| * | | | | Quoting booleans should return a frozen stringRyuta Kamizono2016-07-272-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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" ```
* | | | | | Merge pull request #25523 from kamipo/extract_quoted_binds_type_casted_bindsSean Griffin2016-07-264-6/+10
|\ \ \ \ \ \ | |/ / / / / |/| | | | | Extract `type_casted_binds` method
| * | | | | Extract `type_casted_binds` methodRyuta Kamizono2016-07-264-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because `type_cast` against `binds` always requires `attr.value_for_database` and this pattern appears frequently.
* | | | | | adds missing requiresXavier Noria2016-07-241-0/+1
| |/ / / / |/| | | |
* | | | | systematic revision of =~ usage in ARXavier Noria2016-07-233-3/+3
|/ / / / | | | | | | | | | | | | | | | | Where appropriatei, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
* | | | Merge pull request #25578 from ↵Rafael França2016-07-202-8/+11
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | kamipo/move_warning_about_composite_primary_key_to_attribute_methods_primary_key Move the warning about composite primary key to `AttributeMethods::PrimaryKey`