aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
* Rails 5.1 point type should not raise exception if empty string is provided ↵bUg2016-05-151-0/+7
| | | | as value
* Give more context from `AssociationMismatchError`Sean Griffin2016-05-121-1/+1
| | | | | | | The error message that we give today makes this error difficult to debug if you receive it. I have no clue why we're printing the object ID of the class (the commit doesn't give context), but I've left it as it was deliberate.
* Rename test methodMolchanov Andrey2016-05-121-1/+1
|
* Fix false positive mutation detection when JSON is used with serializeSean Griffin2016-05-121-0/+33
| | | | | | | | | | | | | When looking for mutation, we compare the serialized version of the value to the before_type_cast form. `Type::Serialized` was breaking this contract by passing the already serialized attribute to the subtype's mutation detection. This never manifested previously, as all mutable subtypes either didn't do anything in their `serialize` method, or had a way to detect double serialization (e.g. `is_a?(String)`). However, now that JSON types can handle string primitives, we need to avoid double serialization. Fixes #24993.
* Merge pull request #24980 from merhard/virtual-attribute-defaultSean Griffin2016-05-111-0/+9
|\ | | | | Define ActiveRecord::Attribute::Null#type_cast
| * Define ActiveRecord::Attribute::Null#type_castMatthew Erhard2016-05-111-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Using ActiveRecord::Base.attribute to declare an attribute with a default value on a model where the attribute is not backed by the database would raise a NotImplementedError when model.save is called. The error originates from https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L84. This is called from https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L46 on an ActiveRecord::Attribute::Null object. This commit corrects the behavior by implementing ActiveRecord::Attribute::Null#type_cast. With ActiveRecord::Attribute::Null#type_cast defined, ActiveRecord::Attribute::Null#value (https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L173..L175) can be replaced with its super method (https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L36..L40). fixes #24979
* | remove_connection should not remove parent connectionArthur Neves2016-05-111-0/+7
|/ | | | | | When calling remove_connection in a subclass, that should not fallback to the parent, otherwise it will remove the parent connection from the handler.
* Dont cache the conn_spec_name when emptyArthur Neves2016-05-111-1/+10
| | | | | | | | We cannot cache the connection_specification_name when it doesnt exist. Thats because the parent value could change, and we should keep failling back to the parent. If we cache that in a children as an ivar, we would not fallback anymore in the next call, so the children would not get the new parent spec_name.
* Make sure we reset the connection_specification_name onArthur Neves2016-05-101-0/+14
| | | | | | | | | | | | | | remove_connection When calling `remove_connection` on a model, we delete the pool so we also need to reset the `connection_specification_name` so it will fallback to the parent. This was the current behavior before rails 5, which will fallback to the parent connection pool. [fixes #24959] Special thanks to @jrafanie for working with me on this fix.
* Should quote `lock_name` to pass to `get_advisory_lock`Ryuta Kamizono2016-05-101-3/+3
|
* Merge pull request #24844 from arthurnn/arthurnn/connArthur Nogueira Neves2016-05-066-30/+43
|\ | | | | Refactor connection handler
| * s/specification_name/connection_specification_nameArthur Neves2016-05-061-2/+2
| |
| * s/specification_id/specification_nameArthur Neves2016-05-053-13/+13
| |
| * Test to swap connection at runtimeArthur Neves2016-05-051-0/+7
| |
| * fix testArthur Neves2016-05-051-8/+7
| |
| * Add spec_id testsArthur Neves2016-05-051-0/+9
| |
| * Use spec key, when given as spec_idArthur Neves2016-05-051-19/+15
| |
| * Refactor connection handlerArthur Neves2016-05-055-33/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ConnectionHandler will not have any knowlodge of AR models now, it will only know about the specs. Like that we can decouple the two, and allow the same model to use more than one connection. Historically, folks used to create abstract AR classes on the fly in order to have multiple connections for the same model, and override the connection methods. With this, now we can override the `specificiation_id` method in the model, to return a key, that will be used to find the connection_pool from the handler.
* | Merge pull request #24871 from vipulnsward/disable-transaction-failureArthur Nogueira Neves2016-05-061-0/+2
|\ \ | | | | | | Fix failures due to transactions
| * | We are erroring due to nested transaction failures from mysql on ↵Vipul A M2016-05-061-0/+2
| |/ | | | | | | | | | | | | | | test_migrate_clears_schema_cache_afterward test. Disable transactions for this test. Fixes #24391
* / Allow the connection adapters to determine the order of bind paramsSean Griffin2016-05-061-0/+18
|/ | | | | | | | | | | | In 5.0 we use bind parameters for limit and offset, while in 4.2 we used the values directly. The code as it was written assumed that limit and offset worked as `LIMIT ? OFFSET ?`. Both Oracle and SQL Server have a different syntax, where the offset is stated before the limit. We delegate this behavior to the connection adapter so that these adapters are able to determine how the bind parameters are flattened based on what order their specification has the various clauses appear. Fixes #24775
* Fix some typos in comments.Joe Rafaniello2016-05-042-2/+2
| | | | [ci skip]
* Followup of #24835Vipul A M2016-05-033-5/+5
| | | | Fix failing tests
* Do not delegate `AR::Base#empty?` to `all`Sean Griffin2016-05-021-6/+0
| | | | | | | | | | Unlike `one?` and `none?`, `empty?` has interactions with methods outside of enumerable. It also doesn't fit in the same vein. `Topic.any?` makes sense. `Topic.empty?` does not, as `Topic` is not a container. Fixes #24808 Close #24812
* Merge pull request #24713 from tomkadwill/fix_counter_cache_incrementSean Griffin2016-04-301-0/+11
|\ | | | | | | | | Fix counter_cache double increment bug Close #24183
| * Fix counter_cache double increment bugTom Kadwill2016-04-281-0/+11
| |
* | Replace `Rails.version.to_f` with Active RecordJon Moss2016-04-301-0/+4
| | | | | | | | | | Rails should not be explicity mentioned within Active Record, since railties and the Rails ecosystem is not required for use.
* | rm unused requireVipul A M2016-04-291-1/+0
| | | | | | | | Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* | Extract `add_sql_comment!` methodRyuta Kamizono2016-04-291-3/+3
| | | | | | | | | | | | Refactor of #22911. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* | Treat blank comments as no comment for indexesRyuta Kamizono2016-04-291-1/+10
| | | | | | | | | | | | Follow up of 1683410. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* | test the number of times the schema is loadingKeenan Brock2016-04-281-0/+53
|/
* Dont simply assume a type is a valid database type. This is only always true ↵Vipul A M2016-04-251-0/+11
| | | | | | | in the case of sqlite. Others adapters need to perform a check for validity. Add coverage for mysql2 db type validation
* Add Expression Indexes and Operator Classes support for PostgreSQLRyuta Kamizono2016-04-245-20/+53
| | | | | | | | | | | | | | | | 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>
* remove_index do not fetch indexes if name is specifiedSeva Orlov2016-04-242-0/+16
| | | | | | There is no need to fetch all table indexes in remove_index if name is specified. If name is wrong, then StatementInvalid will be raised. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Followup of #15771Vipul A M2016-04-241-0/+6
| | | | | | | | | Make sure we handle explicitly passed nil's to lock_version as well. An explicitly passed nil value is now converted to 0 on LockingType, so that we don't end up with ActiveRecord::StaleObjectError in update record optimistic locking Fixes #24695
* Merge pull request #24685 from vipulnsward/sqlite-compat-for-multi-insertJeremy Daer2016-04-221-0/+18
|\ | | | | | | Gracefully fallback on version migrations for sqlite < 3.7.11
| * https://github.com/rails/rails/commit/42dd2336b31a8d98776d039a2b9fd7f834156a ↵Vipul A M2016-04-231-0/+18
| | | | | | | | | | | | | | | | | | 78 changed INSERT INTO versions to run in 1 single query. This breaks for sqlite versions < 3.7.11, which is especially the case on Ubuntu 12.04 LTS, that has SQLite version 3.7.9 as default. So we check for support for multi insert, before performing single query inserts, else fallback to older version of running multiple queries. [Vipul A M & Yasuo Honda]
* | Do not attempt to return connection with open transaction to pool (#24610)Sean Griffin2016-04-221-5/+7
|/ | | | | | | | | | | | | When the query cache completes, if Active Record is still inside of a transaction, it is because the transaction is meant to be left open above this unit of work (such as transactional fixtures in tests). There were several tests around the behavior of "tests" that were invalid, as tests are not run through the executor. They have been changed to reflect the new behavior, which is closer to what actually occurs in Rails tests. Fixes #23989 Fixes #24491 Close #24500
* Merge pull request #24221 from gregmolnar/uuidKasper Timm Hansen2016-04-201-0/+7
|\ | | | | create_join_table should work with uuid
| * add column type option to create_join_table to support uuidGreg Molnar2016-03-171-0/+7
| |
* | Dump indexes in `create_table` for generates SQL in one queryRyuta Kamizono2016-04-202-12/+12
| | | | | | | | | | If the adapter supports indexes in create table, it generates SQL in one query.
* | Remove unecessary commentJon Moss2016-04-191-1/+1
| |
* | Database comments: Treat blank comments as no comment. Don't dump blank ↵Jeremy Daer2016-04-191-55/+96
| | | | | | | | comments.
* | Remove unused `table_with_autoincrement` tableRyuta Kamizono2016-04-191-4/+0
| |
* | Merge pull request #24503 from ↵Jeremy Daer2016-04-191-11/+23
|\ \ | | | | | | | | | | | | | | | prathamesh-sonpatki/add-test-for-warn-on-records-fetched-greater-than Add missing test case for record_fetched_greater_than config
| * | Add missing test case for record_fetched_greater_than configPrathamesh Sonpatki2016-04-111-11/+23
| | | | | | | | | | | | - The negative scenario test case was missing earlier.
* | | Merge pull request #23523 from kamipo/avoid_truncation_in_uniqueness_validationJeremy Daer2016-04-181-10/+32
|\ \ \ | | | | | | | | | | | | Avoid a string value truncation in uniqueness validation
| * | | Avoid a string value truncation in uniqueness validationRyuta Kamizono2016-02-121-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In MySQL, PostgreSQL, Oracle and SQLServer, a value over the limit cannot be inserted or updated (See #23522). In SQLite3, a value is inserted or updated regardless of the limit. We should avoid a string value truncation in uniqueness validation.
* | | | Merge pull request #23522 from kamipo/add_value_too_long_exception_classJeremy Daer2016-04-181-0/+9
|\ \ \ \ | | | | | | | | | | | | | | | Add `ActiveRecord::ValueTooLong` exception class
| * | | | Add `ActiveRecord::ValueTooLong` exception classRyuta Kamizono2016-02-061-0/+9
| | | | |