aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/schema
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #19683 from tristang/require-option-for-counter-cacheRafael Mendonça França2015-08-131-0/+2
|\ | | | | | | Require explicit counter_cache option for has_many
| * Add tests for associations without counter_cacheTristan Gamilis2015-04-091-0/+2
| | | | | | | | | | Assert that counter_cache behaviour is not used on belongs_to or has_many associations if the option is not given explicitly.
* | Skip statement cache on through association readerRafael Mendonça França2015-08-121-0/+12
| | | | | | | | | | | | | | If the through class has default scopes we should skip the statement cache. Closes #20745.
* | use correct DB connection for generated HABTM tableMatt Hanlon2015-08-071-0/+9
| |
* | Fix counter_cache for polymorphic associationsStefan Kanev2015-07-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Also removes a false positive test that depends on the fixed bug: At this time, counter_cache does not work with polymorphic relationships (which is a bug). The test was added to make sure that no StaleObjectError is raised when the car is destroyed. No such error is currently raised because the lock version is not incremented by appending a wheel to the car. Furthermore, `assert_difference` succeeds because `car.wheels.count` does not check the counter cache, but the collection size. The test will fail if it is replaced with `car.wheels_count || 0`.
* | Ensure cyclic associations w/ autosave don't cause duplicate errorsSean Griffin2015-07-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This code is so fucked. Things that cause this bug not to replicate: - Defining the validation before the association (we end up calling `uniq!` on the errors in the autosave validation) - Adding `accepts_nested_attributes_for` (I have no clue why. The only thing it does that should affect this is adds `autosave: true` to the inverse reflection, and doing that manually doesn't fix this). This solution is a hack, and I'm almost certain there's a better way to go about it, but this shouldn't cause a huge hit on validation times, and is the simplest way to get it done. Fixes #20874.
* | Add pending test for the great-grandparent touching bug from #19324David Heinemeier Hansson2015-06-251-0/+11
| |
* | Add enum prefix/suffix option to enum definitionIgor Kapkov2015-06-121-0/+4
| | | | | | | | Fixes #17511 and #17415
* | Correctly handle array columns with defaults in the schema dumperSean Griffin2015-06-111-0/+1
| | | | | | | | | | | | | | | | | | If the subtype provides custom schema dumping behavior, we need to defer to it. We purposely choose not to handle any values other than an array (which technically should only ever be `nil`, but I'd rather code defensively here). Fixes #20515.
* | Fix crash when loading fixture with belongs_to association defined in ↵Victor Costan2015-06-041-0/+5
| | | | | | | | abstract base class.
* | Move PostgreSQL specific schema to postgresql_specific_schema.rbRyuta Kamizono2015-05-032-14/+11
| |
* | Merge pull request #17574 from kamipo/charset_collation_optionsJeremy Kemper2015-04-072-18/+10
|\ \ | |/ |/| | | Add charset and collation options support for MySQL string and text columns.
| * Add `:charset` and `:collation` options support for MySQL string and text ↵Ryuta Kamizono2015-03-062-18/+10
| | | | | | | | | | | | | | | | | | | | | | columns Example: create_table :foos do |t| t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin' t.text :text_ascii, charset: 'ascii' end
* | Delegate limit to subtypewallerjake2015-03-211-0/+4
| | | | | | | | | | | | | | | | | | | | As described here https://github.com/rails/rails/issues/19420. When using the Postgres BigInt[] field type the big int value was not being translated into schema.rb. This caused the field to become just a regular integer field when building off of schema.rb. This fix will address this by delegating the limit from the subtype to the Array type. https://github.com/rails/rails/issues/19420
* | Fix leaky chain on polymorphic associationeileencodes2015-03-151-0/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there was a polymorphic hm:t association with a scope AND second non-scoped hm:t association on a model the polymorphic scope would leak through into the call for the non-polymorhic hm:t association. This would only break if `hotel.drink_designers` was called before `hotel.recipes`. If `hotel.recipes` was called first there would be no problem with the SQL. Before (employable_type should not be here): ``` SELECT COUNT(*) FROM "drink_designers" INNER JOIN "chefs" ON "drink_designers"."id" = "chefs"."employable_id" INNER JOIN "departments" ON "chefs"."department_id" = "departments"."id" WHERE "departments"."hotel_id" = ? AND "chefs"."employable_type" = ? [["hotel_id", 1], ["employable_type", "DrinkDesigner"]] ``` After: ``` SELECT COUNT(*) FROM "recipes" INNER JOIN "chefs" ON "recipes"."chef_id" = "chefs"."id" INNER JOIN "departments" ON "chefs"."department_id" = "departments"."id" WHERE "departments"."hotel_id" = ? [["hotel_id", 1]] ``` From the SQL you can see that `employable_type` was leaking through when calling recipes. The solution is to dup the chain of the polymorphic association so it doesn't get cached. Additionally, this follows `scope_chain` which dup's the `source_reflection`'s `scope_chain`. This required another model/table/relationship because the leak only happens on a hm:t polymorphic that's called before another hm:t on the same model. I am specifically testing the SQL here instead of the number of records becasue the test could pass if there was 1 drink designer recipe for the drink designer chef even though the `employable_type` was leaking through. This needs to specifically check that `employable_type` is not in the SQL statement.
* tests, favor `drop_table` and `:if_exists` over raw SQL.Yves Senn2015-03-022-12/+4
| | | | | We've replaced most querues using DROP TABLE in our tests already. This patch replaces the last couple calls.
* Merge pull request #17297 from ↵Rafael Mendonça França2015-02-251-0/+1
|\ | | | | | | | | rebyn/fix/17161-remove-objs-from-has_many-updates-fields Add specs for adding-to/clear has_many collections’s behavior on `updated_at`
| * Add specs for adding-to/clear has_many collections’s behavior on `updated_at`Tu Hoang2014-10-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | There are behaviors mentioned in #17161 that: 1. are not documented properly, and 2. don't have specs This commit addresses the spec absence. For has_many collections, 1. addition (<<) should update the associated object's updated_at (if any) 2. .clear, depending on options[:dependent], calls delete_all, destroy_all, or nullifies the associated object(s)' foreign key.
* | Remove unused tableRyuta Kamizono2015-02-251-10/+0
| | | | | | | | `postgresql_xml_data_type` table is used from nowhere.
* | Add `ActiveRecord::Base.suppress`Michael Ryan2015-02-181-0/+4
| |
* | Prefer `drop_table if_exists: true` over raw SQLRyuta Kamizono2015-02-181-1/+1
| | | | | | | | | | Lowercase raw SQL has been replaced by 07b659c already. This commit replaces everything else of raw SQL.
* | Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | | | | | onwards.
* | Merge pull request #18512 from vipulnsward/18492-fixtures-with-stiAaron Patterson2015-01-311-1/+11
|\ \ | | | | | | Fix STI for fixtures from multi-files
| * | Fixes #18492Vipul A M2015-01-141-1/+11
| | | | | | | | | | | | | | | | | | | | | - Add check for not deleting previously created fixtures, to overcome sti fixtures from multiple files - Added fixtures and fixtures test to verify the same - Fixed wrong fixtures duplicating data insertion in same table
* | | Don't redefine autosave association callbacks in nested attrsSean Griffin2015-01-281-0/+1
|/ / | | | | | | | | | | | | | | These callbacks will already have been defined when the association was built. The check against `reflection.autosave` happens at call time, not at define time, so simply modifying the reflection is sufficient. Fixes #18704
* | Add firebird support to test suiteRay Zane2015-01-051-0/+2
| |
* | Add has_secure_token to Active Recordrobertomiranda2015-01-041-0/+5
| | | | | | | | | | | | Update SecureToken Docs Add Changelog entry for has_secure_token [ci skip]
* | Allow precision option for MySQL datetimes.Ryuta Kamizono2015-01-021-1/+1
| |
* | Add foreign_type option for polymorphic has_one and has_many.Ulisses Almeida + Kassio Borges2014-12-081-0/+5
| | | | | | | | | | | | | | To be possible to use a custom column name to save/read the polymorphic associated type in a has_many or has_one polymorphic association, now users can use the option :foreign_type to inform in what column the associated object type will be saved.
* | pg tests, get rid of global schema `schema_1`.Yves Senn2014-12-021-7/+0
| |
* | pg tests, move uniqueness validation test to array tests.Yves Senn2014-12-021-10/+1
| |
* | tests, extract pg number tests into separate file.Yves Senn2014-12-021-9/+1
| |
* | tests, move schema shorthand assertions into pg specific tests.Yves Senn2014-12-021-55/+3
| |
* | tests, move pg geometric tests out of `base_test`.Yves Senn2014-12-021-13/+0
| |
* | tests, favor public API over inspecting columns where possible.Yves Senn2014-12-012-7/+1
| | | | | | | | | | This is a follow up to https://github.com/rails/rails/commit/07786c5e75a7b0afdf318063510af6b475e3e04c and https://github.com/rails/rails/commit/cd2596f55e88fe659592612a793c4f4aa723c9be
* | Ensure HABTM relationships produce valid class names (Fixes #17119)Sammy Larbi2014-11-091-0/+5
| |
* | Added SchemaDumper support for tables with jsonb columns.Ted O'Meara2014-11-041-11/+4
| |
* | Use bind values for joined tables in where statementsSean Griffin2014-11-011-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In practical terms, this allows serialized columns and tz aware columns to be used in wheres that go through joins, where they previously would not behave correctly. Internally, this removes 1/3 of the cases where we rely on Arel to perform type casting for us. There were two non-obvious changes required for this. `update_all` on relation was merging its bind values with arel's in the wrong order. Additionally, through associations were assuming there would be no bind parameters in the preloader (presumably because the where would always be part of a join) [Melanie Gilman & Sean Griffin]
* | 💣Sean Griffin2014-10-281-1/+1
|/ | | | We were relying on hash inequality in tests
* Dynamically modified schema and association would not be correctly resetAkira Matsuda2014-09-061-0/+6
| | | | | This fixes <"SQLite3::SQLException: no such column: legacy_things.person_id: SELECT \"legacy_things\".* FROM \"legacy_things\" WHERE \"legacy_things\".\"person_id\" = ?"> in OptimisticLockingTest#test_lock_destroy
* Added enable_extension! to helperAbdelkader Boudih2014-09-051-1/+1
|
* Only merge scopes with zero arity in has_many throughAgis-2014-08-201-0/+1
| | | | | | | | | | | | | | | with dynamic conditions. Fixes #16128 This bug was introduced in https://github.com/rails/rails/commit/c35e438620f2d56562251571377995359546393d so it's present from 4.1.2-rc1 and after. https://github.com/rails/rails/commit/c35e438620f2d56562251571377995359546393d merges any relation scopes passed as proc objects to the relation, but does *not* take into account the arity of the lambda. To reproduce: https://gist.github.com/Agis-/5f1f0d664d2cd08dfb9b
* Change the default `null` value for timestampsSean Griffin2014-08-121-5/+5
| | | | | | | As per discussion, this changes the model generators to specify `null: false` for timestamp columns. A warning is now emitted if `timestamps` is called without a `null` option specified, so we can safely change the behavior when no option is specified in Rails 5.
* use foreign key DSL in our tests.Yves Senn2014-07-161-3/+2
|
* Address ORA-00972: identifier is too long when tested with OracleYasuo Honda2014-07-141-2/+2
| | | | by using shorter attribute names.
* Re-enable foriegn key tests on MySQLGodfrey Chan2014-07-051-3/+1
| | | | This reverts commit e84799d, e31104c and e6ca8e2
* MySQL doesn't work with foreign keysPhilippe Creux2014-06-271-1/+4
| | | | | | This was previously fixed in e84799d but broken in 3f596f8. This commit reintroduced the conditional that prevents the foreign keys from being added to MySQL databases.
* Fix test with add_foreign_key DSL in 9d21ef9Philippe Creux2014-06-271-1/+1
|
* Do not change the global state of the test suiteRafael Mendonça França2014-06-271-0/+1
|
* fk: use random digest namesYves Senn2014-06-262-5/+5
| | | | | | The name of the foreign key is not relevant from a users perspective. Using random names resolves the urge to rename the foreign key when the respective table or column is renamed.