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

27 commits

Author SHA1 Message Date
Sean Griffin
b364cb1083 Look for Enumerable rather than Array in predicates
It's not quite duck typed, but it will allow us to pass in our own
objects with additional logic (like type casting).
2014-11-02 12:00:04 -07:00
Sean Griffin
7db0e4accf Dry up building quoted nodes in predication
Given that we are going to remove casting from Arel in the near future,
having a single place nodes in predications will help.
2014-10-27 16:58:05 -06:00
Sean Griffin
f8d85cf24b Deprecate passing ranges to #in and #not_in
The goal of these methods should be to generate in nodes, not handle
every possible permutation of more than one value. The `#between` and
`#not_between` methods have been extracted, which better represent the
semantics of handling ranges in SQL.
2014-10-25 07:38:56 -05:00
Sean Griffin
df5723dfbe Refactor #in and #not_in
These methods duplicate a lot of logic from the other predications. We
can just use those methods directly, and only build nodes with the same
name in our method directly. We've already had one bug that came from
building nodes directly, rather than using the proper predicate.
2014-10-25 07:24:18 -05:00
Sean Griffin
51f48f0ed9 #not_in with a range should respect proper precedence
Currently, doing

```ruby
relation[:id].not_eq(4).and(relation[:id].not_in(1..3))
```

will generate

```sql
"id" != 4 AND "id" < 1 OR "id" > 3
```

Which would incorrectly include records with an id of 4, as the OR
statement has higher precidence than the AND statement. The `or`
method on `Node` properly groups the statement in parenthesis.
2014-10-24 09:01:39 -05:00
Tamir Duberstein
fef9ce493e {Matches,DoesNotMatch} support the ESCAPE clause 2014-09-25 13:30:03 -07:00
bigxiang
d27bfef96a Fix lt & lteq don't accept most of values. 2014-08-23 21:01:12 +08:00
Noah Lindner
493cc80fd5 Cleaned up some edge cases with infinity, the logic seems more intuitive now 2014-06-01 15:57:45 -07:00
Aaron Patterson
6d47c4cae5 build quoted nodes in factory methods 2014-03-24 17:18:56 -07:00
Aaron Patterson
d38352ef9e build quoted strings 2014-03-24 16:50:34 -07:00
Aaron Patterson
93d72131bc add the casting node to the AST at build time
If we add the casting node to the ast at build time, then we can avoid
doing the lookup at visit time.
2014-03-24 16:26:09 -07:00
Tim Pope
0df9ab8442 Support Float::INFINITY in ranges 2013-02-19 12:37:13 -05:00
Daniel Cadenas
11f929b5c4 Add nodes for boolean constants
This is useful for dynamically created predicates e.g:

expr1 = table.create_false
expr2 = table.create_false

expr1 = create_a_predicate() if some_condition
expr2 = create_another_predicate() if some_other_condition

table.where(expr1.and(expr2))
2011-08-03 20:50:03 -03:00
Ernie Miller
7361b6cbd5 Move #as to AliasPredication, stop overriding Function's #as. 2011-04-29 11:13:41 -07:00
Aaron Patterson
d09a882329 Revert "Merged pull request #40 from gmile/master."
This reverts commit 490d6f98f8, reversing
changes made to dd07005dce.
2011-04-29 10:26:53 -07:00
Aaron Patterson
490d6f98f8 Merged pull request #40 from gmile/master.
Passing nil in array generates improper SQL
2011-04-29 10:05:40 -07:00
Arthur Taylor
85882d1b26 Add support for ordering on expressions
Conflicts:

	lib/arel.rb
	lib/arel/attributes/attribute.rb
	lib/arel/nodes/infix_operation.rb
	lib/arel/nodes/named_function.rb

Conflicts:

	lib/arel.rb
	lib/arel/attributes/attribute.rb
2011-04-28 10:11:50 +02:00
Ernie Miller
3e3d4d1979 Improve performance of grouping_any/grouping_all 2011-04-19 00:20:29 +08:00
gmile
fe5719fea5 Generate more sqlish queue.
Now, instead of the following SQL code:
  some_field IN (1, 2, NULL)

Arel will generate the proper one:
  some_field IN (1, 2) OR IS NULL
2011-03-24 22:12:48 +02:00
Ernie Miller
05887fc406 Make as factory method convert alias name to SqlLiteral 2011-03-12 10:59:03 +08:00
Ernie Miller
3d21dabaa6 Fix modification of input on *_any/*_all predications 2011-02-08 06:33:38 -05:00
Aaron Patterson
6be1a71464 stop using deprecated AND usage 2010-12-09 14:52:11 -08:00
Aaron Patterson
b9d2cd9788 refactoring where, fixing subselect 2010-12-07 10:46:30 -08:00
Sven Fuchs
1135c2c088 implementation for passing a subquery to #in and #not_in 2010-12-07 10:05:42 +01:00
Aaron Patterson
6667cfb995 adding an AS node 2010-11-23 18:22:42 -08:00
Rolf Timmermans
9244e2ddbd Fixed Ruby 1.8 performance regression for Nodes::In and Nodes::NotIn queries with very wide ranges that was caused by using Range#min and Range#max rather than Range#begin and Range#end. Ruby 1.8 uses Enumerable#min and Enumerable#max in Ranges, which calls to_a internally. It is not necessary to enumerate the range in order to construct the predicates. At the same time, an off-by-one error (failing test) with exclusive-end Ranges in Nodes::NotIn queries was fixed. 2010-11-18 00:37:16 +08:00
Ernie Miller
01e7ceef45 Refactor predication methods to be available to SqlLiterals as well. 2010-10-27 22:34:04 +08:00