aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #30439 from prathamesh-sonpatki/changelog-30360Ryuta Kamizono2017-08-291-0/+5
|\ | | | | Added CHANGELOG for #30360 [ci skip]
| * Added CHANGELOG for #30360 [ci skip]Prathamesh Sonpatki2017-08-281-0/+5
| |
* | 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
* | "models/reader" is no longer used in `autosave_association_test.rb`Ryuta Kamizono2017-08-281-1/+0
| |
* | Address `test_assign_ids_for_through_a_belongs_to` failureRyuta Kamizono2017-08-281-8/+8
| | | | | | | | | | | | | | | | If `:readers` fixture is loaded before the test, it will be failed. Use `firm.developer_ids` instead because we don't have `:contracts` fixture for now. https://travis-ci.org/rails/rails/jobs/268976230#L729
* | `@previous_reflection.options[:source_type]` in `PolymorphicReflection` is ↵Ryuta Kamizono2017-08-281-10/+2
| | | | | | | | | | | | | | always true Because `add_as_polymorphic_through` is only called when `options[:source_type]` is true.
* | Remove unused `RuntimeReflection#alias_candidate`Ryuta Kamizono2017-08-281-4/+0
| | | | | | | | `RuntimeReflection#alias_candidate` is no longer used since 0408e212.
* | Should be appear deprecation message for every call (#29649)Ryuta Kamizono2017-08-272-8/+1
| | | | | | Context: https://github.com/rails/rails/pull/29619#discussion_r125158589
* | Omit the default limit for float columns (#28041)Ryuta Kamizono2017-08-273-5/+10
| |
* | Prefer to place a table options before `force: :cascade` (#28005)Ryuta Kamizono2017-08-275-11/+10
|/ | | | | | I was added a table options after `force: :cascade` in #17569 for not touching existing tests (reducing diff). But `force: :cascade` is not an important information. So I prefer to place a table options before `force: :cascade`.
* Use tt in doc for ActiveRecord [ci skip]Yoshiyuki Hirano2017-08-276-20/+20
|
* Fix random CI failure due to non-deterministic sorting orderRyuta Kamizono2017-08-261-6/+6
| | | | https://travis-ci.org/rails/rails/jobs/268599781#L784
* Merge pull request #30403 from yhirano55/fix_broken_doc_for_active_recordRyuta Kamizono2017-08-267-7/+7
|\ | | | | Fix broken doc for Active Record [ci skip]
| * Fix broken doc for Active Record [ci skip]Yoshiyuki Hirano2017-08-257-7/+7
| |
* | Add :nodoc: for ActiveRecord::AttributeMethods [ci skip]Yoshiyuki Hirano2017-08-263-3/+3
| |
* | Should work inverse association when eager loadingRyuta Kamizono2017-08-254-15/+24
|/ | | | | | | This regression was caused by caa178c1. The block for `set_inverse_instance` should also be passed to join dependency. Fixes #30402.
* Address `test_after_save_callback_with_autosave` failureYasuo Honda2017-08-241-0/+4
| | | | | | | when other `AutomaticInverseFindingTests` load `:comments` fixture but does not load `:posts`. Refer #30385 for similar issue
* Remove unused returning value `stream`Ryuta Kamizono2017-08-241-2/+0
|
* Merge pull request #30337 from kamipo/refactor_schema_dumperRyuta Kamizono2017-08-2415-56/+54
|\ | | | | Refactor `SchemaDumper` to make it possible to adapter specific customization
| * Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-2213-38/+51
| | | | | | | | | | | | | | 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-225-19/+4
| |
* | Remove unnecessary fixture loadingRyuta Kamizono2017-08-241-5/+1
| |
* | Merge pull request #30365 from yahonda/require_post_before_commentRyuta Kamizono2017-08-231-0/+3
|\ \ | | | | | | `counter_cache` requires association class before `attr_readonly`
| * | `counter_cache` requires association class before `attr_readonly`Yasuo Honda2017-08-231-0/+3
| |/ | | | | | | | | There were similar pull requests #26370 #27575 fixed by different way by moving `require "models/post"` before `require "models/comment"`
* | Merge pull request #28991 from yahonda/load_authors_and_author_addressesRyuta Kamizono2017-08-234-4/+4
|\ \ | | | | | | Load :author_addresses fixture to keep data integrity with :authors
| * | Load both `:authors` and `:author_addresses` to keep data integrityYasuo Honda2017-08-224-4/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `:authors` has a foreign key to `:author_addresses`. If only `:authors` fixture loaded into the database which supports foreign key and checks the existing data when enabling foreien keys like Oracle, it raises the following error `ORA-02298: cannot validate (ARUNIT.FK_RAILS_94423A17A3) - parent keys not found` It is because there is no parent data exists in `author_addresses` table. Here are how other database with foreign key support works: - MySQL does not check the existing data when enabling foreign key by `foreign_key_checks=1` https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_foreign_key_checks > Setting foreign_key_checks to 1 does not trigger a scan of the existing table data. Therefore, rows added to the table while foreign_key_checks=0 will not be verified for consistency. - PostgreSQL database itself has a feature to check existing data when enabling foreign key and discussed at #27636, which is reverted.
* | Merge pull request #30360 from gcourtemanche/transaction_timedoutRafael França2017-08-223-0/+14
|\ \ | |/ |/| Add TransactionTimeout for MySQL error code 1205
| * Add TransactionTimeout for MySQL error code 1205Gabriel Courtemanche2017-08-223-0/+14
| |
* | Automatically guess the inverse associations for STIyui-knk2017-08-223-2/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord associations automatically guess the inverse associations. But this feature does not work correctly on assoctions for STI. For example, before this commit ``` class Post < ActiveRecord::Base belongs_to :author end class SpecialPost < Post; end class Author < ActiveRecord::Base has_many :posts has_many :special_posts end ``` `author.posts.first.author` works correctly, but `author.special_posts.first.author` does not work correctly.
* | Merge pull request #30354 from ↵Ryuta Kamizono2017-08-2212-13/+13
|\ \ | | | | | | | | | | | | yhirano55/use_https_instead_of_http_in_activerecord [activerecord] Update links to use https instead of http [ci skip]
| * | Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-2212-13/+13
| |/
* / Update MIT licenses link [ci skip]Yoshiyuki Hirano2017-08-221-2/+2
|/
* Prevent extra `SET time zone` in `configure_connection` (#28413)Ryuta Kamizono2017-08-212-6/+15
| | | | | | | | `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
|
* Prefer formatted number as schema version [ci skip]Ryuta Kamizono2017-08-211-1/+1
|
* 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]] ```
* Fix `can't modify frozen String` error in an AR testKoichi ITO2017-08-191-2/+2
|
* Improve `migration/column_attributes_test.rb` (#25286)Ryuta Kamizono2017-08-181-3/+17
| | | | | * Test `test_unabstracted_database_dependent_types` for `PostgreSQLAdapter` * Add `test_change_column_with_new_precision_and_scale` for `SQLite3Adapter` * This test case and comment was lost at 28bb02a78fd47527bb7a208d01a4594bb212812c
* Add deterministic sorting order for `test_taking_with_a_number`Ryuta Kamizono2017-08-181-1/+9
| | | | | | Otherwise random CI failure will be caused. https://travis-ci.org/rails/rails/jobs/265848046#L777
* Restore the ability that SQL with binds for `insert`, `update`, and `delete` ↵Ryuta Kamizono2017-08-182-6/+38
| | | | | | | | (#29944) Since 213796f, it was lost the ability that SQL with binds for `insert`, `update`, and `delete` (like `select_all`). This restores the ability because `insert`, `update`, and `delete` are public API, so it should not be removed without deprecation.
* Add test cases that class level `destroy`, `delete`, and `update` are ↵Ryuta Kamizono2017-08-181-3/+33
| | | | | | | affected by scoping (#29997) I tried to change the expectation in #29976, but it is expected behavior at least for now. So I added the test cases to prevent anyone change the expectation.
* Restore `to_sql` to return only SQL (#29945)Ryuta Kamizono2017-08-186-13/+15
| | | | Because `to_sql` is public API. I introduced `to_sql_and_binds` internal API to return SQL and binds.
* Add test cases for `where.not` with polymorphic associationRyuta Kamizono2017-08-181-0/+19
| | | | | | | | | | | `where.not` with multiple conditions is still unexpected behavior. But `where.not` with only polymorphic association has already been fixed in 213796fb. Closes #14161. Closes #16983. Closes #17010. Closes #26207.
* Move `test_index_is_created_for_both_timestamps` to ↵Yasuo Honda2017-08-171-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `TimestampsWithoutTransactionTest` This commit addresses these failures when the backend RDBMS executes implicit commit for DDL like MySQL and Oracle. ```ruby $ ARCONN=mysql2 bin/test test/cases/integration_test.rb test/cases/timestamp_test.rb --seed 58225 -n '/^(?:TimestampTest#(?:test_index_is_created_for_both_timestamps)|IntegrationTest#(?:test_cache_key_for_newer_updated_at|test_cache_key_format_for_existing_record_with_updated_at|test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format))$/' -v Using mysql2 Run options: --seed 58225 -n "/^(?:TimestampTest#(?:test_index_is_created_for_both_timestamps)|IntegrationTest#(?:test_cache_key_for_newer_updated_at|test_cache_key_format_for_existing_record_with_updated_at|test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format))$/" -v TimestampTest#test_index_is_created_for_both_timestamps = 0.19 s = . IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at = 0.05 s = F IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format = 0.02 s = F IntegrationTest#test_cache_key_for_newer_updated_at = 0.01 s = F Finished in 0.272880s, 14.6585 runs/s, 14.6585 assertions/s. 1) Failure: IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:111]: --- expected +++ actual @@ -1 +1 @@ -"developers/1-20170717135609430848" +"developers/1-20170817135609283207" 2) Failure: IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:116]: --- expected +++ actual @@ -1 +1 @@ -"cached_developers/1-20170717135609" +"cached_developers/1-20170817135609" 3) Failure: IntegrationTest#test_cache_key_for_newer_updated_at [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:147]: --- expected +++ actual @@ -1 +1 @@ -"developers/1-20170717145609430848" +"developers/1-20170817135609283207" 4 runs, 4 assertions, 3 failures, 0 errors, 0 skips $ ``` `ActiveRecord::TestCase::TimestampTest#test_index_is_created_for_both_timestamps` calls`ActiveRecord::TestCase::TimestampTest#setup` which updates `updated_at` column value. ```ruby @developer = Developer.first ... snip ... @developer.update_columns(updated_at: Time.now.prev_month) ``` This transaction expected to be rolled back, but if the backend RDBMS like MySQL perfomes implicit commit when DDL executed, this transacion is committed by `create table` statement inside `ActiveRecord::TestCase::TimestampTest#test_index_is_created_for_both_timestamps`. It causes these failures above which expect `update_at` column value are not changed(rollbacked).
* Merge pull request #30048 from yahonda/regexp_aware_schema_dumper_prefix_suffixRafael França2017-08-162-1/+28
|\ | | | | Allow `table_name_prefix` and `table_name_suffix` have `$`
| * Allow `table_name_prefix` and `table_name_suffix` have `$`Yasuo Honda2017-08-042-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL 5.7 and PostgreSQL 9.6 allow table identifiers have the dollar sign. * MySQL 5.7 https://dev.mysql.com/doc/refman/5.7/en/identifiers.html > Permitted characters in unquoted identifiers: > ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) * PostgreSQL 9.6 https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html > SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard. Address #30044 [Yasuo Honda & Ryuta Kamizono]
* | Add spaceJon Moss2017-08-161-1/+1
| | | | | | | | [ci skip]