| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
mtsmfm/disable-referential-integrity-without-superuser-privileges"
This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing
changes made to 5c40239d3104543e70508360d27584a3e4dc5baf.
Reason: Broke the isolated tests.
https://travis-ci.org/rails/rails/builds/188721346
|
|\
| |
| | |
Fix typo s/permited/permitted/
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
```
% git grep -n permited
actionview/test/template/url_helper_test.rb:238: def test_button_to_with_permited_strong_params
actionview/test/template/url_helper_test.rb:245: def test_button_to_with_unpermited_strong_params
activerecord/test/cases/relations_test.rb:1620: def test_update_on_relation_passing_active_record_object_is_not_permited
```
|
|\ \
| |/
|/|
| |
| | |
mtsmfm/disable-referential-integrity-without-superuser-privileges
Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser privileges
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
privileges
ref: 72c1557254
- We must use `authors` fixture with `author_addresses` because of its foreign key constraint.
- Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently if `CollectionProxy` has more than one new record,
`CollectionProxy#uniq` result is incorrect.
And `CollectionProxy#uniq` was aliased to `distinct` in a1bb6c8b06db.
But the `uniq` method and the `SELECT DISTINCT` method are different
methods. The doc in `CollectionProxy` is for the `SELECT DISTINCT`
method, not for the `uniq` method.
Therefore, reverting the alias in `CollectionProxy` to fix the
inconsistency and to have the both methods.
|
| |
|
| |
|
|
|
|
|
|
| |
assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message
assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
|
|\
| |
| |
| | |
Fix does_not_support_reverse? to find sql functions with commas in nested brackets
|
| |
| |
| |
| | |
brackets
|
| |
| |
| |
| |
| |
| |
| |
| | |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
| | |
|
| | |
|
| | |
|
| | |
|
|/
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|\
| |
| | |
Forward ActiveRecord::Relation#count to Enumerable#count if block given
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
| |
In 5.0 we use bind parameters for limit and offset, while in 4.2 we used
the values directly. The code as it was written assumed that limit and
offset worked as `LIMIT ? OFFSET ?`. Both Oracle and SQL Server have a
different syntax, where the offset is stated before the limit. We
delegate this behavior to the connection adapter so that these adapters
are able to determine how the bind parameters are flattened based on
what order their specification has the various clauses appear.
Fixes #24775
|
|\
| |
| | |
Add test cases about MySQL ORDER BY FIELD()
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Add assertions to MySQL `ORDER BY FIELD()` with empty data.
These tests examine to sanitize `ORDER BY FIELD()` with empty data
appropriately.
```ruby
Tag.order(['field(id, ?)', []]).to_sql
# => SELECT "tags".* FROM "tags" ORDER BY field(id, NULL)
Tag.order(['field(id, ?)', nil]).to_sql
# => SELECT "tags".* FROM "tags" ORDER BY field(id, NULL)
```
|
|/
|
|
|
|
| |
Clarifying this separation and enforcing relation immutability is the
culmination of the previous efforts to remove the mutator method
delegations.
|
|
|
|
|
| |
Raises when #reverse_order can not process SQL order instead of making
invalid SQL before this patch
|
|\
| |
| |
| | |
Fix #first(limit) to take advantage of #loaded? records if available
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I realized that `first(2)`, etc. was unnecessarily querying for the
records when they were already preloaded. This was because
`find_nth_with_limit` can not know which `@records` to return because
it conflates the `offset` and `index` into a single variable, while
the `@records` only needs the `index` itself to select the proper
record.
Because `find_nth` and `find_nth_with_limit` are public methods, I
instead introduced a private method `find_nth_with_limit_and_offset`
which is called internally and handles the `loaded?` checking.
Once the `offset` argument is removed from `find_nth`,
`find_nth_with_limit_and_offset` can be collapsed into
`find_nth_with_limit`, with `offset` always equal to `offset_index`.
|
|
|
|
|
|
|
|
|
| |
This reverts commit 6d5b1fdf55611de2a1071c37544933bb588ae88e.
`eager_load` and `references` can include hashes, which won't match up
with `references`
A test case has been added to demonstrate the problem
|
|\
| |
| |
| | |
Support SQL sanitization in AR::QueryMethods#order
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Add support for sanitizing arrays in SQL ORDER clauses.
This is useful when using MySQL `ORDER BY FIELD()` to return records in
a predetermined way.
```ruby
Tag.order(['field(id, ?', [1,3,2]].to_sql
# => SELECT "tags".* FROM "tags" ORDER BY field(id, 1,3,2)
```
Prior to this, developers must be careful to sanitize `#order` arguments
themselves.
|
| |
| |
| |
| |
| |
| |
| |
| | |
When passing an instance of `ActiveRecord::Base` to `#update`, it would
internally call `#find`, resulting in a misleading deprecation warning.
This change gives this deprecated use of `#update` its own, meaningful
warning.
|
| |
| |
| |
| | |
See 7dcfc25e7c52682a4343c2ba7188a69e7c06c936 for more details
|
| |
| |
| |
| |
| |
| | |
Fixes #21488
[Sean Griffin & johanlunds]
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When preload is used in a default scope the preload_values were
returning nested arrays and causing the preloader to fail because it
doesn't know how to deal with nested arrays. So before calling preload!
we need to splat the arguments.
This is not needed to includes because it flatten its arguments.
|
|\ \
| | |
| | | |
Properly append preload / includes args on Merger
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Couldn't find other way to get the association name from a given class
other than looping through `reflect_on_all_associations` reflections ..
Noticed this one while looking at this example:
```ruby
class Product < ActiveRecord::Base
has_many :variants
has_many :translations
end
class Translation < ActiveRecord::Base
belongs_to :product
end
class Variant < ActiveRecord::Base
belongs_to :product
end
class BugTest < Minitest::Test
def test_merge_stuff
product = Product.create! name: 'huhu'
variant = Variant.create! product_id: product.id
Translation.create! locale: 'en', product_id: product.id
product_relation = Product.all
.preload(:translations)
.joins(:translations)
.merge(Translation.where(locale: 'en'))
.where(name: 'huhu')
assert_equal variant, Variant.joins(:product).merge(product_relation).first
end
end
```
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
See #9683 for the reasons we switched to `distinct`.
Here is the discussion that triggered the actual deprecation #20198.
`uniq`, `uniq!` and `uniq_value` are still around.
They will be removed in the next minor release after Rails 5.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
```
|
| |
| |
| |
| | |
Fix appending table_name to select and group when used with subquery (fr...
|
| |
| |
| |
| |
| |
| |
| |
| | |
Use SQL COUNT and LIMIT 1 queries for none? and one? methods if no block or limit is given,
instead of loading the entire collection to memory. The any? and many? methods already
follow this behavior.
[Eugene Gilburg & Rafael Mendonça França]
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
`bound_attributes` is now used universally across the board, removing
the need for the conversion layer. These changes are mostly mechanical,
with the exception of the log subscriber. Additional, we had to
implement `hash` on the attribute objects, so they could be used as a
key for query caching.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The column is primarily used for type casting, which we're trying to
separate from the idea of a column. Since what we really need is the
combination of a name, type, and value, let's use the object that we
already have to represent that concept, rather than this tuple. No
consumers of the bind values have been changed, only the producers
(outside of tests which care too much about internals). This is
*finally* possible since the bind values are now produced from a
reasonable number of lcoations.
|
| | |
|