1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

20 commits

Author SHA1 Message Date
Sean Griffin
b06f64c348 Remove Relation#bind_params
`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.
2015-01-27 16:10:03 -07:00
Sean Griffin
6c235dd958 Use an Attribute object to represent a bind value
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.
2015-01-27 12:07:06 -07:00
Sean Griffin
f916aa247b Remove all cases of manuallly wrapping Arel::Nodes::Quoted
This is no longer required now that we are injecting a type caster
object into the Arel table, with the exception of uniqueness
validations. Since it calls `ConnectionAdapter#type_cast`, the value has
already been cast for the database. We don't want Arel to attempt to
cast it further, so we need to continue wrapping it in a quoted node.
This can potentially go away when this validator is refactored to make
better use of `where` or the predicate builder.
2014-12-29 11:21:56 -07:00
Sean Griffin
de0cfd27a5 Inform Arel we don't need additional type casting in tests
Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
2014-12-26 17:50:20 -07:00
Arun Agrawal
9ae210ba09 Build fix when running in isolation
`Computer` class needs to be require

See #17217 for more details
2014-11-14 10:24:11 +01:00
Akira Matsuda
312e4cda78 Load :developers fixtures where expecting a Developer to be there 2014-09-05 09:50:49 +09:00
Akira Matsuda
f02c9726f1 "warning: assigned but unused variable" 2014-08-21 06:52:54 +09:00
Agis-
431f8e0119 Only merge scopes with zero arity in has_many through
with dynamic conditions.

Fixes #16128

This bug was introduced in c35e438620
so it's present from 4.1.2-rc1 and after.

c35e438620
merges any relation scopes passed as proc objects to the relation,
but does *not* take into account the arity of the lambda.

To reproduce: https://gist.github.com/Agis-/5f1f0d664d2cd08dfb9b
2014-08-20 08:25:58 +03:00
Rafael Mendonça França
ec6bb33209 Merge pull request #15078 from nbudin/fix_merger_filter_binds_comparison_master
Make filter_binds filter out symbols that are equal to strings

Conflicts:
	activerecord/CHANGELOG.md
2014-05-14 20:29:30 -03:00
Nat Budin
1d316ac1fd Make filter_binds filter out symbols that are equal to strings
ActiveRecord::Relation::Merger's filter_binds method does not filter out bind
variables when one of the attribute nodes has a string name, but the other has
a symbol name, even when those names are actually equal.

This can result in there being more bind variables than placeholders in the
generated SQL.  This is particularly an issue for PostgreSQL, where this is
treated as an error.

This patch changes the filter_binds method to make it convert both attribute
names to strings before comparing.
2014-05-14 16:18:42 -07:00
Yasuo Honda
317868d0bd Modify assert conditions not to be affected
by each database bind variable naming conventions
2014-05-12 08:47:06 +02:00
Aaron Patterson
1794ac0197 remove the bind substitution visitor. to_sql should never return bind values 2014-04-09 12:02:43 -07:00
Aaron Patterson
438fce75af Merge branch 'master' into set_binds
* master:
  rm dup code

Conflicts:
	activerecord/test/cases/relations_test.rb
2014-01-14 17:48:13 -08:00
Aaron Patterson
25bc0fbf51 where uses bind values so we don't need to manually create them 2014-01-14 10:43:53 -08:00
Aaron Patterson
f4d600865c remove test that does not apply anymore 2014-01-14 10:41:33 -08:00
Yves Senn
f83c9b10b4 use arel nodes to represent non-string order_values.
This fixes a bug when merging relations of different classes.

```
Given:
  Post.joins(:author).merge(Author.order(name: :desc)).to_sql

Before:
 SELECT "posts".* FROM "posts"
   INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
   ORDER BY "posts"."name" DESC

After:
 SELECT "posts".* FROM "posts"
   INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
   ORDER BY "authors"."name" DESC
```
2013-11-19 17:40:21 +01:00
Yasuo Honda
8e3474bede Address test_merging_where_relations failure by adding order("posts.id") 2013-11-18 02:10:56 +09:00
Yves Senn
c994e10862 fix weird Emacs auto indentation. [ci skip] 2013-11-13 17:56:44 +01:00
Yves Senn
f081edb1fe tests for merging Relations of different classes. 2013-11-13 17:41:26 +01:00
Yves Senn
742adce211 move Relation#merge tests into separate file. 2013-11-13 17:41:20 +01:00