| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| |
| | |
Fix unscope for less than
|
| |
| |
| |
| |
| |
| | |
Code such as the following will be corrected.
Developer.where(id: -Float::INFINITY...2).unscope(where: :id)
|
|\ \
| | |
| | |
| | | |
Raise ArgumentError when find_by receives no arguments
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
It fixes the strange error saying undefined method `take'.
```
RelationTest#test_find_by_without_arg_behaves_same_with_find_by({}):
NoMethodError: undefined method `take' for #<ActiveRecord::QueryMethods::WhereChain:0x007f9c55db1d68>
```
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Add a test-case to make sure that `create_table` with
a `foreign_key: true` and an adapter without foreign key support
does not blow up.
Motivated by #19794.
Originating from: https://github.com/rails/rails/commit/99a6f9e60ea55924b44f894a16f8de0162cf2702#commitcomment-10855210
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
When running Active Record MySQL test, this warning is printed in the
console:
warning: instance variable errno not initialized
It turns out that this is a warning from `mysql` gem in MySQL::Error
object. However, since the `mysql` gem is no longer maintained, and
there won't be a newer version, it make sense for us to just silence
this warning to make the output cleaner.
|
|\ \ \
| | | |
| | | |
| | | | |
Fix missing index when using timestamps with index
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The `index` option used with `timestamps` should be passed to both
`column` definitions for `created_at` and `updated_at` rather than just
the first.
This was happening because `Hash#delete` is used to extract the `index`
option passed to `timestamps`, thereby mutating the `options` hash
in-place. Now take a copy of the `options` before deleting so that the
original is not modified.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
In 1f006c an option was added called :class to allow passing anonymous
classes to association definitions. Since using :class instead of
:class_name is a fairly common typo even amongst experienced developers
this can result in hard to debug errors arising in raise_on_type_mismatch?
To fix this we're renaming the option from :class to :anonymous_class as
that is a more correct description of what the option is for. Since this
was an internal, undocumented option there is no need for a deprecation.
Fixes #19659
|
|\ \ \ \
| | | | |
| | | | | |
Raise StaleObjectError if touched object is stale and locking is enabled
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Fixes #19776
change test variable names and use more verbose on method
less verbose
use _read_attribute instead of send
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
To me it seems like this should only be the case if `autosave: true` is
set on the association. However, when implemented that way, it caused
issues with has many associations, where we have explicit tests stating
that child records are updated when the parent is new, even if autosave
is not set (presumably to update the parent id, but other changed
attributes would be persisted as well).
It's quirky, but at least we should be consistently quirky. This
constitutes a minor but subtle change in behavior, and therefore should
not be backported to 4.2 and earlier.
Fixes #19782
|
|\ \ \ \
| |/ / /
|/| | | |
Fix typos and improve the documentation
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This is a squash of the following commits, from first to last:
-
Fix minor, random things I’ve come across lately that individually
did not seem worth making a PR for, so I saved them for one commit.
One common error is using “it’s” (which is an abbreviation of “it is”)
when the possessive “its” should be used for indicating possession.
-
Changes include the name of a test, so remove the `[skip ci]` (thanks @senny).
-
Line wrap the changes at 80 chars and add one more doc fix.
-
Add a missing line wrap in the Contributing to Ruby on Rails Guide.
-
Line wrap the `TIP` section in the Contributing to Ruby on Rails Guide as well.
Rendering the guide locally with `bundle exec rake guides:generate` did
not show any change in on-screen formatting after adding the line wrap.
The HTML generated is (extra line added to illustrate where the line
wrap takes place):
<div class="info"><p>Please squash your commits into a single commit
when appropriate. This
simplifies future cherry picks and also keeps the git log
clean.</p></div>
-
Squash commits.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This reverts commit 524d40591eaa2f4d007409bfad386f6b107492eb, reversing
changes made to 34d3a6095100245283861ef480a54d0643bbee4c.
Reasoning behind the revert are in the PR discussion:
https://github.com/rails/rails/pull/19755
- This means that types can no longer cast to/from `Set`, and reasonably
work with `where` (we already have this problem for `array`/`json`
types on pg)
- This adds precedent for every other `Enumerable`, and we can't target
`Enumerable` directly.
- Calling `to_a` on a `Set` is reasonable.
|
|\ \ \
| | | |
| | | |
| | | | |
Add support for Set to Relation#where
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously `#where` used to treat `Set`objects as nil, but now it treats
them as an array:
set = Set.new([1, 2])
Author.where(:id => set)
# => SELECT "authors".* FROM "authors" WHERE "authors"."id" IN (1, 2)
|
| | |
| | |
| | |
| | |
| | |
| | | |
We don't actually need to enumerate the possible types here any more;
that dates back to before e105e599e706780905d4c348394da989de3b200f, when
they were symbols, and indistinguishable from other options.
|
|/ /
| |
| |
| |
| |
| | |
`use_transactional_fixtures` was deprecated in favor of
`use_transactional_tests` in Rails 5.0. This removes one warning while
running test suite.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
[fixes #18606]
Make belongs_to use touch over touch_later when running the callbacks.
Add more tests and small method rename
Thanks Jeremy for the feedback.
|
|\ \ |
|
|/ / |
|
|\ \
| | |
| | |
| | | |
Add charset and collation options support for MySQL string and text columns.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
columns
Example:
create_table :foos do |t|
t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin'
t.text :text_ascii, charset: 'ascii'
end
|
|\ \ \
| | | |
| | | | |
Fix a regression introduced by removing unnecessary db call when replacing
|
| | | |
| | | |
| | | |
| | | | |
When replacing a has_many association with the same one, there is nothing to do with database but a setter method should still return the substituted value for backward compatibility.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
creating foreign key
test case for use singular table name if pluralize_table_names is setted as false while creating foreign key
refactor references foreign key addition tests
use singular table name while removing foreign key
merge foreign key singular table name methods
remove unnecessary drop table from test
|
|\ \ \
| | | |
| | | | |
Fix eager loading association using default_scope for finder methods.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
- Eager loading was not working for the default_scope (class method)
for 'find' & 'find_by' methods.
- Fixed these by adding a new check 'respond_to?(:default_scope)'.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`widgets` table is being created in `primary_keys_test.rb` for PostgreSQLAdapter, MysqlAdapter, Mysql2Adapter
and it makes test to fail earlier.
Before:
`bundle exec rake mysql2:test`
```
Finished in 127.287669s, 35.5258 runs/s, 97.8885 assertions/s.
1) Error:
PersistenceTest::SaveTest#test_save_touch_false:
ActiveModel::UnknownAttributeError: unknown attribute 'name' for #<Class:0x0000000a7d6ef0>.
/home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:36:in `rescue in _assign_attribute'
/home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:34:in `_assign_attribute'
/home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes'
/home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:39:in `each'
/home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:39:in `_assign_attributes'
/home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `_assign_attributes'
/home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:33:in `assign_attributes'
/home/kd/projects/kd-rails/activerecord/lib/active_record/core.rb:293:in `initialize'
/home/kd/projects/kd-rails/activerecord/lib/active_record/inheritance.rb:61:in `new'
/home/kd/projects/kd-rails/activerecord/lib/active_record/inheritance.rb:61:in `new'
/home/kd/projects/kd-rails/activerecord/lib/active_record/persistence.rb:50:in `create!'
/home/kd/projects/kd-rails/activerecord/test/cases/persistence_test.rb:913:in `test_save_touch_false'
4522 runs, 12460 assertions, 0 failures, 1 errors, 4 skips
```
After:
`bundle exec rake mysql2:test`
```
Finished in 135.785086s, 33.3026 runs/s, 91.7774 assertions/s.
4522 runs, 12462 assertions, 0 failures, 0 errors, 4 skips
```
|
| |/
|/| |
|
|\ \
| | |
| | |
| | |
| | | |
Merges 1d8d5a74b81b8aab1f5e6d233d509a92525ed4e1. The pull request as a
whole is quite large, and I'm reviewing the smaller pieces individually.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The type map was introduced in aafee23, but wasn't properly filled.
This mainly adjusts many locations, that expected strings instead of
integers or boolean.
add_pg_decoders is moved after setup of the StatementPool, because
execute_and_clear could potentially make use of it.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
When set to an integer, a warning will be logged whenever a result set
larger than the specified size is returned by a query. Fixes #16463
The warning is outputed a module which is prepended in an initializer,
so there will be no performance impact if
`config.active_record.warn_on_records_fetched_greater_than` is not set.
|
| |
| |
| |
| | |
Avoid loading user's psqlrc when loading test structure
|
|\ \
| | |
| | |
| | |
| | |
| | | |
pinglamb/fix-referencing-wrong-alias-when-joining-tables-of-has-many-through-association
Fix referencing wrong aliases while joining tables of has many through association
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
association
While joining table of has_many :through association, ActiveRecord will
use the actual table name instead of through-join alias. It results with
a wrong SQL and exception is raised. This only happens when calculation
methods like #count is called.
This issue is affecting Rails 4.1.x and 4.2.x as well.
|
|\ \ \
| | | |
| | | | |
PostgreSQL, Add test case for "Infinity" string assignment to float columns
|
| |/ /
| | |
| | |
| | | |
This is implemented in Type::Float, but not tested, so far.
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| | |
The subtype will (quite reasonably) ignore the possibility that it has
`changed_in_place?` by becoming nil.
Fixes #19467
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As described here https://github.com/rails/rails/issues/19420. When
using the Postgres BigInt[] field type the big int value was not being
translated into schema.rb. This caused the field to become just a
regular integer field when building off of schema.rb. This fix will
address this by delegating the limit from the subtype to the Array type.
https://github.com/rails/rails/issues/19420
|
| |
| |
| |
| |
| |
| |
| | |
Preserving RACK_ENV behavior.
This reverts commit 7bdc7635b885e473f6a577264fd8efad1c02174f, reversing
changes made to 45786be516e13d55a1fca9a4abaddd5781209103.
|
| |
| |
| |
| | |
Fixes #19389.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is a better test for 51660f0. It is testing that the SQL is the
same before and after the previously leaky scope is called. Before if
`hotel.drink_designers` was called first then `hotel.recipes` would
incorrectly get the scope applied. We want to be sure that the
polymorphic hm:t association is not leaking into or affecting the
SQL for the hm:t association on `Hotel`.
The reason I couldn't do this before was because there was an issue with
the SQL getting cached and wanted to resolve that later and then fix the
test to be better. Because of the caching, this test requires that
`Hotel.reflect_on_association(:recipes).clear_association_scope_cache`
be called after the first call to `hotel.recipes` to clear the
assocation scope chain and not interfere with the rest of the test.
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | | |
Reuse the CollectionAssociation#reader proxy cache if the foreign key is present from the start.
Conflicts:
activerecord/CHANGELOG.md
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
present from the start.
When a new record has the necessary information prior to save, we can
avoid busting the cache.
We could simply clear the @proxy on #reset or #reset_scope, but that
would clear the cache more often than necessary.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Fixes db:structure:dump when using schema_search_path and PostgreSQL
extensions.
Closes #17157.
|
| | | |
|