aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/primary_keys_test.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge pull request #17696 from kamipo/unsigned_integer_supportJeremy Daer2015-09-191-1/+2
|\ | | | | | | Add `unsigned` support for numeric data types in MySQL
| * Add `unsigned` support for numeric data types in MySQLRyuta Kamizono2015-09-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | Example: create_table :foos do |t| t.integer :unsigned_integer, unsigned: true t.bigint :unsigned_bigint, unsigned: true t.float :unsigned_float, unsigned: true t.decimal :unsigned_decimal, unsigned: true, precision: 10, scale: 2 end
* | Correctly dump composite primary keyRyuta Kamizono2015-09-201-0/+27
|/ | | | | | | | | Example: create_table :barcodes, primary_key: ["region", "code"] do |t| t.string :region t.integer :code end
* Added test case for serial? method when sequence name is not quotedPrathamesh Sonpatki2015-05-221-0/+6
| | | | - Followup of https://github.com/rails/rails/pull/20190/.
* Fix `serial?` with quoted sequence nameRyuta Kamizono2015-05-181-0/+8
|
* use Model.reset_column_information to clear table cache connection wide.Kuldeep Aggarwal2015-03-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `widgets` table is being created in `primary_keys_test.rb` for PostgreSQLAdapter, MysqlAdapter, Mysql2Adapter and it makes test to fail earlier. Before: `bundle exec rake mysql2:test` ``` Finished in 127.287669s, 35.5258 runs/s, 97.8885 assertions/s. 1) Error: PersistenceTest::SaveTest#test_save_touch_false: ActiveModel::UnknownAttributeError: unknown attribute 'name' for #<Class:0x0000000a7d6ef0>. /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:36:in `rescue in _assign_attribute' /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:34:in `_assign_attribute' /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes' /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:39:in `each' /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:39:in `_assign_attributes' /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `_assign_attributes' /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:33:in `assign_attributes' /home/kd/projects/kd-rails/activerecord/lib/active_record/core.rb:293:in `initialize' /home/kd/projects/kd-rails/activerecord/lib/active_record/inheritance.rb:61:in `new' /home/kd/projects/kd-rails/activerecord/lib/active_record/inheritance.rb:61:in `new' /home/kd/projects/kd-rails/activerecord/lib/active_record/persistence.rb:50:in `create!' /home/kd/projects/kd-rails/activerecord/test/cases/persistence_test.rb:913:in `test_save_touch_false' 4522 runs, 12460 assertions, 0 failures, 1 errors, 4 skips ``` After: `bundle exec rake mysql2:test` ``` Finished in 135.785086s, 33.3026 runs/s, 91.7774 assertions/s. 4522 runs, 12462 assertions, 0 failures, 0 errors, 4 skips ```
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Allow `:limit` option for MySQL bigint primary key supportRyuta Kamizono2015-02-241-0/+10
| | | | | | | | | | | | | Example: create_table :foos, id: :primary_key, limit: 8 do |t| end # or create_table :foos, id: false do |t| t.column :id, limit: 8 end
* 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.
* Replace `if exists` with `table_exists?` and drop table statement with ↵Yasuo Honda2015-01-211-1/+1
| | | | | | | `drop_table` since 'drop table if exists' statement does not always work with some databases such as Oracle. also Oracle drop table statement will not drop sequence objects.
* Improve a dump of the primary key support.Ryuta Kamizono2014-12-291-0/+19
| | | | If it is not a default primary key, correctly dump the type and options.
* Add bigint primary key support for MySQL.Ryuta Kamizono2014-12-281-6/+13
| | | | | | | Example: create_table :foos, id: :bigint do |t| end
* Support for any type primary key.Ryuta Kamizono2014-12-281-0/+24
|
* Define id_was to get the previous value of the primary keyRafael Mendonça França2014-08-061-0/+10
| | | | | | | | | Currently when we call id_was and we have a custom primary key name Active Record will return the current value of the primary key. This make impossible to correctly do an update operation if you change the id. Fixes #16413
* Move writing unknown column exception to null attributeSean Griffin2014-06-261-2/+10
| | | | | | Making this change revealed several subtle bugs related to models with no primary key, and anonymous classes. These have been fixed as well, with regression tests added.
* test refactor, don't hardcode `primary_key_prefix_type` default.Yves Senn2014-06-061-0/+3
| | | | /cc @zuhao
* Remove `Column#primary`Sean Griffin2014-05-231-32/+0
| | | | | | | | It appears to have been used at some point in the past, but is no longer used in any meaningful way. Whether a column is considered primary is a property of the model, not the schema/column. This also removes the need for yet another layer of caching of the model's schema, and we can leave that to the schema cache.
* Handle other pk types in PostgreSQL gracefully.Patrick Robertson2014-05-121-0/+26
| | | | | | | | | | | | | | In #10410 it was noted that you can no longer create PK's with the type of bigserial in PostgreSQL in 4.0.0.rc1. This is mostly because the newer adapter is checking for column type with the id column instead of just letting it pass through like it did before. Side effects: You may just create a PK column of a type that you really don't want to be your PK. As far as I can tell this was allowed in 3.2.X and perhaps an exception should be raised if you try and do something extremely dumb.
* docs, AR already auto-detects primary keys. Closes #13946. [ci skip]Yves Senn2014-02-051-1/+5
| | | | | This behavior was introduced since Rails 3.1 (207f266ccaaa9cd04cd2a7513ae5598c4358b510) but the docs were still out of date.
* Remove more skipRafael Mendonça França2013-11-081-2/+0
|
* Don't skip tests if we don't need to.Rafael Mendonça França2013-11-081-9/+10
| | | | | | | We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed.
* Fix class and method name typosVipul A M2013-05-121-1/+1
|
* Revert "Merge pull request #10455 from ↵Aaron Patterson2013-05-071-29/+0
| | | | | | | patricksrobertson/bigserial_id_not_identifying_pk" This reverts commit 3043d45eefc3776d5f3a9e7d212a01f99d869ef8, reversing changes made to ca0275d36b395631725c4583db5a45c06443fdb9.
* Handle other pk types in PostgreSQL gracefully.Patrick Robertson2013-05-071-0/+29
| | | | | | | | | | | | | | In #10410 it was noted that you can no longer create PK's with the type of bigserial in PostgreSQL in 4.0.0.rc1. This is mostly because the newer adapter is checking for column type with the id column instead of just letting it pass through like it did before. Side effects: You may just create a PK column of a type that you really don't want to be your PK. As far as I can tell this was allowed in 3.2.X and perhaps an exception should be raised if you try and do something extremely dumb.
* Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"Guillermo Iguaran2013-01-181-1/+1
| | | | | This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
* User Rails 4 find_byrobertomiranda2013-01-181-1/+1
|
* Standardize the use of current_adapter?Rafael Mendonça França2013-01-011-3/+3
|
* Remove ActiveRecord::ModelJon Leighton2012-10-261-2/+2
| | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* fix build 5001, model reply is required in cases/primary_keys_test too!Vishnu Atrai2012-02-121-0/+1
|
* removed unuseful require for reply as we are not using require modelKarunakar (Ruby)2012-02-111-1/+0
|
* Fix GH #4754. Remove double-quote when using ANSI_QUOTESkennyj2012-01-311-0/+16
|
* Fix CIJon Leighton2011-12-281-2/+2
|
* Cache columns at the model level.Jon Leighton2011-12-161-8/+30
| | | | Allows two models to use the same table but have different primary keys.
* Fix #3987.Jon Leighton2011-12-151-0/+10
|
* Add test for read_attribute(:id) with non-standard PK.Jon Leighton2011-12-011-0/+5
| | | | | | | | Also make it actually work. It slows down all read_attribute accesses to map 'id' to whatever the PK actually is, inside read_attribute. So instead make sure the necessary methods are defined and that they redirect wherever they need to go.
* Deprecate set_primary_key in favour of self.primary_key=Jon Leighton2011-11-291-5/+2
|
* Transactional fixtures enlist all active database connections.Jeremy Kemper2011-10-051-0/+4
| | | | You can use multiple databases in your tests without disabling transactional fixtures.
* Revert "Raise error on unknown primary key."Jon Leighton2011-10-051-14/+0
| | | | This reverts commit ee2be435b1e5c0e94a4ee93a1a310e0471a77d07.
* Raise error on unknown primary key.Jon Leighton2011-10-051-0/+14
| | | | | If we don't have a primary key when we ask for it, it's better to fail fast. Fixes GH #2307.
* Don't require a DB connection when setting primary key.Jon Leighton2011-09-261-0/+16
| | | | Closes #2807.
* Revert "to_key on a destroyed model should return nil". Closes #2440Santiago Pastorino2011-08-051-1/+1
| | | | This reverts commit c5448721b5054b8a467958d60427fdee15eac604.
* to_key on a destroyed model should return nilSantiago Pastorino2011-07-091-1/+1
|
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* Quote find_in_batches ORDER BY clause [#6620 state:resolved]Andrew White2011-03-291-0/+9
|
* code gardening: we have assert_(nil|blank|present), more concise, with ↵Xavier Noria2010-08-171-1/+1
| | | | better default failure messages - let's use them
* Revert "Makes AR use AMo to_key implementation"Santiago Pastorino2010-08-151-1/+1
| | | | This reverts commit 36a84a4f15f29b41c7cac2f8de410055006a8a8d.
* Makes AR use AMo to_key implementationSantiago Pastorino2010-08-131-1/+1
| | | | [#5249]
* expected value should come first in assert_equalNeeraj Singh2010-07-181-2/+2
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* primary_keys_test reads better than pk_testNeeraj Singh2010-07-181-0/+139
Signed-off-by: José Valim <jose.valim@gmail.com>