aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/schema/schema.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix CI failure due to reference type mismatchRyuta Kamizono2017-08-141-10/+9
| | | | | | | | `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
* Specify `table.name` only when `scope.table` and `table` are different (#29058)Ryuta Kamizono2017-08-111-0/+1
| | | Fixes #29045.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Fix unscoping `default_scope` in STI associationsRyuta Kamizono2017-07-191-0/+1
| | | | | | | Since 5c71000, it has lost to be able to unscope `default_scope` in STI associations. This change will use `.empty_scope?` instead of `.values.empty?` to regard as an empty scope if only have `type_condition`.
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Fix `ids_reader` to respect case sensitive primary keyRyuta Kamizono2017-06-281-1/+1
| | | | | | | | | | | | ```ruby car = Car.create!(name: "Tofaş") # Before car.bulb_ids # => SELECT "bulbs".ID FROM "bulbs" WHERE "bulbs"."name" = $1 AND "bulbs"."car_id" = $2 [["name", "defaulty"], ["car_id", 3]] # After car.bulb_ids # => SELECT "bulbs"."ID" FROM "bulbs" WHERE "bulbs"."name" = $1 AND "bulbs"."car_id" = $2 [["name", "defaulty"], ["car_id", 3]] ```
* Ensure that using correct alias trackerRyuta Kamizono2017-06-251-1/+1
| | | | | | Covering #27994 in tests. Closes #27994.
* Fix ActiveRecord::Persistence#touch with lockingbogdanvlviv2017-06-211-0/+2
| | | | | | `ActiveRecord::Persistence#touch` does not work well when optimistic locking enabled and `locking_column`, without default value, is null in the database.
* Use nullable `id` column instead of a primary keyRyuta Kamizono2017-06-161-1/+2
| | | | | | | | | `id` column in `subscribers` was added as a primary key for ignorable in INSERT. But it caused `NotNullViolation` for oracle-enhanced adapter. https://github.com/rsim/oracle-enhanced/issues/1357 I changed the column to nullable to address the issue.
* Avoid overwriting the methods of `AttributeMethods::PrimaryKey`Ryuta Kamizono2017-06-071-6/+8
| | | | | | | | | Currently the methods of `AttributeMethods::PrimaryKey` are overwritten by `define_attribute_methods`. It will be broken if a table that customized primary key has non primary key id column. It should not be overwritten if a table has any primary key. Fixes #29350.
* Don't attempt to create a new record that was already created.Isaac Betesh2017-04-201-0/+7
| | | | Fixes #24032
* Omit redundant `using: :btree` for schema dumpingRyuta Kamizono2017-02-131-1/+1
|
* Fix inspection behavior when the :id column is not primary keynamusyaka2017-02-091-0/+4
|
* `primary_key` and `references` columns should be identical typeRyuta Kamizono2017-02-071-6/+6
| | | | | | | | Follow up to #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But legacy migration and sqlite3 adapter should keep its previous behavior.
* Chain scope constraints should respect own table aliasRyuta Kamizono2017-02-011-0/+9
| | | | Fixes #27666.
* Should work foreign key in test schema without `if supports_foreign_keys?` ↵Ryuta Kamizono2017-01-171-7/+5
| | | | | | | | | statement If an adapter does not support foreign key feature, should be noop. https://github.com/rails/rails/blob/v5.0.0.rc1/activerecord/test/cases/migration/foreign_key_test.rb#L288-L294 https://github.com/rails/rails/blob/v5.0.0.rc1/activerecord/test/cases/migration/references_foreign_key_test.rb#L208-L214
* Should not update children when the parent creation with no reasonRyuta Kamizono2016-12-291-0/+1
| | | | | | | | This issue was introduced with d849f42 to solve #19782. However, we can solve #19782 without causing the issue. It is enough to save only when necessary. Fixes #27338.
* fix #create_fixtures when equal table names in different databasesJulia Lopez2016-12-211-0/+2
|
* Make pg adapter use bigserial for pk by defaultPavel Pravosud2016-12-051-0/+3
|
* Change MySQL and Postgresql to use Bigint primary keysJon McCartie2016-12-051-3/+3
|
* Remove a confusing commentyui-knk2016-10-311-1/+0
| | | | | These comment sometimes explain a face which does not match the face.
* Fix the order of `create_table` to match a comment about `:inverse_of` optionsyui-knk2016-10-311-4/+4
| | | | | In ActiveRecord test :men, :faces, :interests and :zines tables are used for `:inverse_of` test cases, not `:wheels`.
* Fixed: Optimistic locking does not work well with null in the databasebogdanvlviv2016-10-211-0/+2
|
* Dump index options to pretty formatRyuta Kamizono2016-10-101-1/+1
| | | | | | | | | | ```ruby # Before t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree # After t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree ```
* Add tests for ActiveRecord::Enum#enum when suffix specifiedYosuke Kabuto2016-09-121-0/+1
| | | | Make name of attribute medium instead of normal
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-12/+12
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Correctly return `associated_table` when `associated_with?` is trueRyuta Kamizono2016-07-101-0/+5
| | | | | | | `AssociationQueryHandler` requires `association` initialized `TableMetadata` even if `table_name == arel_table.name`. Fixes #25689.
* Extract foreign key action from `information_schema`Ryuta Kamizono2016-06-071-7/+8
| | | | Fixes #25300.
* Add Expression Indexes and Operator Classes support for PostgreSQLRyuta Kamizono2016-04-241-0/+1
| | | | | | | | | | | | | | | | Example: create_table :users do |t| t.string :name t.index 'lower(name) varchar_pattern_ops' end Fixes #19090. Fixes #21765. Fixes #21819. Fixes #24359. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Fix undefined method `owners' for NullPreloader:ClassLadislav Smola2016-04-061-0/+6
| | | | | | | | | | | | | | * Fix undefined method `owners' for NullPreloader:Class Fixing undefined method `owners' for ActiveRecord::Associations::Preloader::NullPreloader:Class * Use Ruby 1.9 hash format Use Ruby 1.9 hash format #24192 [Rafael Mendonça França + Ladislav Smola]
* Remove `except` helper for test schemaRyuta Kamizono2016-03-301-7/+1
|
* Execute default_scope defined by abstract class within the scope of subclassMehmet Emin İNAÇ2016-03-081-0/+5
|
* eliminate warnings about multiple primary keys on habtm join tablesAaron Patterson2016-02-191-1/+1
| | | | | | | | habtm join tables commonly have two id columns and it's OK to make those two id columns a primary key. This commit eliminates the warnings for join tables that have this setup. ManageIQ/manageiq#6713
* Use `t.index` in `create_table` instead of `add_index` in test schemaRyuta Kamizono2016-01-311-6/+5
| | | | For reduce bootstrap queries in tests.
* Add missing source_type if provided on hmt which belongs to an sti recordVipul A M2016-01-241-0/+2
| | | | Fixes #23209
* Use the database type to deserialize enumSean Griffin2016-01-231-0/+1
| | | | | | | | | | | | This fixes incorrect assumptions made by e991c7b that we can assume the DB is already casting the value for us. The enum type needs additional information to perform casting, and needs a subtype. I've opted not to call `super` in `cast`, as we have a known set of types which we accept there, and the subtype likely doesn't accept them (symbol -> integer doesn't make sense) Close #23190
* Revert "Merge pull request #20835 from ↵Kasper Timm Hansen2016-01-141-1/+0
| | | | | | | | | | | | | glittershark/if-and-unless-in-secure-token" This reverts commit 224eddfc0eeff6555ae88691306e61c7a9e8b758, reversing changes made to 9d681fc74c6251d5f2b93fa9576c9b2113116680. When merging the pull request, I misunderstood `has_secure_token` as declaring a model has a token from birth and through the rest of its lifetime. Therefore, supporting conditional creation doesn't make sense. You should never mark a model as having a secure token if there's a time when it shouldn't have it on creation.
* Add conditional_token to users.Kasper Timm Hansen2016-01-091-0/+1
| | | | | | Fix the NoMethodErrors introduced in 224eddf, when adding conditional token creation. The model declarations but the column wasn't added to the schema.
* tests, pluralize singular table name.Yves Senn2015-12-021-1/+1
| | | | | | | | | | This solves the following error: ActiveRecord::StatementInvalid: Could not find table 'guitars' It seems that the table structure of the `Guitar` model has not been necessary until now. Due to the wrong table name the model was not correctly linked to the table.
* Except keys of `build_record`'s argument from `create_scope` in ↵yui-knk2015-11-161-1/+1
| | | | | | | | | | | | | | initialize_attributes If argument of `build_record` has key and value which is same as default value of database, we should also except the key from `create_scope` in `initialize_attributes`. Because at first `build_record` initialize record object with argument of `build_record`, then assign attributes derived from Association's scope. In this case `record.changed` does not include the key, which value is same as default value of database, so we should add the key to except list. Fix #21893.
* Merge pull request #18548 from ↵Sean Griffin2015-10-281-0/+8
|\ | | | | | | | | | | sebjacobs/support-bidirectional-destroy-dependencies Add support for bidirectional destroy dependencies
| * Add support for bidirectional destroy dependenciesSeb Jacobs2015-01-161-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit if you defined a bidirectional relationship between two models with destroy dependencies on both sides, a call to `destroy` would result in an infinite callback loop. Take the following relationship. class Content < ActiveRecord::Base has_one :content_position, dependent: :destroy end class ContentPosition < ActiveRecord::Base belongs_to :content, dependent: :destroy end Calling `Content#destroy` or `ContentPosition#destroy` would result in an infinite callback loop. This commit changes the behaviour of `ActiveRecord::Callbacks#destroy` so that it guards against subsequent callbacks. Thanks to @zetter for demonstrating the issue with failing tests[1]. [1] rails#13609
* | Merge pull request #19686 from tsun1215/index_errorsSean Griffin2015-10-261-0/+9
|\ \ | | | | | | | | | | | | | | | Errors can be indexed with nested attributes Close #8638
| * | Errors can be indexed with nested attributesMichael Probber2015-04-171-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `has_many` can now take `index_errors: true` as an option. When this is enabled, errors for nested models will be returned alongside an index, as opposed to just the nested model name. This option can also be enabled (or disabled) globally through `ActiveRecord::Base.index_nested_attribute_errors` E.X. ```ruby class Guitar < ActiveRecord::Base has_many :tuning_pegs accepts_nested_attributes_for :tuning_pegs end class TuningPeg < ActiveRecord::Base belongs_to :guitar validates_numericality_of :pitch end ``` - Old style - `guitar.errors["tuning_pegs.pitch"] = ["is not a number"]` - New style (if defined globally, or set in has_many_relationship) - `guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]` [Michael Probber, Terence Sun]
* | | Fix merge conflicts for #19938Sean Griffin2015-10-201-0/+6
|\ \ \ | | | | | | | | | | | | | | | | This is a separate commit, as it is not just a changelog conflict. Want to point out the changes in the code
| * | | Fix for activerecord join dependency instantiate bugMehmet Emin İNAÇ2015-05-041-0/+6
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | use only object_id instead parent class and parent id test cases assert_equal use table name in references fix minor problems
* | | Fix regression in inverse_of on through associationseileencodes2015-09-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `inverse_of` on through associations was accidently removed/caused to stop working in commit f8d2899 which was part of a refactoring on `ThroughReflection`. To fix we moved `inverse_of` and `check_validity_of_inverse!` to the `AbstractReflection` so it's available to the `ThroughReflection` without having to dup any methods. We then need to delegate `inverse_name` method in `ThroughReflection`. `inverse_name` can't be moved to `AbstractReflection` without moving methods that set the instance variable `@automatic_inverse_of`. This adds a test that ensures that `inverse_of` on a `ThroughReflection` returns the correct class name, and the correct record for the inverse relationship. Fixes #21692
* | | Implement ActiveRecord::Base.ignored_columnsJean Boussier2015-09-241-0/+1
| | |