aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
Commit message (Collapse)AuthorAgeFilesLines
...
* | Correctly handle limit on int4 and int8 types in PGSean Griffin2014-12-221-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PG doesn't register it's types using the `int(4)` format that others do. As such, if we alias `int8` to the other integer types, the range information is lost. This is fixed by simply registering it separately. The other option (which I specifically chose to avoid) is to pass the information of the original type that was being aliased as an argument. I'd rather avoid that, since an alias should truly be treated the same. If we need different behavior for a different type, we should explicitly register it with that, and not have a conditional based on aliasing. Fixes #18144 [Sean Griffin & ysbaddaden]
* | Correctly handle Float -> BigDecimal with unspecified precisionSean Griffin2014-12-221-0/+5
| | | | | | | | Fixes #18122
* | `force: :cascade` to recreate tables referenced by foreign-keys.Yves Senn2014-12-193-1/+37
| |
* | Relax the UUID regexGodfrey Chan2014-12-181-3/+7
|/ | | | | | | | Apparently PG does not validate against RFC 4122. The intent of the original patch is just to protect against PG errors (which potentially breaks txns, etc) because of bad user input, so we shouldn't try any harder than PG itself. Closes #17931
* Remove unused lineRyuta Kamizono2014-12-171-1/+0
|
* `update_column` take ruby-land input, not database-land inputSean Griffin2014-12-161-2/+4
| | | | | | | | | | | | | | | In the case of serialized columns, we would expect the unserialized value as input, not the serialized value. The original issue which made this distinction, #14163, introduced a bug. If you passed serialized input to the method, it would double serialize when it was sent to the database. You would see the wrong input upon reloading, or get an error if you had a specific type on the serialized column. To put it another way, `update_column` is a special case of `update_all`, which would take `['a']` and not `['a'].to_yaml`, but you would not pass data from `params` to it. Fixes #18037
* Add test case for joined pluckSean Griffin2014-12-111-0/+7
| | | | https://github.com/rails/rails/commit/39542fba54328ca048fb75a5d5b37f8e1d4c1f37#commitcomment-8938379
* Improve the test case introduced by bd0d47eSean Griffin2014-12-111-19/+10
|
* Merge pull request #17994 from mfazekas/pluck-bind-values-masterSean Griffin2014-12-111-0/+24
|\ | | | | Fix ProtocolViolation/bind message for polymorphic + pluck or group+calc
| * Fix ProtocolViolation/bind message supplies for polymorphic + pluck or groupMiklos Fazkeas2014-12-111-0/+24
| |
* | Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.Ryuta Kamizono2014-12-123-0/+78
|/
* Merge pull request #17970 from ulissesalmeida/foreign-type-has-many-has-oneRafael Mendonça França2014-12-102-0/+21
|\ | | | | Add foreign_type option for polymorphic has_one and has_many.
| * Add foreign_type option for polymorphic has_one and has_many.Ulisses Almeida + Kassio Borges2014-12-082-0/+21
| | | | | | | | | | | | | | 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.
* | Merge pull request #17972 from claudiob/remove-unused-callback-fixturesCarlos Antonio da Silva2014-12-091-46/+0
|\ \ | | | | | | Remove unused "Developer" fixtures from tests
| * | Remove unused "Developer" fixtures from testsclaudiob2014-12-081-46/+0
| |/ | | | | | | | | The `RecursiveCallbackDeveloper` and `ImmutableMethodDeveloper` classes are not used anymore in tests, and neither is the `@cancelled` variable.
* | Update test case for TZ aware attributesSean Griffin2014-12-081-4/+14
| | | | | | | | | | | | The test added in 42418cfc94d1356d35d28d786f63e7fab9406ad6 wasn't actually testing anything, since the bug was with TZ aware attributes only.
* | Allow custom handling of non-standard types in `time_zone_conversion`Sean Griffin2014-12-081-0/+6
|/ | | | | | | | | | | | PostgreSQL for example, allows infinity as a valid value for date time columns. The PG type has explicit handling for that case. However, time zone conversion will end up trampling that handling. Unfortunately, we can't call super and then convert time zones. However, if we get back nil from `.in_time_zone`, it's something we didn't expect so we can let the superclass handle it. Fixes #17971
* Don't error when `attributes` is called on a frozen AR modelSean Griffin2014-12-081-0/+8
| | | | | | | | | | | | | | | | | | `freeze` will ultimately end up freezing the `AttributeSet`, which in turn freezes its `@attributes` hash. However, we actually insert a special object to lazily instantiate the values of the hash on demand. When it does need to actually instantiate all of them for iteration (the only case is `ActiveRecord::Base#attributes`, which calls `AttributeSet#to_h`), it will set an instance variable as a performance optimization Since it's just an optimization for subsequent calls, and that method being called at all is a very uncommon case, we can just leave the ivar alone if we're frozen, as opposed to coming up with some overly complicated mechanism for freezing which allows us to continue to modify ourselves. Fixes #17960
* Revert to 4.1 behavior for casting PG arraysSean Griffin2014-12-081-5/+20
| | | | | | | | | | The user is able to pass PG string literals in 4.1, and have it converted to an array. This is also possible in 4.2, but it would remain in string form until saving and reloading, which breaks our `attr = save.reload.attr` contract. I think we should deprecate this in 5.0, and only allow array input from user sources. However, this currently constitutes a breaking change to public API that did not go through a deprecation cycle.
* Make error message clearer that :on requires a symbol, not a stringCarol Nichols2014-12-071-0/+4
| | | | | | | | | | | | | | The validation added in 5a3dc8092d19c816b0b1203945639cb91d065847 will reject values for the `:on` option for after_commit and after_rollback callbacks that are string values like `"create"`. However, the error message says ":on conditions for after_commit and after_rollback callbacks have to be one of create,destroy,update". That looks like a string value *would* be valid. This commit changes the error message to say ":on conditions for after_commit and after_rollback callbacks have to be one of [:create, :destroy, :update]", making it clearer that symbols are required.
* Add `force: true` to tables created in PG testsSean Griffin2014-12-052-2/+2
| | | | | | If the tests are interupted and the teardown block doesn't run, the developer needs to delete these manually in order to be able to run the tests again.
* Correctly respect subtypes for PG arrays and rangesSean Griffin2014-12-051-0/+18
| | | | | | | | | | | | | The type registration was simply looking for the OID, and eagerly fetching/constructing the sub type when it was registered. However, numeric types have additional parameters which are extracted from the actual SQL string of the type during lookup, and can have their behavior change based on the result. We simply need to use the block form of registration, and look up the subtype lazily instead. Fixes #17935
* Merge pull request #17919 from mrgilman/stop-supporting-nested-arraysSean Griffin2014-12-042-30/+0
|\ | | | | Remove deprecated behavior allowing nested arrays as query values
| * Remove deprecated behavior allowing nested arrays as query valuesMelanie Gilman2014-12-042-30/+0
| |
* | Correctly handle multiple attribute method prefix/suffixes which matchSean Griffin2014-12-041-0/+10
|/ | | | | | | | | Active Record defines `attribute_method_suffix :?`. That suffix will match any predicate method when the lookup occurs in Active Model. This will make it incorrectly decide that `id_changed?` should not exist, because it attempts to determine if the attribute `id_changed` is present, rather than `id` with the `_changed?` suffix. Instead, we will look for any correct match.
* Deprecate `Class` handler in `PredicateBuilder`Melanie Gilman2014-12-041-1/+3
| | | | Users should pass strings to queries instead of classes
* Prevent Symbol GCRyuta Kamizono2014-12-041-0/+3
|
* Failure to rollback t.timestamps when within a change_table migrationnoam2014-12-034-6/+6
| | | | | | | | | | | | | When running the following migration: change_table(:table_name) { |t| t/timestamps } The following error was produced: wrong number of arguments (2 for 1) .... /connection_adapters/abstract/schema_statements.rb:851:in `remove_timestamps' This is due to `arguments` containing an empty hash as its second argument.
* skip test to get `sqlite3_mem` suite passing.Yves Senn2014-12-031-1/+1
|
* Merge pull request #17889 from mxie/mx-fix-nonexistent-typoSean Griffin2014-12-023-4/+4
|\ | | | | Fix "nonexistent" typo in tests
| * Fix "nonexistent" typo in testsMelissa Xie2014-12-023-4/+4
| |
* | Require missing association in testSean Griffin2014-12-021-0/+1
|/
* Refactor `build_from_hash` to convert dot notation to hash firstMelanie Gilman2014-12-021-0/+6
| | | | | | | | | | This ensures that we're handling all forms of nested tables the same way. We're aware that the `convert_dot_notation_to_hash` method will cause a performance hit, and we intend to come back to it once we've refactored some of the surrounding code. [Melissa Xie & Melanie Gilman]
* Allow to unscope where conditions using `arel_table` with Symboldeeeki2014-12-031-0/+8
| | | | | | This commit fixes the following case. User.where(User.arel_table[:created_at].lteq(1.year.ago)).unscope(where :created_at)
* pg tests, get rid of global schema `schema_1`.Yves Senn2014-12-022-46/+51
|
* pg tests, move uniqueness validation test to array tests.Yves Senn2014-12-022-17/+15
|
* tests, extract pg number tests into separate file.Yves Senn2014-12-022-35/+50
|
* tests, move schema shorthand assertions into pg specific tests.Yves Senn2014-12-029-76/+86
|
* tests, move pg geometric tests out of `base_test`.Yves Senn2014-12-022-93/+73
|
* ugh, forgot to add this test to cdd90f39d796986dabf1678b3277b230dbe18961Aaron Patterson2014-12-011-0/+5
|
* tests, favor public API over inspecting columns where possible.Yves Senn2014-12-011-16/+19
| | | | | This is a follow up to https://github.com/rails/rails/commit/07786c5e75a7b0afdf318063510af6b475e3e04c and https://github.com/rails/rails/commit/cd2596f55e88fe659592612a793c4f4aa723c9be
* tests, run numeric default tests for every adapter.Yves Senn2014-12-011-15/+33
|
* tests, use public API to verify default parsing. #17863, #17856Yves Senn2014-12-011-1/+2
|
* Fix value extracted from negative integers for PostgreSQL.Guo Xiang Tan2014-12-011-0/+4
| | | | Fixes: https://github.com/rails/rails/issues/17856.
* Ensure numericality validations work with mutationSean Griffin2014-12-011-0/+13
| | | | | | | | | | | | | | | | | | | | | The detection of in-place changes caused a weird unexpected issue with numericality validations. That validator (out of necessity) works on the `_before_type_cast` version of the attribute, since on an `:integer` type column, a non-numeric string would type cast to 0. However, strings are mutable, and we changed strings to ensure that the post type cast version of the attribute was a different instance than the before type cast version (so the mutation detection can work properly). Even though strings are the only mutable type for which a numericality validation makes sense, special casing strings would feel like a strange change to make here. Instead, we can make the assumption that for all mutable types, we should work on the post-type-cast version of the attribute, since all cases which would return 0 for non-numeric strings are immutable. Fixes #17852
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-2930-121/+109
|
* Adds preloaded_records method to NullPreloaderThorsten Ball2014-11-281-0/+8
| | | | | | | | This fixes a regression where preloading association throws an exception if one of the associations in the preloading hash doesn't exist for one record. Fixes #16070
* Fix a bug where AR::RecordNotSaved loses error messagesYuki Nishijima2014-11-273-9/+28
| | | | | | Since 3e30c5d, it started ignoring the given error message. This commit changes the behavior of AR::RecordNotSaved#initialize so that it no longer loses the given error message.
* Merge pull request #17807 from jvperrin/correct-integer-testRafael Mendonça França2014-11-271-1/+1
|\ | | | | Correct test description for large integer test
| * Correct test description for large integer testJason Perrin2014-11-031-1/+1
| |