aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | Avoid using index_xinfo, only available in sqlite >= 3.8.9Paul Kuruvilla2017-10-251-9/+12
| | | |
| * | | Save index order :desc to schema.rb (sqlite). Fixes #30902Paul Kuruvilla2017-10-241-2/+9
| | | | | | | | | | | | | | | | | | | | Although the sqlite adapter supports index sort orders, they weren't being written to db/schema.rb.
* | | | `supports_extensions?` return always true since PostgreSQL 9.1Yasuo Honda2017-10-241-9/+3
|/ / / | | | | | | | | | | | | | | | | | | | | | since the minimum version of PostgreSQL currently Rails supports is 9.1, there is no need to handle if `supports_extensions?` Refer https://www.postgresql.org/docs/9.1/static/sql-createextension.html "CREATE EXTENSION"
* | | Remove `supports_disable_referential_integrity?`Yasuo Honda2017-10-231-25/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `supports_disable_referential_integrity?` used to handle if PostgreSQL database supports `ALTER TABLE <table name> DISABLE/ENABLE TRIGGER` statements. Refer https://github.com/rails/rails/commit/9a947af0e79cfb8692eb7e5ae94c1b8c40756f49 These statements have been documented since 8.1. https://www.postgresql.org/docs/8.1/static/sql-altertable.html > DISABLE/ENABLE TRIGGER Now Rails supports PostgreSQL 9.1 or higher only. No need to handle `supports_disable_referential_integrity?` anymore. Also, this method does not exist in any other adapters including AbstractAdapter.
* | | Remove deprecated arguments from `#verify!`Rafael Mendonça França2017-10-231-4/+1
| | |
* | | Remove deprecated argument `name` from `#indexes`Rafael Mendonça França2017-10-234-24/+4
| | |
* | | Remove deprecated method `supports_primary_key?`Rafael Mendonça França2017-10-231-5/+0
| | |
* | | Remove deprecated method `supports_migrations?`Rafael Mendonça França2017-10-231-5/+0
| | |
* | | Remove deprecated methods `initialize_schema_migrations_table` and ↵Rafael Mendonça França2017-10-231-10/+0
| | | | | | | | | | | | `initialize_internal_metadata_table`
* | | Remove deprecated argument `default` from `index_name_exists?`Rafael Mendonça França2017-10-232-12/+2
| | |
* | | Remove deprecated support to `quoted_id` when typecasting an Active Record ↵Rafael Mendonça França2017-10-231-17/+0
| | | | | | | | | | | | object
* | | [Active Record] require => require_relativeAkira Matsuda2017-10-217-62/+62
| | | | | | | | | | | | This basically reverts 9d4f79d3d394edb74fa2192e5d9ad7b09ce50c6d
* | | Fix longer sequence name detection for serial columns (#28339)Ryuta Kamizono2017-10-154-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | We already found the longer sequence name, but we could not consider whether it was the sequence name created by serial type due to missed a max identifier length limitation. I've addressed the sequence name consideration to respect the max identifier length. Fixes #28332.
* | | MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`Ryuta Kamizono2017-10-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently `AUTO_INCREMENT` is implicitly used in the default primary key definition. But `AUTO_INCREMENT` is not only used for single column primary key, but also for composite primary key. In that case, `auto_increment: true` should be dumped explicitly in the `db/schema.rb`. Fixes #30894.
* | | Merge pull request #30798 from ↵Sean Griffin2017-10-091-1/+1
|\ \ \ | | | | | | | | | | | | | | | | bogdanvlviv/express-change_column_comment-as-public-api Express #change_column_comment as public api
| * | | Express #change_column_comment as public apibogdanvlviv2017-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | Implemented by #22911 Related to #30677
* | | | Fix typo in loading error messageyuuji.yaginuma2017-10-091-1/+1
| | | | | | | | | | | | | | | | s/Action Record/Active Record/
* | | | Distinguish missing adapter gems from load errors within the adapterJeremy Daer2017-10-081-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * When the adapter is missing, raise an exception that points out config typos and missing Gemfile entries. (We can assume that a non-builtin adapter was used since these are always available.) * When loading an adapter raises a LoadError, prefix its error message to indicate that the adapter is likely missing an optional dependency.
* | | | Add JSON attribute test cases for SQLite3 adapterRyuta Kamizono2017-10-052-1/+2
|/ / /
* | | Prefer official name PostgreSQL over PostgresRyuta Kamizono2017-10-041-2/+2
| | |
* | | `Postgres::OID::Range` serializes to a `Range`, quote in `Quoting`Thomas Cannon2017-09-262-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PostgreSQL 9.1+ introduced range types, and Rails added support for using this datatype in ActiveRecord. However, the serialization of `PostgreSQL::OID::Range` was incomplete, because it did not properly quote the bounds that make up the range. A clear example of this is a `tsrange`. Normally, ActiveRecord quotes Date/Time objects to include the milliseconds. However, the way `PostgreSQL::OID::Range` serialized its bounds, the milliseconds were dropped. This meant that the value was incomplete and not equal to the submitted value. An example of normal timestamps vs. a `tsrange`. Note how the bounds for the range do not include their milliseconds (they were present in the ruby Range): UPDATE "iterations" SET "updated_at" = $1, "range" = $2 WHERE "iterations"."id" = $3 [["updated_at", "2017-09-23 17:07:01.304864"], ["range", "[2017-09-23 00:00:00 UTC,2017-09-23 23:59:59 UTC]"], ["id", 1234]] `PostgreSQL::OID::Range` serialized the range by interpolating a string for the range, which works for most cases, but does not work for timestamps: def serialize(value) if value.is_a?(::Range) from = type_cast_single_for_database(value.begin) to = type_cast_single_for_database(value.end) "[#{from},#{to}#{value.exclude_end? ? ')' : ']'}" else super end end (byebug) from = type_cast_single_for_database(value.begin) 2010-01-01 13:30:00 UTC (byebug) to = type_cast_single_for_database(value.end) 2011-02-02 19:30:00 UTC (byebug) "[#{from},#{to}#{value.exclude_end? ? ')' : ']'}" "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)" @sgrif (the original implementer for Postgres Range support) provided some feedback about where the quoting should occur: Yeah, quoting at all is definitely wrong here. I'm not sure what I was thinking in 02579b5, but what this is doing is definitely in the wrong place. It should probably just be returning a range of subtype.serialize(value.begin) and subtype.serialize(value.end), and letting the adapter handle the rest. `Postgres::OID::Range` now returns a `Range` object, and `ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting` can now encode and quote a `Range`: def encode_range(range) "[#{type_cast(range.first)},#{type_cast(range.last)}#{range.exclude_end? ? ')' : ']'}" end ... encode_range(range) #=> "['2010-01-01 13:30:00.670277','2011-02-02 19:30:00.745125')" This commit includes tests to make sure the milliseconds are preserved in `tsrange` and `tstzrange` columns
* | | Preload digest/sha2 to avoid thread safe error.Francesco Rodriguez2017-09-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I got this error in production using Puma in multi-threaded mode: ``` RuntimeError: Digest::Base cannot be directly inherited in Ruby from active_support/security_utils.rb:23:in `variable_size_secure_compare' from active_support/security_utils.rb:23:in `hexdigest' from active_support/security_utils.rb:23:in `digest' ``` Looks like Digest uses const_missing to load Digest::SHA256 (https://github.com/ruby/ruby/blob/trunk/ext/digest/lib/digest.rb#L8) - https://bugs.ruby-lang.org/issues/9494 - https://github.com/ruby/ruby/commit/c02fa39463a0c6bf698b01bc610135604aca2ff4
* | | Extract `integer_like_primary_key_type` to ease to handle it for adaptersRyuta Kamizono2017-09-254-17/+18
| | |
* | | Move integer-like primary key normalization to `new_column_definition`Ryuta Kamizono2017-09-235-31/+27
| | | | | | | | | | | | | | | | | | Currently the normalization only exists in `primary_key` shorthand. It should be moved to `new_column_definition` to also affect to `add_column` with primary key.
* | | Prevent extra `column_for` for `change_column_{default,null,comment}`Ryuta Kamizono2017-09-231-7/+4
| | | | | | | | | | | | | | | | | | | | | `change_column_{default,null,comment}` in mysql2 adapter are passing `column.sql_type` as `type` to `change_column` to intend keeping previous type. But `column_for` requires extra query, so use passing `nil` to `type` explicitly in the internal for the purpose.
* | | `index_name` should be quotedRyuta Kamizono2017-09-221-1/+1
| | |
* | | Return nil if table comment is blankRyuta Kamizono2017-09-221-1/+1
| | |
* | | Implement change_table_comment and change_column_comment for MySql AdapterAlecs Popa2017-09-221-0/+10
| | |
* | | Merge pull request #30656 from yskkin/add_column_docRyuta Kamizono2017-09-201-0/+2
|\ \ \ | | | | | | | | Add :comment option for add_column [ci skip]
| * | | Add :comment option for add_column [ci skip]Yoshiyuki Kinjo2017-09-201-0/+2
| | | |
* | | | Fix collided sequence name detectionRyuta Kamizono2017-09-181-1/+8
|/ / / | | | | | | | | | | | | | | | If collided named sequence already exists, newly created serial column will generate alternative sequence name. Fix sequence name detection to allow the alternative names.
* | | Don't use `quoted_table_name` in `limited_ids_for`Ryuta Kamizono2017-09-141-1/+5
| | | | | | | | | | | | | | | | | | Because `quoted_table_name` doesn't respect table alias. We should use `arel_attribute` for that, so I added `column_name_from_arel_node` to generate column name from an arel node.
* | | Fix `quote_default_expression` for UUID with array defaultRyuta Kamizono2017-09-081-1/+1
| | | | | | | | | | | | Fixes #30539.
* | | Should quote composite primary key namesRyuta Kamizono2017-09-041-1/+1
| |/ |/| | | | | | | | | | | Otherwise using reserved words as composite primary key names will be failed as an invalid SQL. Fixes #30518.
* | `add_reference` should respect column position for both reference id and ↵Ryuta Kamizono2017-09-011-1/+1
| | | | | | | | | | | | type columns Fixes #30496.
* | Merge pull request #30445 from prathamesh-sonpatki/fix-30441Kasper Timm Hansen2017-08-281-0/+2
|\ \ | | | | | | Clarify that bulk option is supported only by MySQL
| * | Clarify that bulk option is supported only by MySQL [ci skip]Prathamesh Sonpatki2017-08-291-0/+2
| | | | | | | | | | | | - Closes #30441
* | | Omit the default limit for float columns (#28041)Ryuta Kamizono2017-08-271-1/+1
|/ /
* | Use tt in doc for ActiveRecord [ci skip]Yoshiyuki Hirano2017-08-271-2/+2
| |
* | Merge pull request #30337 from kamipo/refactor_schema_dumperRyuta Kamizono2017-08-2412-49/+47
|\ \ | | | | | | Refactor `SchemaDumper` to make it possible to adapter specific customization
| * | Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-2212-35/+48
| | | | | | | | | | | | | | | | | | | | | Currently `SchemaDumper` is only customizable for column options. But 3rd party connection adapters (oracle-enhanced etc) need to customizable for table or index dumping also. To make it possible, I introduced adapter specific `SchemaDumper` classes for that.
| * | Remove deprecated `#migration_keys`Ryuta Kamizono2017-08-223-15/+0
| | |
* | | Merge pull request #30360 from gcourtemanche/transaction_timedoutRafael França2017-08-221-0/+3
|\ \ \ | |/ / |/| | Add TransactionTimeout for MySQL error code 1205
| * | Add TransactionTimeout for MySQL error code 1205Gabriel Courtemanche2017-08-221-0/+3
| | |
* | | Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-226-7/+7
|/ /
* | Prevent extra `SET time zone` in `configure_connection` (#28413)Ryuta Kamizono2017-08-211-6/+8
| | | | | | | | | | | | | | | | `SET time zone 'value'` is an alias for `SET timezone TO 'value'`. https://www.postgresql.org/docs/current/static/sql-set.html So if `variables["timezone"]` is specified, it is enough to `SET timezone` once.
* | Require "active_support/core_ext/hash/compact" for `compact!`Ryuta Kamizono2017-08-211-0/+2
| |
* | Place `update_table_definition` consistently in `SchemaStatements`Ryuta Kamizono2017-08-216-12/+12
| |
* | Don't expose `prepare_column_options`Ryuta Kamizono2017-08-213-52/+30
| | | | | | | | | | This is only used for the internal `column_spec` and `column_spec_for_primary_key`.
* | Register integer types limit correctly for postgresql adapter (#26386)Ryuta Kamizono2017-08-201-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | currently integer types extracts the `limit` from `sql_type`. But the lookup key of type map is the `oid` in postgresql adapter. So in most case `sql_type` is passed to `extract_limit` as `""` and `limit` is extracted as `nil`. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L445 In mysql2 adapter, `limit` is registered correctly without extracting from `sql_type`. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L678-L682 Postgresql adapter should also be registered correctly. ``` ruby conn = ActiveRecord::Base.connection conn.select_all("SELECT 1::smallint, 2::integer, 3::bigint").column_types.map do |name, type| [name, type.limit] end ``` Before: ``` ruby # => [["int2", nil], ["int4", nil], ["int8", nil]] ``` After: ``` ruby # => [["int2", 2], ["int4", 4], ["int8", 8]] ```