| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| |
| |
| | |
kamipo/fix_update_counters_of_multiple_records_with_touch
Fix update counters of multiple records with touch: true
|
| |
| |
| |
| |
| | |
`current_time_from_proper_timezone` and timestamp attributes methods was
pushed up to class method.
|
| |
| |
| |
| |
| |
| | |
to class method
Actually these methods don't need instantiation.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently does not work the following example in the doc:
```ruby
# For the Posts with id of 10 and 15, increment the comment_count by 1
# and update the updated_at value for each counter.
Post.update_counters [10, 15], comment_count: 1, touch: true
# Executes the following SQL:
# UPDATE posts
# SET comment_count = COALESCE(comment_count, 0) + 1,
# `updated_at` = '2016-10-13T09:59:23-05:00'
# WHERE id IN (10, 15)
```
|
|/
|
|
|
| |
b8f74860b61782e3b949ade3bb51bff40899e89b provided a nicer version of
`#test_structure_load` but the old version was not removed.
|
|
|
|
|
|
| |
* Rename update -> touch to remain consistent with the other docs
language of "touch"'ing.
* Remove the sentence that's repeated from just above and rephrase.
|
|\
| |
| | |
Dump schema cache for custom connection
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Today `rake db:schema:cache:dump` only supports dumping cache for a
single connection (`ActiveRecord::Base.connection`). This doesn't work
for apps with multiple databases.
This PR makes `DatabaseTasks` to provide an API for dumping schema cache
for any connection.
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
`touch_updates` calls `Time.now` via `current_time_from_proper_timezone`
so it is better to not invoke `touch_updates` if it is unnecessary.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* Refactor to use `touch_updates`
Ensures we only call `current_time_from_proper_timezone` from one place.
* Clarify touch default in tests.
Not interested in what happens when passed false but that
nothing passed means no touching.
* Backdate touched columns in tests.
We can't be sure a test progresses through time, so our
touching code may be working correctly but the test
itself is brittle.
Fix by backdating that's further in the past akin to
what the timestamps tests do:
https://github.com/rails/rails/blob/d753645d40e925973724e4c3a8617b654da90e41/activerecord/test/cases/timestamp_test.rb#L17
* Expand changelog entry.
Elaborate and show examples.
Closes #26995.
[ Jarred Trost & Kasper Timm Hansen ]
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As pointed out by @matthewd this change makes ImmutableString aware
of MysqlString's existence whereas previously MysqlString was only
overriding public API.
cc @kamipo
This reverts commit e632c2fa4cb60072a778ce95c952a0fa95e5b074, reversing
changes made to 334a7dcf107cd3ff1697163d331d289d6d65dcd7.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`timestamp_attributes_for_{create,update}` is defined as symbol but
always used as string with `to_s`. This allocates extra strings. To
avoid extra allocation, change the definitions from symbol to string.
```ruby
pp ObjectSpace::AllocationTracer.trace {
1_000.times { |i|
Post.create!
}
}
```
Before:
```
["~/rails/activerecord/lib/active_record/timestamp.rb", 121]=>[1002, 0, 750, 0, 1, 18528],
["~/rails/activerecord/lib/active_record/timestamp.rb", 105]=>[1002, 0, 750, 0, 1, 7720],
["~/rails/activerecord/lib/active_record/timestamp.rb", 101]=>[1002, 0, 750, 0, 1, 7720],
["~/rails/activerecord/lib/active_record/timestamp.rb", 109]=>[1002, 0, 750, 0, 1, 13896],
["~/rails/activerecord/lib/active_record/timestamp.rb", 61]=>[4008, 0, 3000, 0, 1, 30880],
```
After:
```
["~/rails/activerecord/lib/active_record/timestamp.rb", 120]=>[1000, 0, 756, 0, 1, 17184],
["~/rails/activerecord/lib/active_record/timestamp.rb", 104]=>[1000, 0, 756, 0, 1, 7160],
["~/rails/activerecord/lib/active_record/timestamp.rb", 100]=>[1000, 0, 756, 0, 1, 7160],
["~/rails/activerecord/lib/active_record/timestamp.rb", 108]=>[1000, 0, 756, 0, 1, 12888],
```
|
|\ \
| | |
| | | |
Extract `casted_true`/`casted_false` for `Type::ImmutableString`
|
| | |
| | |
| | |
| | |
| | |
| | | |
The only difference between `Type::ImmutableString` and its subclasses
is the representation of the casted booleans. Prefer extracting
`casted_true`/`casted_false` and override these by subclasses.
|
|/ /
| |
| |
| |
| | |
Simply we can do `target.pluck(reflection.association_primary_key)` if
`target` is loaded.
|
|/
|
|
|
| |
Currently schema dumper does not dump array subtype `precision` and
`scale` options. This commit fixes the issue.
|
|\
| |
| | |
Add a quote to an SQL insert statement of schema migration
|
| | |
|
| |
| |
| |
| |
| | |
Trim some needless words off the lines and format the code
sample like we'd write in the Rails source.
|
| |
| |
| |
| |
| | |
Marked as private in 2afe5a1 and doesn't seem worth it
to mention the module name here.
|
|\ \
| | |
| | |
| | |
| | | |
prathamesh-sonpatki/mark-one-more-constant-as-private
Mark :GeneratedAssociationMethods also as private_constant
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
- After https://github.com/rails/rails/commit/64e5b897ac944a05a33275e3828a3d4047a6b457,
only :GeneratedAssociationMethods was remaining to be marked as
private constant, so marked it as well.
- Before:
>> User.constants(false)
=> [:GeneratedAssociationMethods]
- After:
>> User.constants(false)
=> []
|
|/ /
| |
| |
| |
| |
| |
| |
| | |
Per https://www.timeanddate.com/counters/firstnewyear.html, it's already
2017 in a lot of places, so we should bump the Rails license years to
2017.
[ci skip]
|
| |
| |
| |
| | |
[ci skip]
|
| |
| |
| |
| | |
Closes #14640
|
| | |
|
| | |
|
| |
| |
| |
| | |
[ci skip]
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
provided.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|