| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
That ability was introduced at #11898 as `Relation#update` without
giving ids, so the ability on the class level is not documented and not
tested.
c83e30d which fixes #33470 has lost two undocumented abilities.
One has fixed at 5c65688, but I missed the ability on the class level.
Removing any feature should not be suddenly happened in a stable version
even if that is not documented.
I've restored the ability and added test case to avoid any regression in
the future.
Fixes #34743.
|
|
|
|
|
|
|
|
|
| |
`test_update_does_not_run_sql_if_record_has_not_changed` would pass
without #18501 since `assert_queries` ignores BEGIN/COMMIT unless
`ignore_none: true` is given.
Since #32647, empty BEGIN/COMMIT is ommited. So we no longer need to use
`assert_queries(0)` to ignore BEGIN/COMMIT in the queries.
|
| |
|
|
|
|
|
|
|
|
| |
`relations_test.rb`
`persistence_test.rb` and `relations_test.rb` have too many lines, so
I'd like to extract relation around tests to dedicated files before
newly test added.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`touch` option was added to `increment!` (#27660) and `update_counters`
(#26995). But that option behaves inconsistently with
`Persistence#touch` method.
If `touch` option is passed attribute names, it won't update
update_at/on attributes unlike `Persistence#touch` method.
Due to changed from `Persistence#touch` to `increment!` with `touch`
option, #31405 has a regression that `counter_cache` with `touch` option
which is passed attribute names won't update update_at/on attributes.
I think that the inconsistency is not intended. To get back consistency,
ensure that `touch` option updates update_at/on attributes.
|
|
|
|
| |
Follow up of #32605.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`after_initialize`
`becomes` creates new object and copies attributes from the receiver. If
new object has mutation tracker which is created in `after_initialize`,
it should be cleared since it is for discarded attributes.
But if the receiver doesn't have mutation tracker yet, it will not be
cleared properly.
It should be cleared regardless of whether the receiver has mutation
tracker or not.
Fixes #32867.
|
|
|
|
|
| |
This autocorrects the violations after adding a custom cop in
3305c78dcd.
|
|
|
|
| |
Closes #31998
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently `_default_attributes` doesn't work unless `load_schema` is
called before.
The `MissingAttributeError` is caused by `reload_schema_from_cache` is
invoked by `serialize`.
I added `load_schema` in `_default_attributes` to `_default_attributes`
works without any dependency like `attribute_types` etc.
Closes #31905.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes issue described in #30399: A default value on the
inheritance column prevented `child.becomes(Parent)` to return
an instance of `Parent` as expected, instead it returns an instance
of the default subclass.
The change was introduced by #17169 and it was meant to affect
initialization, alone. Where `Parent.new` is expected to return
an instance of the default subclass.
|
|
|
|
|
|
|
|
|
|
| |
Currently `object.save` will unfreeze the object, due to
`changes_applied` replaces frozen `@attributes` to new `@attributes`.
Since originally destroyed objects are not allowed to be mutated, `save`
and `save!` should not return success in that case.
Fixes #28563.
|
|
|
|
|
|
|
|
| |
update_attribute previously stopped execution, before saving and before
running callbacks, if the record's attributes hadn't changed. [The
documentation](http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attribute)
says that "Callbacks are invoked", which was not happening if the
persisted attributes hadn't changed.
|
|
|
|
|
|
| |
Arel doesn't support subselect generation for DELETE unlike UPDATE yet,
but we already have that generation in connection adapters. We can
simply use the subselect generated by that one.
|
|
|
|
|
|
|
|
|
|
|
| |
`offset`
Most RDBMS (except SQLite) requires subselect for UPDATE with OFFSET,
but Arel doesn't support executable subselect generation for MySQL's
UPDATE yet. We need to use the subselect generated by the connection
adapter for now, it works well.
Fixes #30148.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
making changes (#31306)
It makes more sense than ignoring invalid IDs.
|
|
|
|
|
|
|
|
|
|
|
| |
In 35836019, class level `update` and `destroy` suppressed
`RecordNotFound` to ensure returning affected objects. But
`RecordNotFound` is a common exception caught by a `rescue_from`
handler. So changing the behavior when a typical `params[:id]` is passed
has a compatibility problem. The previous behavior should not be
changed.
Fixes #31301.
|
|
|
|
|
|
|
|
|
|
| |
eager-loading is needed
If a relation has eager-loading values, `count` and `exists?` works
properly, but `update_all` and `delete_all` doesn't work due to missing
`apply_join_dependency`. It should be applied to work consistently.
Fixes #28863.
|
|
|
|
|
|
|
| |
Class level `update` and `destroy` are using `find` in the internal, so
it will raise `RecordNotFound` if given ids cannot find an object even
though the method already affect (update or destroy) to any objects.
These methods should return affected objects even in that case.
|
|
|
|
|
|
|
| |
affected by scoping (#29997)
I tried to change the expectation in #29976, but it is expected behavior
at least for now. So I added the test cases to prevent anyone change the
expectation.
|
|\ |
|
| | |
|
| |
| |
| |
| |
| | |
`self.class.delete` is delegated to `all` and `all` is affected by
scoping. It should use `unscoped` to not be affected by that.
|
| |
| |
| |
| |
| | |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
| |
Creating a new class for widgets was causing failing tests because it
clashed with other widget classes. This test does not need to create its
own class, so I changed it to an existing class.
```
ARCONN=mysql2 bin/test --seed 25364 test/cases/*test.rb -n \
"/^(?:PrimaryKeyIntegerTest#(?:test_primary_key_with_serial_integer_are_automatically_numbered)|PersistenceTest::SaveTest#(?:test_save_touch_false))$/"
```
|
|
|
|
| |
\Z was a mistake of \z. Replace \Z to \z to prevent newly \Z added.
|
|
|
|
|
| |
Supports the `touch` option from update_counters.
The default behavior is not to update timestamp columns.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- If the attribute is not changed, then update_attribute does not run
SQL query, this effectively means that no change was made to the
attribute.
- This change was made in https://github.com/rails/rails/commit/0fcd4cf5
to avoid a SQL call.
- But the change resulted into `nil` being returned when there was no
change in the attribute value.
- This commit corrects the behavior to return true if there is no change
in attribute value. This is same as previous behavior of Rails 4.2
plus benefit of no additional SQL call.
- Fixes #26593.
|
|
|
|
|
|
|
|
| |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
|
|
|
| |
Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
|
| |
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
| |
|
| |
|
|
|
|
|
| |
The previous commit changes the state of the class, and while we are
cleaning up the database, I forgot to clean up the class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I've added a redundant test for this under the attributes API as well,
as that also causes this bug to manifest through public API (and
demonstrates that calling `reset_column_information` on the child
classes would be insufficient)
Since children of a class should always share a table with their parent,
just reloading the schema from the cache should be sufficient here.
`reload_schema_from_cache` should probably become public and
`# :nodoc:`, but I'd rather avoid the git churn here.
Fixes #22057
|
| |
|
| |
|
| |
|
| |
|