aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #30980 from sobrinho/sobrinho/arel-star-ignored-columnsRafael França2017-11-131-8/+8
|\ | | | | Do not use `Arel.star` when `ignored_columns`
| * Change tests to use models which don't ignore any columnsJon Moss2017-11-131-8/+8
| |
* | Add new error class `StatementTimeout` which will be raised when statement ↵Ryuta Kamizono2017-11-131-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | timeout exceeded (#31129) We are sometimes using The MAX_EXECUTION_TIME hint for MySQL depending on the situation. It will prevent catastrophic performance down by wrong performing queries. The new error class `StatementTimeout` will make to be easier to handle that case. https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html#optimizer-hints-execution-time
* | Raise `TransactionTimeout` when lock wait timeout exceeded for PG adapterRyuta Kamizono2017-11-111-0/+29
| | | | | | | | Follow up of #30360.
* | removed unnecessary semicolonsShuhei Kitagawa2017-10-281-1/+1
|/
* `supports_extensions?` return always true since PostgreSQL 9.1Yasuo Honda2017-10-244-454/+440
| | | | | | | | 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 deprecated argument `name` from `#indexes`Rafael Mendonça França2017-10-231-1/+1
|
* Fix longer sequence name detection for serial columns (#28339)Ryuta Kamizono2017-10-151-0/+32
| | | | | | | | 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.
* `Postgres::OID::Range` serializes to a `Range`, quote in `Quoting`Thomas Cannon2017-09-262-1/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix collided sequence name detectionRyuta Kamizono2017-09-181-0/+36
| | | | | | If collided named sequence already exists, newly created serial column will generate alternative sequence name. Fix sequence name detection to allow the alternative names.
* Add an extra assertion to ensure dumping schema default as expectedRyuta Kamizono2017-09-081-1/+4
|
* Fix `quote_default_expression` for UUID with array defaultRyuta Kamizono2017-09-081-0/+10
| | | | Fixes #30539.
* Prevent extra `SET time zone` in `configure_connection` (#28413)Ryuta Kamizono2017-08-211-0/+7
| | | | | | | | `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.
* Allow `serialize` with a custom coder on `json` and `array` columnsRyuta Kamizono2017-08-131-1/+25
| | | | | | | We already have a test case for `serialize` with a custom coder in `PostgresqlHstoreTest`. https://github.com/rails/rails/blob/v5.1.3/activerecord/test/cases/adapters/postgresql/hstore_test.rb#L316-L335
* Move `test_not_compatible_with_serialize_macro` to `JSONSharedTestCases`Ryuta Kamizono2017-08-111-11/+2
| | | | Because `JSONSharedTestCases` is also used for `Mysql2JSONTest`.
* Merge pull request #29520 from kirs/serialize-vs-postgres-native-columnSean Griffin2017-08-042-0/+18
|\ | | | | Do not let use `serialize` on native JSON/array column
| * Do not let use `serialize` on native JSON/array columnKir Shatrov2017-08-042-0/+18
| |
* | Merge remote-tracking branch 'origin/master' into unlock-minitestRafael Mendonça França2017-08-0142-20/+112
|\|
| * Merge pull request #29869 from kamipo/make_type_map_to_privateRafael França2017-07-212-7/+7
| |\ | | | | | | Make `type_map` to private because it is only used in the connection adapter
| | * Make `type_map` to private because it is only used in the connection adapterRyuta Kamizono2017-07-202-7/+7
| | | | | | | | | | | | | | | | | | | | | `type_map` is an internal API and it is only used in the connection adapter. And also, some type map initializer methods requires passed `type_map`, but those instances already has `type_map` in itself. So we don't need explicit passing `type_map` to the initializers.
| * | Merge pull request #29732 from kirs/frozen-activerecordRafael França2017-07-2142-0/+84
| |\ \ | | | | | | | | Use frozen-string-literal in ActiveRecord
| | * | Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-1942-0/+84
| | |/
| * / Revert "Extract `bind_param` and `bind_attribute` into `ActiveRecord::TestCase`"Sean Griffin2017-07-214-10/+18
| |/ | | | | | | | | | | | | | | This reverts commit b6ad4052d18e4b29b8a092526c2beef013e2bf4f. This is not something that the majority of Active Record should be testing or care about. We should look at having fewer places rely on these details, not make it easier to rely on them.
| * Merge pull request #29033 from kamipo/make_preload_query_to_prepared_statementsSean Griffin2017-07-181-1/+1
| |\ | | | | | | Make preload query to preparable
| | * Make preload query to preparableRyuta Kamizono2017-07-071-1/+1
| | | | | | | | | | | | | | | | | | | | | Currently preload query cannot be prepared statements even if `prepared_statements: true` due to array handler in predicate builder doesn't support making bind params. This makes preload query to preparable by don't passing array value if possible.
| * | Change sqlite3 boolean serialization to use 1 and 0Lisa Ugray2017-07-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Abstract boolean serialization has been using 't' and 'f', with MySQL overriding that to use 1 and 0. This has the advantage that SQLite natively recognizes 1 and 0 as true and false, but does not natively recognize 't' and 'f'. This change in serialization requires a migration of stored boolean data for SQLite databases, so it's implemented behind a configuration flag whose default false value is deprecated. The flag itself can be deprecated in a future version of Rails. While loaded models will give the correct result for boolean columns without migrating old data, where() clauses will interact incorrectly with old data. While working in this area, also change the abstract adapter to use `"TRUE"` and `"FALSE"` as quoted values and `true` and `false` for unquoted. These are supported by PostreSQL, and MySQL remains overriden.
* | | Merge branch 'master' into unlock-minitestKasper Timm Hansen2017-07-156-21/+28
|\| |
| * | Don't allow uuids with orphan curly bracespdebelak2017-07-071-1/+3
| |/ | | | | | | | | | | | | | | The uuid validation regex was allowing uuids to have a single leading curly brace or single trailing curly brace. Saving with such a uuid would cause Postgres to generate an exception even though the record seemed valid. With this change, the regex requires both a leading *and* a trailing curly brace or neither to be valid.
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0242-42/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-0242-0/+42
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-0142-0/+42
| | |
| * | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-022-6/+6
| |\ \ | | |/ | |/| | | | Make ActiveSupport frozen-string-literal friendly.
| | * Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-202-6/+6
| | |
| * | Use bulk INSERT to insert fixturesKir Shatrov2017-06-201-0/+6
| |/ | | | | | | | | | | | | | | Improves the performance from O(n) to O(1). Previously it would require 50 queries to insert 50 fixtures. Now it takes only one query. Disabled on sqlite which doesn't support multiple inserts.
| * Allow `uuid_test.rb` to be loaded on all adaptersEugene Kenny2017-06-141-1/+2
| | | | | | | | | | | | | | | | | | Running `bin/test` from the activerecord directory produces this error: test/cases/adapters/postgresql/uuid_test.rb:43:in `<class:PostgresqlUUIDTest>': undefined method `supports_pgcrypto_uuid?' for #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x007fc405e72a68> (NoMethodError) The test only actually runs on the PostgreSQL adapter; we can avoid triggering the error on other adapters with this `respond_to?` guard.
| * Merge pull request #28868 from yahonda/pg10_oid_unknown_to_textMatthew Draper2017-06-071-8/+8
| |\ | | | | | | PostgreSQL 10 converts unknown type to text type
| | * PostgreSQL 10 converts unknown OID 705 to text 25Yasuo Honda2017-06-061-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Rename test cases from `unknown` to `unrecognized` since unknown OID is one of possible unrecognized types by Rails - Use "select 'pg_catalog.pg_class'::regclass" whose OID is 2205, which will not be converted to recognized type in PostgreSQL 10. activerecord_unittest=# select oid, typname from pg_type where oid in (2205, 2277); oid | typname ------+---------- 2205 | regclass 2277 | anyarray (2 rows) Addresses #28868
| * | Remove redundant `assert_nothing_raised` before another assertionsRyuta Kamizono2017-06-061-2/+0
| |/ | | | | | | These `assert_nothing_raised` are covered by following assertions.
| * Remove assert_nothing_raised, as test is already testing the required concernsPrathamesh Sonpatki2017-06-031-3/+3
| |
* | Explicitly clear type map before run ↵yuuji.yaginuma2017-06-031-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `test_only_reload_type_map_once_for_every_unknown_type` Currently, the following test fails. ``` bin/test -a sqlite3_mem --seed 37473 test/cases/relation_test.rb ``` This is due to reset connection in `test_respond_to_for_non_selected_element` postprocessing. This reset is added with #29332 for `test_only_reload_type_map_once_for_every_unknown_type`. Since the above test expects the type map to be empty at the time of test run, I think that it is better to empty the type map before test run.
* | Merge branch 'master' into unlock-minitestRafael Mendonça França2017-06-022-18/+19
|\|
| * Consolidate database specific JSON types to `Type::Json`Ryuta Kamizono2017-05-301-18/+9
| |
| * Fix UUID column with `null: true` and `default: nil`Ryuta Kamizono2017-05-301-0/+10
| | | | | | | | | | | | | | `quote_default_expression` can be passed nil value when `null: true` and `default: nil`. This addressed in that case. Fixes #29222.
* | Make sure to disable extension after testyuuji.yaginuma2017-05-311-6/+2
|/ | | | | If keep the extension, can not test properly to make sure that extension can be enabled.
* Prevent extra `current_database` query for `encoding`/`collation`/`ctype`Ryuta Kamizono2017-05-281-3/+9
|
* Merge pull request #29176 from bogdanvlviv/define-path-with__dir__Matthew Draper2017-05-261-1/+1
|\ | | | | Define path with __dir__
| * Define path with __dir__bogdanvlviv2017-05-231-1/+1
| | | | | | | | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* | Remove a duplicate test of schema_authorization_test in ARKoichi ITO2017-05-251-11/+0
| |
* | Extract `JSONSharedTestCases`Ryuta Kamizono2017-05-221-180/+2
|/ | | | | Both `mysql2/json_test.rb` and `postgresql/json_test.rb` have same test cases.
* Should escape meta characters in regexpRyuta Kamizono2017-05-073-5/+5
|