aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
...
* 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]
* | Merge pull request #30210 from koic/fix_rubocop_offensesMatthew Draper2017-08-162-6/+7
|\ \ | | | | | | Fix RuboCop offenses
| * | Fix RuboCop offensesKoichi ITO2017-08-162-6/+7
| | | | | | | | | | | | And enable `context_dependent` of Style/BracesAroundHashParameters cop.
* | | Fix test "_before_type_cast" for enum (#29004)Ryuta Kamizono2017-08-161-6/+8
|/ / | | | | Since c51f9b61 changed the "_before_type_cast" expectation for enum.
* | Merge pull request #30271 from ↵Rafael França2017-08-155-19/+33
|\ \ | | | | | | | | | | | | kamipo/through_scope_should_not_be_affected_by_scoping Through scope should not be affected by scoping
| * | Through scope should not be affected by scopingRyuta Kamizono2017-08-155-19/+33
| | | | | | | | | | | | | | | | | | Follow up of #29834. Fixes #30266.
* | | Don't expose `write_attribute_without_type_cast`Ryuta Kamizono2017-08-161-6/+5
|/ / | | | | | | | | | | `write_attribute_without_type_cast` is defined as a private method in `AttributeMethods::Write`, but `AttributeMethods::Dirty` overrode it as a public method. It should be kept the original visibility.
* | Formatting CHANGELOGs [ci skip]Ryuta Kamizono2017-08-151-2/+2
| | | | | | | | | | | | Add missing backticks Add missing * Add missing .
* | Merge pull request #30169 from awortham/awortham/awortham/fix-sql-distinct-bugRafael Mendonça França2017-08-143-0/+35
|\ \ | | | | | | | | | Ensure sum honors distinct on has_many through
| * | Ensure sum honors distinct on has_many throughAaron Wortham2017-08-143-0/+35
| | | | | | | | | | | | | | | | | | When using a has_many through relation and then summing an attribute the distinct was not being used. This will ensure that when summing an attribute, the number is only used once when distinct has been used.
* | | Merge pull request #30215 from untidy-hair/clarify-abstract-or-not-in-testsRafael França2017-08-143-8/+18
|\ \ \ | | | | | | | | Clarify base_class tests on abstract STI vs concrete STI
| * | | Clarify base_class tests on abstract STI vs concrete STIYukio Mizuta2017-08-123-8/+18
| | | |
* | | | Merge pull request #30073 from yalab/fixture_binary_helperRafael França2017-08-144-1/+14
|\ \ \ \ | | | | | | | | | | Add `binary` helper method to fixtures.
| * | | | Add `binary` helper method to fixtures.yalab2017-08-124-1/+14
| | | | |
* | | | | Merge pull request #30208 from kamipo/extract_primary_key_to_abstract_reflectionRafael França2017-08-141-8/+4
|\ \ \ \ \ | | | | | | | | | | | | Extract `primary_key` to `AbstractReflection`
| * | | | | Extract `primary_key` to `AbstractReflection`Ryuta Kamizono2017-08-121-8/+4
| | |/ / / | |/| | |
* | | | | Merge pull request #27609 from kamipo/fix_association_primary_keyRafael França2017-08-144-21/+25
|\ \ \ \ \ | | | | | | | | | | | | Fix `reflection.association_primary_key` for `has_many` association
| * | | | | Fix `reflection.association_primary_key` for `has_many` associationsRyuta Kamizono2017-08-134-21/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is incorrect to treat `options[:primary_key]` as `association_primary_key` if `has_many` associations because the `:primary_key` means the column on the owner record, not on the association record. It will break `ids_reader` and `ids_writer`. ```ruby people(:david).essay_ids # => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David' ``` Fixes #14439.
* | | | | | Merge pull request #30229 from kamipo/allow_serialize_with_custom_coderRafael França2017-08-143-9/+54
|\ \ \ \ \ \ | | | | | | | | | | | | | | Allow `serialize` with a custom coder on `json` and `array` columns
| * | | | | | Allow `serialize` with a custom coder on `json` and `array` columnsRyuta Kamizono2017-08-133-9/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | | | Merge pull request #30214 from kirs/uniqueness-scope-validatorRafael França2017-08-142-0/+11
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Check :scope input in Uniqueness validator
| * | | | | | | Check :scope input in Uniqueness validatorKir Shatrov2017-08-132-0/+11
| | |_|/ / / / | |/| | | | |
* | | | | | | Merge pull request #30236 from padi/find-each-example-updateRafael França2017-08-141-1/+6
|\ \ \ \ \ \ \ | |_|_|_|_|/ / |/| | | | | | Completes ActiveRecord::Batches.find_each example [ci skip]
| * | | | | | Completes ActiveRecord::Batches.find_each example [ci skip]Marc Rendl Ignacio2017-08-131-1/+6
| | |_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | The previous paragraph mentions that you can hand off the same processing queue to multiple workers. This completes the following example below it.
* | | | | | Merge pull request #30231 from kamipo/remove_unused_source_type_infoRafael França2017-08-141-10/+7
|\ \ \ \ \ \ | | | | | | | | | | | | | | Remove unused `source_type_info` in `RuntimeReflection`
| * | | | | | Remove unused `source_type_info` in `RuntimeReflection`Ryuta Kamizono2017-08-131-10/+7
| | |_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | `source_type_info` is only used for `constraints` in `PolymorphicReflection`.
* | | | | | Merge pull request #30233 from kamipo/remove_duplicated_join_id_forRafael França2017-08-141-10/+2
|\ \ \ \ \ \ | | | | | | | | | | | | | | Remove duplicated `join_id_for`
| * | | | | | Remove duplicated `join_id_for`Ryuta Kamizono2017-08-131-10/+2
| |/ / / / / | | | | | | | | | | | | | | | | | | The primary key on the owner record is abstracted as `join_foreign_key`.
* | | | | | Merge pull request #30206 from yukihirop/improve_activerecord_rdocKasper Timm Hansen2017-08-141-0/+4
|\ \ \ \ \ \ | | | | | | | | | | | | | | Add document that you rake test single file by using DB(ex. postgresql)
| * | | | | | Add document that you rake test single file by using DB(ex. postgresql) [ci ↵yukihirop2017-08-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | skip]
* | | | | | | Fix CI failure due to reference type mismatchRyuta Kamizono2017-08-142-12/+18
| |/ / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Firm.id` is a bigint if mysql2 adapter is used, but `firm_id` is an integer. It will cause an out of range error. https://travis-ci.org/rails/rails/jobs/264112814#L776 https://travis-ci.org/rails/rails/jobs/264112835#L919
* | | | | | Merge pull request #30228 from kamipo/fix_random_ci_failureMatthew Draper2017-08-131-2/+4
|\ \ \ \ \ \ | | | | | | | | | | | | | | Fix random CI failure due to non-deterministic sorting order
| * | | | | | Fix random CI failure due to non-deterministic sorting orderRyuta Kamizono2017-08-131-2/+4
| | |/ / / / | |/| | | | | | | | | | | | | | | | https://travis-ci.org/rails/rails/jobs/263617099#L769-L775
* | | | | | Merge pull request #30079 from ↵Matthew Draper2017-08-132-11/+11
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | kamipo/move_test_not_compatible_with_serialize_macro Move `test_not_compatible_with_serialize_macro` to `JSONSharedTestCases`
| * | | | | | Move `test_not_compatible_with_serialize_macro` to `JSONSharedTestCases`Ryuta Kamizono2017-08-112-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Because `JSONSharedTestCases` is also used for `Mysql2JSONTest`.
* | | | | | | Delegate to `Enumerable#find` for `CollectionProxy`Ryuta Kamizono2017-08-132-17/+14
| |/ / / / / |/| | | | | | | | | | | | | | | | | | | | | | | Since `Relation` includes `Enumerable`, it is enough to use `super` simply.
* | | | | | Remove duplicated `table_name`Ryuta Kamizono2017-08-121-8/+0
| |_|/ / / |/| | | | | | | | | | | | | | It can use `AbstractReflection#table_name` simply.
* | | | | Fix outdated comment for `Core::ClassMethods#===` [ci skip] (#30146)Ryuta Kamizono2017-08-121-2/+2
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This comment was added at 97849de, but `AssociationProxy` and `test_triple_equality` was removed at 1644663. Currently the `===` is used for `test_decorated_polymorphic_where` that added at #11945. So I updated "association proxies" to "decorated models". And also, currently `Core::ClassMethods` appears in the doc. http://api.rubyonrails.org/classes/ActiveRecord/Core/ClassMethods.html But it looks like that the methods in the module is not public API. So I also added `# :nodoc:` to the module.
* | | | Merge pull request #30126 from ↵Rafael França2017-08-114-12/+26
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | chopraanmol1/support_for_has_many_and_has_one_for_where_relation Fixed query building when relation is passed for has one or has many association in where