aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Merge pull request #17820 from fw42/restore_query_cache_on_rollbackRafael Mendonça França2015-01-021-0/+32
|\ \ \ | | | | | | | | | | | | Clear query cache on rollback
| * | | Restore query cache on rollbackFlorian Weingarten2014-12-011-0/+32
| | | |
* | | | Merge pull request #15309 from iantropov/issue_12698_build_throughRafael Mendonça França2015-01-022-1/+12
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add setting of FK for throgh associations while building Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/associations/has_many_through_associations_test.rb
| * | | | Add setting of FK for throgh associations while buildingIvan Antropov2014-05-252-1/+12
| | | | |
* | | | | Merge pull request #18228 from kamipo/correctly_dump_primary_keyRafael Mendonça França2015-01-021-0/+19
|\ \ \ \ \ | |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | Improve a dump of the primary key support. Conflicts: activerecord/CHANGELOG.md
| * | | | 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.
* | | | | Remove support to activerecord-deprecated_findersRafael Mendonça França2015-01-022-3/+2
| | | | |
* | | | | Merge pull request #18067 from ↵Rafael Mendonça França2015-01-024-1/+182
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | kamipo/format_datetime_string_according_to_precision Format the datetime string according to the precision of the datetime field. Conflicts: activerecord/CHANGELOG.md
| * | | | | Format the datetime string according to the precision of the datetime field.Ryuta Kamizono2015-01-022-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Incompatible to rounding behavior between MySQL 5.6 and earlier. In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`: http://bugs.mysql.com/bug.php?id=68760
| * | | | | Allow precision option for MySQL datetimes.Ryuta Kamizono2015-01-024-1/+148
| | | | | |
* | | | | | Merge pull request #15746 from amccloud/auto-inverse_of-in-moduleRafael Mendonça França2015-01-021-0/+12
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed automatic inverse_of for models nested in module Conflicts: activerecord/CHANGELOG.md
| * | | | | | Fixed automatic inverse_of for models nested in moduleAndrew McCloud2014-06-151-0/+12
| | | | | | |
* | | | | | | Merge pull request #11898 from prathamesh-sonpatki/patch-updateRafael Mendonça França2015-01-022-2/+22
|\ \ \ \ \ \ \ | |_|/ / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed ActiveRecord::Relation#update behavior so that it will work on Relation objects without giving id Conflicts: activerecord/CHANGELOG.md
| * | | | | | Allow ActiveRecord::Relation#update to run on result of a relation with ↵Prathamesh Sonpatki2014-12-202-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | callbacks and validations - Right now, there is no method to update multiple records with validations and callbacks. - Changed the behavior of existing `update` method so that when `id` attribute is not given and the method is called on an `Relation` object, it will execute update for every record of the `Relation` and will run validations and callbacks for every record. - Added test case for validating that the callbacks run when `update` is called on a `Relation`. - Changed test_create_columns_not_equal_attributes test from persistence_test to include author_name column on topics table as it it used in before_update callback. - This change introduces performance issues when a large number of records are to be updated because it runs UPDATE query for every record of the result. The `update_all` method can be used in that case if callbacks are not required because it will only run single UPDATE for all the records.
* | | | | | | Merge pull request #18080 from korbin/fix_reaping_frequency_configurationRafael Mendonça França2015-01-021-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Fix issue with reaping_frequency type.
| * | | | | | | fix issue with reaping_frequency typekorbin2014-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using DATABASE_URL to configure ActiveRecord, :reaping_frequency does not get converted from a string to a numeric value. This value is eventually passed to 'sleep' and must be numeric to avoid exceptions. This commit converts :reaping_frequency to a float when present.
* | | | | | | | Stop explicitly passing `nil` as the column to `type_cast`Sean Griffin2015-01-011-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So we can change the arity later.
* | | | | | | | Stop depending on columns for type information in PG quoting testsSean Griffin2015-01-012-30/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few of the tests weren't testing anything of value. The IP Address tests are testing the type, not behavior of the connection adapter. There are two CVE regression tests which are important, but don't have a good place to go, so I've left them alone for now, as they call `quote` and the focus right now is removing `column` from `type_cast`
* | | | | | | | Stop relying on columns for type information in mysql2 casting testsSean Griffin2015-01-011-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The column itself has no actual impact on the return value. These were actually testing the behavior of the type object, which is sufficiently covered elsewhere.
* | | | | | | | Stop relying on columns in mysql quoting testsSean Griffin2015-01-011-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The behavior tested by the removed lines is sufficiently covered elsewhere.
* | | | | | | | Stop relying on columns in sqlite quoting testsSean Griffin2015-01-012-22/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The string encoding test wasn't using the types for anything. The boolean casting test included logic that should be in the tests for the types, and the string test was legitimately not testing anything useful.
* | | | | | | | Fix warning: assigned but unused variable - postRyuta Kamizono2014-12-311-1/+1
| | | | | | | |
* | | | | | | | Fix error message when trying to create an associated recordRafael Mendonça França2014-12-302-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This error only happens when the foreign key is missing. Before this fix the following exception was being raised: NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218> Now the message is: ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
* | | | | | | | Share foreign_key_present? implementation in _has_ associationsbrainopia2014-12-312-35/+57
| | | | | | | |
* | | | | | | | Merge pull request #17680 from larskanis/fix_bytea_change_detectionSean Griffin2014-12-301-1/+8
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | PostgreSQL, Fix change detection caused by superfluous bytea unescaping
| * | | | | | | | PostgreSQL, Fix change detection caused by wrong data for bytea unescaping.Lars Kanis2014-12-291-1/+8
| | |_|_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This showed up when running BinaryTest#test_load_save with the more restrictive input string handling of pg-0.18.0.pre20141117110243.gem . Bytea values sent to the server are in binary format, but are returned back as escaped text. To fulfill the assumption that type_cast_from_database(type_cast_for_database(binary)) == binary we unescape only, if the value was really received from the server.
* | | | | | | | Ensures that primary_key method will return nil when multi-pkArthur Neves2014-12-303-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When table has a composite primary key, the `primary_key` method for sqlite3 and postgresql was only returning the first field of the key. Ensures that it will return nil instead, as AR dont support composite pks.
* | | | | | | | AR specific length validator to respect `marked_for_destruction`.Yves Senn2014-12-302-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Closes #7247. Conflicts: activerecord/CHANGELOG.md activerecord/test/models/owner.rb
* | | | | | | | Ensure `first!` and friends work on loaded associationsSean Griffin2014-12-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #18237
* | | | | | | | Remove all cases of manuallly wrapping `Arel::Nodes::Quoted`Sean Griffin2014-12-294-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is no longer required now that we are injecting a type caster object into the Arel table, with the exception of uniqueness validations. Since it calls `ConnectionAdapter#type_cast`, the value has already been cast for the database. We don't want Arel to attempt to cast it further, so we need to continue wrapping it in a quoted node. This can potentially go away when this validator is refactored to make better use of `where` or the predicate builder.
* | | | | | | | Fix failing testsSean Griffin2014-12-291-8/+4
| | | | | | | |
* | | | | | | | `eager_load` preserves readonly flag for associationsTakashi Kokubun2014-12-301-1/+4
|/ / / / / / /
* | | | | | | Provide :touch option to save() to accommodate saving without updating ↵Dan Olson2014-12-271-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | timestamps. [#18202]
* | | | | | | Provide a better error message for unsupported classes in `serialize`Sean Griffin2014-12-271-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We only support classes which provide a no-args constructor to use as a default value. We can provide a more helpful error message if we catch this when `serialize` is called, rather than letting it error when you try to assign the attribute. Fixes #18224
* | | | | | | 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
| | | | | | |
* | | | | | | Inform Arel we don't need additional type casting in testsSean Griffin2014-12-263-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of the larger refactoring to remove type casting from Arel. We can inform it that we already have the right type by wrapping the value in an `Arel::Nodes::Quoted`. This commit can be reverted when we have removed type casting from Arel in Rail 5.1
* | | | | | | Go through normal `update_all` logic when updating lock columnsSean Griffin2014-12-261-2/+0
| | | | | | |
* | | | | | | Inform Arel that we don't need type casting in testsSean Griffin2014-12-261-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of the larger refactoring to remove type casting from Arel. We can inform it that we already have the right type by wrapping the value in an `Arel::Nodes::Quoted`. This commit can be reverted when we have removed type casting from Arel in Rail 5.1
* | | | | | | Inform Arel that we don't need to cast a value in testsSean Griffin2014-12-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of the larger refactoring to remove type casting from Arel. We can inform it that we already have the right type by wrapping the value in an `Arel::Nodes::Quoted`. This commit can be reverted when we have removed type casting from Arel in Rail 5.1
* | | | | | | Go through normal `where` logic when preloading associationsSean Griffin2014-12-264-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will allow eager type casting to take place as needed. There doesn't seem to be any particular reason that the `in` statement was forced for single values, and the commit message where it was introduced gives no context. See https://github.com/rails/rails/commit/d90b4e2615e8048fdeffc6dffe3246704adee01f
* | | | | | | Eagerly cast array values passed to the predicate builderSean Griffin2014-12-261-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of a larger refactoring to remove type casting from Arel. /cc @mrgilman [Sean Griffin & Melanie Gilman]
* | | | | | | Perform casting of single values within the predicate builderSean Griffin2014-12-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of the larger refactoring to remove type casting from Arel, we need to do the casting of values eagerly. The predicate builder is the closest place that knows about the Active Record class, and can therefore have the type information. /cc @mrgilman [Sean Griffin & Melanie Gilman]
* | | | | | | Remove `klass` and `arel_table` as a dependency of `PredicateBuilder`Sean Griffin2014-12-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class cares far too much about the internals of other parts of Active Record. This is an attempt to break out a meaningful object which represents the needs of the predicate builder. I'm not fully satisfied with the name, but the general concept is an object which represents a table, the associations to/from that table, and the types associated with it. Many of these exist at the `ActiveRecord::Base` class level, not as properties of the table itself, hence the need for another object. Currently it provides these by holding a reference to the class, but that will likely change in the future. This allows the predicate builder to remain wholy concerned with building predicates. /cc @mrgilman
* | | | | | | Fix new warning in ruby 2.2Sean Griffin2014-12-261-2/+2
| | | | | | |
* | | | | | | Change `PredicateBuilder` handler methods to instance methodsSean Griffin2014-12-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will allow us to pass the predicate builder into the constructor of these handlers. The procs had to be changed to objects, because the `PredicateBuilder` needs to be marshalable. If we ever decide to make `register_handler` part of the public API, we should come up with a better solution which allows procs. /cc @mrgilman [Sean Griffin & Melanie Gilman]
* | | | | | | Inject the `PredicateBuilder` into the `Relation` instanceSean Griffin2014-12-263-27/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Construction of relations can be a hotspot, we don't want to create one of these in the constructor. This also allows us to do more expensive things in the predicate builder's constructor, since it's created once per AR::Base subclass
* | | | | | | Merge branch 'brainopia-remember_frozen_state_in_transaction'Sean Griffin2014-12-261-0/+15
|\ \ \ \ \ \ \
| * | | | | | | Propagate frozen state during transaction changesbrainopia2014-12-261-0/+14
|/ / / / / / /
* | | | | | | Correctly ignore `case_sensitive` for UUID uniqueness validationSean Griffin2014-12-261-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I think we should deprecate this behavior and just error if you tell us to do a case insensitive comparison for types which are not case sensitive. Partially reverts 35592307 Fixes #18195