aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Fix table comment dumpingRyuta Kamizono2016-10-111-1/+3
| | | | | | | | | | | | | Follow up to #26735. If `table_options` returns `{ comment: nil }`, `create_table` line is broken. Example: ```ruby create_table "accounts", force: :cascade, do |t| ```
* `name` is not a column optionRyuta Kamizono2016-10-102-3/+2
| | | | `migration_keys` includes `name` but `name` is not a column option.
* Dump index options to pretty formatRyuta Kamizono2016-10-102-3/+3
| | | | | | | | | | ```ruby # Before t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree # After t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree ```
* Prevent to create blank commentRyuta Kamizono2016-10-082-3/+3
| | | | | Currently blank comment does not dump to `db/schema.rb`. But created it even if specified blank.
* Merge pull request #26584 from Shopify/cached-query-nameRafael França2016-09-301-4/+10
|\ | | | | Preserve cached queries name in AS notifications
| * Preserve cached queries name in AS notificationsJean Boussier2016-09-221-4/+10
| |
* | [ci skip] Update PG adapter documentationAlex Kitchens2016-09-261-1/+1
| | | | | | | | | | | | | | | | Per discussion in pull request #26622: "Let's change it to PG::Error. The more specific classes mentioned are subclasses, and the fact the raised exception is a PG::UndefinedColumn doesn't change the fact that it's also a PG::Error." - matthewd
* | [ci skip] Clarify Postgresql DocumentationAlex Kitchens2016-09-251-4/+4
|/ | | | | This clarifies the object that +ActiveRecord::Base.connection.execute+ will return when using Postgresql.
* Force correct namespace when using TransactionManagerArthur Neves2016-09-161-1/+1
| | | | [fixes #26441]
* fix typo in `add_column` doc [ci skip]yuuji.yaginuma2016-09-161-1/+1
|
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-145-96/+96
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* activerecord/mysql2: Avoid setting @connection to nil, just close itDylan Thacker-Smith2016-09-082-15/+7
| | | | | | | | | | By doing `@connection = nil` that means that we need nil checks before it is used anywhere, but we weren't doing those checks. Instead, we get a NoMethodError after using a connection after it fails to reconnect. Neither of the other adapters set @connection to nil, just the mysql2 adapter. By just closing it, we avoid the need to check if we have a connection object and it will produce an appropriate exception when used.
* Fix Remaining Case-In-Assignment Statement FormattingAlex Kitchens2016-09-062-41/+43
| | | | | | | | | Recently, the Rails team made an effort to keep the source code consistent, using Ruboco (bb1ecdcc677bf6e68e0252505509c089619b5b90 and below). Some of the case statements were missed. This changes the case statements' formatting and is consistent with changes in 810dff7c9fa9b2a38eb1560ce0378d760529ee6b and db63406cb007ab3756d2a96d2e0b5d4e777f8231.
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-012-4/+4
|
* Remove deprecated handling of PG PointsSean Griffin2016-08-314-21/+32
| | | | | | | | | | There are some minor changes to the point type as I had forgotten that this will affect the behavior of `t.point` in migrations and the schema dumper so we need to handle those as well. I'll say this again so I can convince myself to come up with a better structure... TYPES SHOULD NOT CARE ABOUT SCHEMA DUMPING AND WE NEED TO BETTER SEPARATE THESE.
* Revert "Extract `PredicateBuilder::CaseSensitiveHandler`"Sean Griffin2016-08-312-9/+10
| | | | | | | | | This reverts commit 3a1f6fe7b4a70bf0698b0684dd48ac712c6883b6. This commit takes the code in a direction that I am looking to avoid. The predicate builder should be purely concerned with AST construction as it matters to methods like `where`. Things like case sensitivity should continue to be handled elsewhere.
* Attempt to maintain encoding for arrays of strings with PGSean Griffin2016-08-311-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | I still think that this is something that should be handled in the pg gem, but it's not going to end up happening there so we'll do it here instead. Once we bump to pg 0.19 we can pass the encoding to the `encode` method instead. This issue occurs because C has no concept of encoding (or strings, really). The bytes that we pass here when sending the value to the database will always be interpreted as whatever encoding the connection is currently configured to use. That means that roundtripping to the database will lose no information However, after assigning we round trip through our type system without hitting the database. The only way that we can do the "correct" thin here would be to actually give a reference to the connection to the array type and have it check the current value of the connection's encoding -- which I'm strongly opposed to. We could also pass in the encoding when it's constructed, but since that can change independently of the type I'm not a huge fan of that either. This feels like a reasonable middle ground, where if we have an array of strings we simply use the encoding of the string we're given. Fixes #26326.
* Add `Type.default_value` and use it everywhere for internalRyuta Kamizono2016-08-261-1/+1
| | | | For reduce instantiating `Type::Value`.
* Fix `OID::Bit#cast_value`Ryuta Kamizono2016-08-201-2/+2
| | | | Fixes #26137.
* Remove unused `blob_or_text_column?` methodRyuta Kamizono2016-08-191-4/+0
|
* Merge pull request #26154 from ↵Rafael Mendonça França2016-08-193-24/+5
|\ | | | | | | | | | | kamipo/remove_text_default_treated_as_empty_string Remove text default treated as an empty string in non-strict mode
| * Remove text default treated as an empty string in non-strict modeRyuta Kamizono2016-08-193-24/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. If strict mode is not in effect, MySQL inserts adjusted values for invalid or missing values and produces warnings. ```ruby def test_mysql_not_null_defaults_non_strict using_strict(false) do with_mysql_not_null_table do |klass| record = klass.new assert_nil record.non_null_integer assert_nil record.non_null_string assert_nil record.non_null_text assert_nil record.non_null_blob record.save! record.reload assert_equal 0, record.non_null_integer assert_equal "", record.non_null_string assert_equal "", record.non_null_text assert_equal "", record.non_null_blob end end end ``` It is inconsistent with other types that only text/blob defaults treated as an empty string. This commit fixes the inconsistency.
* | 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.
* | Merge pull request #26089 from travisoneill/sqlite_rollback_fixRafael Mendonça França2016-08-192-2/+3
|\ \ | |/ |/| | | Sqlite3 Migration Error Fixed (issue #26087)
| * 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
* | Remove unnecessary `test_sql_for_insert_with_returning_disabled`Ryuta Kamizono2016-08-181-3/+2
|/ | | | | Because `sql_for_insert` is only called in `use_insert_returning?` is true since #26002.
* 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.