aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql
Commit message (Collapse)AuthorAgeFilesLines
* Remove database specific JSON typesRyuta Kamizono2017-07-052-11/+0
| | | | We already have database agnostic `Type::Json` since #29220.
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-022-25/+23
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0234-34/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-0234-0/+34
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-0134-0/+34
| | |
| * | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-021-3/+3
| |\ \ | | | | | | | | | | | | Make ActiveSupport frozen-string-literal friendly.
| | * | Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-201-3/+3
| | | |
| * | | Don't cache queries for schema statementsRyuta Kamizono2017-06-302-22/+20
| | |/ | |/| | | | | | | | | | | | | `test_middleware_caches` is sometimes failed since #29454. The failure is due to schema statements are affected by query caching. Bypassing query caching for schema statements to avoid the issue.
* / | [Active Record] require => require_relativeAkira Matsuda2017-07-011-22/+22
|/ /
* | Use `quote` method rather than single quotes to identifiers in SQLRyuta Kamizono2017-06-292-6/+10
| | | | | | | | | | | | Because identifiers in SQL could include a single quote. Related #24950, #26784.
* | Ensure query caching for `select_*` methods in connection adaptersRyuta Kamizono2017-06-151-32/+0
|/
* Merge pull request #29220 from kamipo/consolidate_database_specific_json_typesMatthew Draper2017-06-012-2/+2
|\ | | | | Consolidate database specific JSON types to `Type::Json`
| * Consolidate database specific JSON types to `Type::Json`Ryuta Kamizono2017-05-302-2/+2
| |
* | Support PostgreSQL 10 `pg_sequence`Yasuo Honda2017-05-301-1/+9
|/ | | | | | | | | | | | | | Another fix for #28780 based on discussions at #28789 - In PostgreSQL 10 each sequence does not know its `min_value`. A new system catalog `pg_sequence` shows it as `seqmin`. Refer https://github.com/postgres/postgres/commit/1753b1b027035029c2a2a1649065762fafbf63f3 - `setval` 3rd argument needs to set to `false` only when the table has no rows to avoid `nextval(<sequence_name>)` returns `2` where `1` is expected. - `min_value` is only necessary when the table has no rows. It used to be necessary since the 3rd argument of `setval` is always `false`.
* Merge pull request #29273 from ↵Rafael França2017-05-291-10/+0
|\ | | | | | | | | kamipo/deserialize_raw_value_from_database_for_json Deserialize a raw value from the database in `changed_in_place?` for `AbstractJson`
| * Deserialize a raw value from the database in `changed_in_place?` for ↵Ryuta Kamizono2017-05-301-10/+0
| | | | | | | | | | | | | | | | `AbstractJson` Structured type values sometimes caused representation problems (keys sort order, spaces, etc). A raw value from the database should be deserialized (normalized) to prevent the problems.
* | Fix UUID column with `null: true` and `default: nil`Ryuta Kamizono2017-05-301-1/+1
|/ | | | | | | `quote_default_expression` can be passed nil value when `null: true` and `default: nil`. This addressed in that case. Fixes #29222.
* `rename_table` renames primary key index nameYaw Boakye2017-05-291-4/+5
| | | | | | | | | | Formerly, `rename_table` only renamed primary key index name if the column's data type was sequential (serial, etc in PostgreSQL). The problem with that is tables whose primary keys had other data types (e.g. UUID) maintained the old primary key name. So for example, if the `cats` table has a UUID primary key, and the table is renamed to `felines`, the primary key index will still be called `cats_pkey` instead of `felines_pkey`. This PR corrects it.
* Prevent extra `current_database` query for `encoding`/`collation`/`ctype`Ryuta Kamizono2017-05-281-3/+3
|
* Revert "Merge pull request #27636 from ↵Rafael Mendonça França2017-04-261-43/+4
| | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privilege-take-2" This reverts commit c1faca6333abe4b938b98fedc8d1f47b88209ecf, reversing changes made to 8c658a0ecc7f2b5fc015d424baf9edf6f3eb2b0b. See https://github.com/rails/rails/pull/27636#issuecomment-297534129
* Refactor `indexes` things in connection adaptersRyuta Kamizono2017-04-161-2/+11
| | | | | | | * Use keyword arguments in `IndexDefinition` to ease to ignore unused options and to avoid to initialize incorrect empty value. * Place it in `SchemaStatements` for consistency. * And tiny tweaks.
* Use a query that's compatible with PostgreSQL 9.2Matthew Draper2017-04-121-7/+11
| | | | | | Also, explicitly apply the order: generate_subscripts is unlikely to start returning values out of order, but we should still be clear about what we want.
* Merge pull request #28478 from kamipo/fix_primary_keys_across_multiple_schemasAndrew White2017-03-291-9/+7
|\ | | | | Fix `primary_keys` across multiple schemas
| * Fix `primary_keys` across multiple schemasRyuta Kamizono2017-03-201-9/+7
| | | | | | | | Fixes #28470.
* | Merge pull request #28052 from kamipo/make_internal_methods_to_privateRafael França2017-03-282-39/+49
|\ \ | | | | | | Make internal methods to private
| * | Make internal methods to privateRyuta Kamizono2017-03-272-39/+49
| | |
* | | Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2017-03-261-4/+43
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | privileges (take 2) Re-create https://github.com/rails/rails/pull/21233 eeac6151a5 was reverted (127509c071b4) because it breaks tests. ---------------- ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* / [PostgreSQL]: Replace deprecated PG constants.Lars Kanis2017-03-223-6/+6
|/ | | | | The old top level classes PGconn, PGresult and PGError were deprecated since pg-0.13.0: https://github.com/ged/ruby-pg/blob/master/History.rdoc#v0130-2012-02-09-michael-granger-gedfaeriemudorg
* Merge pull request #28068 from kamipo/refactor_data_sourcesRafael França2017-03-131-91/+55
|\ | | | | Extract `data_source_sql` to refactor data source statements
| * Prefer `USING (column_list)` for joining information_schemaRyuta Kamizono2017-02-251-3/+1
| |
| * Extract `data_source_sql` to refactor data source statementsRyuta Kamizono2017-02-201-88/+54
| |
* | Merge pull request #28017 from mtsmfm/suppress-dep-warnMatthew Draper2017-03-131-0/+2
|\ \ | | | | | | Suppress deprecation warning `implementing to_yaml is deprecated`
| * | Suppress deprecation warning `implementing to_yaml is deprecated`Fumiaki MATSUSHIMA2017-02-151-0/+2
| |/
* | Fix `deserialize` with JSON arrayRyuta Kamizono2017-03-061-1/+1
| | | | | | | | Fixes #28285.
* | Use `max_identifier_length` for `index_name_length` in PostgreSQL adapterRyuta Kamizono2017-02-271-4/+0
| | | | | | | | | | Actually `index_name_length` depend on `max_identifier_length`, not always 63.
* | Fix `change_column` to drop default with `null: false`Ryuta Kamizono2017-02-261-1/+1
|/ | | | | | | | | | | | | | | | Currently `change_column` cannot drop default if `null: false` is specified at the same time. This change fixes the issue. ```ruby # cannot drop default change_column "tests", "contributor", :boolean, default: nil, null: false # we need the following workaround currently change_column "tests", "contributor", :boolean, null: false change_column "tests", "contributor", :boolean, default: nil ``` Closes #26582
* Should keep the primary key column orderRyuta Kamizono2017-02-141-0/+1
| | | | | | Fixes CI failure caused by #27961. https://travis-ci.org/rails/rails/jobs/201472146#L2390-L2409
* Simplify and optimize Postgres query for primary_keys()Jordan Lewis2017-02-131-10/+10
| | | | | | | | | | | | primary_keys(table) needs to query various metadata tables in Postgres to determine the primary key for the table. Previously, it did so using a complex common table expression against pg_constraint and pg_attribute. This patch simplifies the query by using information_schema tables. This simplifies the logic, making the query far easier to understand, and additionally avoids an expensive unnest, window function query, and common table expression.
* Merge pull request #26930 from kamipo/index_name_exists_defaultRafael França2017-02-131-1/+6
|\ | | | | The `default` arg of `index_name_exists?` makes to optional
| * Deprecate passing `default` to `index_name_exists?`Ryuta Kamizono2017-02-131-0/+5
| |
| * The `default` arg of `index_name_exists?` makes to optionalRyuta Kamizono2017-02-131-1/+1
| | | | | | | | | | | | The `default` arg of `index_name_exists?` is only used the adapter does not implemented `indexes`. But currently all adapters implemented `indexes` (See #26688). Therefore the `default` arg is never used.
* | Merge pull request #26630 from kamipo/quoted_binaryRafael França2017-02-131-2/+4
|\ \ | |/ |/| Extract `quoted_binary` and use it rather than override `_quote`
| * Extract `quoted_binary` and use it rather than override `_quote`Ryuta Kamizono2016-09-271-2/+4
| | | | | | | | | | | | | | Each databases have different binary representation. Therefore all adapters overrides `_quote` for quoting binary. Extract `quoted_binary` for quoting binary and use it rather than override `_quote`.
* | Schema dumping support for PostgreSQL oid typeRyuta Kamizono2017-02-123-0/+18
| | | | | | | | Closes #27980
* | Schema dumping support for PostgreSQL interval typeRyuta Kamizono2017-02-122-1/+6
| | | | | | | | Closes #27979
* | Revert "Simplify and speed up Postgres query for primary_keys"Ryuta Kamizono2017-02-101-8/+10
| | | | | | | | This reverts commit d6529af2954a67bd57fda45286fa9cfd0ff6b5ac.
* | Simplify and speed up Postgres query for primary_keysJordan Lewis2017-02-091-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | primary_keys(table) needs to query various metadata tables in Postgres to determine the primary key for the table. Previously, it did so using a complex common table expression against pg_constraint and pg_attribute. This patch simplifies the query by joining pg_index against pg_attribute instead of going through pg_constraint. This avoids an expensive unnest, window function query, and common table expression. EXPLAINing these queries in Postgres against a database with a single table with a composite primary key shows a 66% reduction in the plan and execute latencies. This is significant during application startup time, especially against very large schemas, where these queries would be even slower and more numerous. Closes #27949
* | Refactor `ColumnDefinition` to contain `options` hashRyuta Kamizono2017-02-093-36/+19
| | | | | | | | | | | | Column options are passed as an hash args then used as `options` hash in `add_column_options!`. Converting args to attributes is inconvinient for using options as an hash.
* | Restore the behaviour of the compatibility layer for integer-like PKsRyuta Kamizono2017-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The PR #27384 changed migration compatibility behaviour. ```ruby class CreateMasterData < ActiveRecord::Migration[5.0] def change create_table :master_data, id: :integer do |t| t.string :name end end end ``` Previously this migration created non-autoincremental primary key expected. But after the PR, the primary key changed to autoincremental, it is unexpected. This change restores the behaviour of the compatibility layer.
* | Correctly dump integer-like primary key with default nilRyuta Kamizono2017-02-041-9/+5
| | | | | | | | | | | | | | The PR #27384 changed integer-like primary key to be autoincrement unless an explicit default. This means that integer-like primary key is restored as autoincrement unless dumping the default nil explicitly. We should dump integer-like primary key with default nil correctly.