aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters
Commit message (Collapse)AuthorAgeFilesLines
* Simplify and optimize Postgres query for primary_keys()Jordan Lewis2017-02-132-14/+0
| | | | | | | | | | | | 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 #26655 from kamipo/fix_remove_expression_indexRafael França2017-02-131-2/+5
|\ | | | | Fix `remove_index` to be able to remove expression indexes
| * Fix `remove_index` to be able to remove expression indexesRyuta Kamizono2016-12-251-2/+5
| | | | | | | | Fixes #26635, #26641.
* | The `default` arg of `index_name_exists?` makes to optionalRyuta Kamizono2017-02-131-7/+7
| | | | | | | | | | | | 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.
* | Schema dumping support for PostgreSQL oid typeRyuta Kamizono2017-02-121-1/+1
| | | | | | | | Closes #27980
* | Schema dumping support for PostgreSQL interval typeRyuta Kamizono2017-02-121-2/+2
| | | | | | | | Closes #27979
* | Add `Style/EmptyLinesAroundMethodBody` in `.rubocop.yml` and remove extra ↵Ryuta Kamizono2017-02-122-2/+0
| | | | | | | | empty lines
* | Refactor `ColumnDefinition` to contain `options` hashRyuta Kamizono2017-02-093-6/+6
| | | | | | | | | | | | 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.
* | Merge pull request #27389 from kamipo/fix_mysql_pk_dumping_correctlyJeremy Daer2017-02-063-173/+0
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | Restore the behaviour of the compatibility layer for integer-like PKs * kamipo/fix_mysql_pk_dumping_correctly: Restore custom primary key tests lost at #26266 Restore the behaviour of the compatibility layer for integer-like PKs Correctly dump integer-like primary key with default nil
| * | Restore the behaviour of the compatibility layer for integer-like PKsRyuta Kamizono2017-02-043-173/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Correct spellingBenjamin Fleischer2017-02-052-3/+3
|/ / | | | | | | | | | | | | ``` go get -u github.com/client9/misspell/cmd/misspell misspell -w -error -source=text . ```
* | Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+Ryuta Kamizono2017-02-012-8/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ Declare virtual columns with `t.virtual name, type: …, as: "expression"`. Pass `stored: true` to persist the generated value (false by default). Example: create_table :generated_columns do |t| t.string :name t.virtual :upper_name, type: :string, as: "UPPER(name)" t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true t.index :name_length # May be indexed, too! end Closes #22589
* | Add assertion messagesAkira Matsuda2017-01-252-2/+2
| | | | | | | | | | This message could be generated by `assert_predicate`, https://github.com/rails/rails/commit/1853a4f2c8b2bddfbde6aae80abb08310295201c#commitcomment-20546113 but I'd rather handwrite the message string if I could reduce magic from the code by doing so.
* | Deprecate `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-201-2/+2
| | | | | | | | | | | | `initialize_internal_metadata_table` These internal initialize methods are no longer used internally.
* | Revert "Merge pull request #27718 from kamipo/remove_internal_public_methods"Matthew Draper2017-01-201-2/+2
| | | | | | | | | | This reverts commit 39c77eb1843f79925c7195e8869afc7cb7323682, reversing changes made to 9f6f51be78f8807e18fc6562c57af2fdbf8ccb56.
* | assert_send is going to be deprecated since minitest 5.10.0Akira Matsuda2017-01-182-2/+2
| |
* | :warning: "Use assert_nil if expecting nil. This will fail in MT6."Akira Matsuda2017-01-181-3/+4
| | | | | | | | | | | | These are followups for 307065f959f2b34bdad16487bae906eb3bfeaf28, but TBH I'm personally not very much confortable with this style. Maybe we could override assert_equal in our test_helper not to warn?
* | Remove `initialize_schema_migrations_table` and ↵Ryuta Kamizono2017-01-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | `initialize_internal_metadata_table` internal public methods These internal methods accidentally appeared in the doc, and so almost useless. It is enough to create these internal tables directly, and indeed do so in several places. https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/schema.rb#L55 https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/railties/databases.rake#L6 https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/tasks/database_tasks.rb#L230
* | Merge pull request #27618 from kamipo/fix_uuid_default_nilKasper Timm Hansen2017-01-151-19/+36
|\ \ | | | | | | Fix UUID primary key with default nil in legacy migration
| * | Fix UUID primary key with default nil in legacy migrationRyuta Kamizono2017-01-091-0/+19
| | | | | | | | | | | | | | | | | | UUID primary key with no default value feature (#10404, #18206) was lost in legacy migration caused by #25395 got merged. Restore the feature again in legacy migration.
| * | Should test uuid legacy migration without `supports_pgcrypto_uuid?`Ryuta Kamizono2017-01-091-19/+17
| | |
* | | Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-2/+2
| | | | | | | | | | | | (I personally prefer writing one string in one line no matter how long it is, though)
* | | activerecord/test: Fix Mysql2ConnectionTest#test_execute_after_disconnectDylan Thacker-Smith2017-01-091-1/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Mysql2ConnectionTest#test_execute_after_disconnect was originally added to catch a NoMethodError occuring in execute when the Mysql2Adapter has a nil `@connection`. Pull request #26869 removed the error message check in that test because the error message changed in the mysql2 gem, which caused the test to fail. Now the test wouldn't catch the original bug since the NoMethodError would get turned into a ActiveRecord::StatementInvalid exception. Check the cause of the StatementInvalid exception to make sure it is of the correct type.
* | Revert "Merge pull request #21233 from ↵Rafael Mendonça França2017-01-031-107/+68
| | | | | | | | | | | | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges" This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing changes made to 5c40239d3104543e70508360d27584a3e4dc5baf. Reason: Broke the isolated tests. https://travis-ci.org/rails/rails/builds/188721346
* | Merge pull request #21233 from ↵Rafael França2017-01-031-68/+107
|\ \ | | | | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
| * | Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2016-12-031-68/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | privileges 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.
* | | Deprecate passing `name` to `indexes` like `tables`Ryuta Kamizono2017-01-042-2/+2
| | | | | | | | | | | | | | | Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
* | | Compare deserialized values for `PostgreSQL::OID::Hstore` typesJon Moss2017-01-031-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Per the regression commit below, the commit changes the behavior of `#changed?`to consult the `#changed_in_place?` method on `Type::Value` classes. Per this change, `PostgreSQL::OID::Hstore` needs to override this method in order to compare the deserialized forms of the two arguments. In Ruby, two hashes are considered equal even if their key order is different. This commit helps to bring that behavior to `Hstore` values. Fixes regression introduced by 8e633e505880755e7e366ccec2210bbe2b5436e7 Fixes #27502
* | | Consistently apply adapter behavior when serializing arraysSean Griffin2017-01-032-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In f1a0fa9 we moved backend specific timestamp behavior out of the type and into the adapter. This was in line with our general attempt to reduce the number of adapter specific type subclasses. However, on PG, the array type performs all serialization, including database encoding in its serialize method. This means that we have converted the value into a string before reaching the database, so no adapter specific logic can be applied (and this also means that timestamp arrays were using the default `.to_s` method on the given object, which likely meant timestamps were being ignored in certain cases as well) Ultimately I want to do a more in depth refactoring which separates database serializer objects from the active model type objects, to give us a less awkward API for introducing the attributes API onto Active Model. However, in the short term, we follow the solution we've applied elsewhere for this. Move behavior off of the type and into the adapter, and use a data object to allow the type to communicate information up the stack. Fixes #27514.
* | | Dump array subtype options correctlyRyuta Kamizono2017-01-011-3/+5
| | | | | | | | | | | | | | | Currently schema dumper does not dump array subtype `precision` and `scale` options. This commit fixes the issue.
* | | `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-292-8/+6
| | |
* | | Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-292-4/+2
| | |
* | | "Use assert_nil if expecting nil from ...:in `...'. This will fail in MT6."Akira Matsuda2016-12-254-10/+10
| |/ |/|
* | "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-255-6/+6
| |
* | Privatize unneededly protected methods in Active Record testsAkira Matsuda2016-12-244-4/+4
| |
* | Merge pull request #27329 from kamipo/simplify_unsigned_regexEileen M. Uchitelle2016-12-171-1/+1
|\ \ | | | | | | Simplify the regex for `unsigned?` method
| * | Simplify the regex for `unsigned?` methodRyuta Kamizono2016-12-111-1/+1
| | | | | | | | | | | | | | | It is enough to distinguish only the trailing `unsigned` and `unsigned zerofill`.
* | | fix new warning in ruby 2.4yuuji.yaginuma2016-12-141-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following warning. ``` test/caching_test.rb:986: warning: parentheses after method name is interpreted as test/caching_test.rb:986: warning: an argument list, not a decomposed argument test/cases/adapters/mysql2/reserved_word_test.rb:146: warning: parentheses after method name is interpreted as test/cases/adapters/mysql2/reserved_word_test.rb:146: warning: an argument list, not a decomposed argument ``` Ref: https://github.com/ruby/ruby/commit/65e27c8b138d6959608658ffce2fa761842b8d24
* | Translate numeric value out of range to the specific exceptionRyuta Kamizono2016-12-061-2/+2
| | | | | | | | Raise `ActiveRecord::RangeError` when values that executed are out of range.
* | Merge pull request #26687 from kamipo/fix_add_index_to_normalize_optionsMatthew Draper2016-12-062-0/+7
|\ \ | | | | | | Fix `add_index` to normalize column names and options
| * | Fix `add_index` to normalize column names and optionsRyuta Kamizono2016-10-032-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently does not work the following code. ```ruby add_index(:people, ["last_name", "first_name"], order: { last_name: :desc, first_name: :asc }) ``` Normalize column names and options to fix the issue.
* | | Make pg adapter use bigserial for pk by defaultPavel Pravosud2016-12-054-0/+186
| |/ |/|
* | Fix that unsigned with zerofill is treated as signedRyuta Kamizono2016-11-271-0/+1
| | | | | | | | Fixes #27125.
* | abort_on_exception can't be disabled for a single threadMatthew Draper2016-11-272-6/+8
| | | | | | | | | | If it's enabled globally, it's on regardless of how individual threads are set.
* | We expect exceptions; abort will just raise in the wrong placeMatthew Draper2016-11-272-9/+17
| |
* | Should test `test_change_column_default` in `PostgresqlUUIDTest`Ryuta Kamizono2016-11-251-13/+13
| | | | | | | | Follow up to #25395.
* | Merge pull request #27171 from kamipo/suppress_migration_messageMatthew Draper2016-11-251-0/+4
|\ \ | | | | | | Suppress migration message in the test
| * | Suppress migration message in the testRyuta Kamizono2016-11-251-0/+4
| | |
* | | Remove blank else blockRyuta Kamizono2016-11-251-1/+0
|/ /
* | For `PostgreSQL >= 9.4` use `gen_random_uuid()`Yaw Boakye2016-11-221-14/+59
| | | | | | | | | | | | | | | | | | | | Since 9.4, PostgreSQL recommends using `pgcrypto`'s `gen_random_uuid()` to generate version 4 UUIDs instead of the functions in the `uuid-ossp` extension. These changes uses the appropriate UUID function depending on the underlying PostgreSQL server's version, while maintaining `uuid_generate_v4()` in older migrations.