Pratik Naik
0c2c893434
Revert "Style fixes"
...
This reverts commit 3c300b3121 .
2010-07-15 13:17:35 +01:00
wycats
3c300b3121
Style fixes
2010-07-14 17:33:07 -07:00
Pratik Naik
4a06489525
Style fixes
2010-07-14 16:50:26 +01:00
Ken Collins
0e9bc23c0e
Fix the #using_limitable_reflections? helper to work correctly by not examining the length of an array which contains false/true, hence always passing. [ #4869 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-07-08 22:34:34 +02:00
José Valim
af6ec607fa
No need to check if the attribute exists (this is the same behavior as in 2.3) [ #4994 state:resolved] and [ #5003 state:resolved]
2010-06-29 20:15:32 +02:00
Neeraj Singh
dabf74b495
array subtraction should be faster than iterating over all the elements
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-29 17:57:06 +02:00
José Valim
bd1666ad1d
Add scoping and unscoped as the syntax to replace the old with_scope and with_exclusive_scope. A few examples:
...
* with_scope now should be scoping:
Before:
Comment.with_scope(:find => { :conditions => { :post_id => 1 } }) do
Comment.first #=> SELECT * FROM comments WHERE post_id = 1
end
After:
Comment.where(:post_id => 1).scoping do
Comment.first #=> SELECT * FROM comments WHERE post_id = 1
end
* with_exclusive_scope now should be unscoped:
class Post < ActiveRecord::Base
default_scope :published => true
end
Post.all #=> SELECT * FROM posts WHERE published = true
Before:
Post.with_exclusive_scope do
Post.all #=> SELECT * FROM posts
end
After:
Post.unscoped do
Post.all #=> SELECT * FROM posts
end
Notice you can also use unscoped without a block and it will return an anonymous scope with default_scope values:
Post.unscoped.all #=> SELECT * FROM posts
2010-06-29 17:18:55 +02:00
Santiago Pastorino
093c4eedd0
Remove unneeded reject
2010-06-28 19:14:40 -07:00
Santiago Pastorino
8d9545389f
Refactor: metaprogramming here it's confusing and make use of tap
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-06-26 19:44:44 -07:00
Santiago Pastorino
64fee27a55
Removes useless flatten
2010-06-26 17:09:40 -07:00
José Valim
5b91c97763
Create a little bit less objects in ARel.
2010-06-26 22:37:24 +02:00
Santiago Pastorino
47134a04bb
blocks removed from all the ActiveRelation query_methods, extend method added instead
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-26 01:35:23 +02:00
Santiago Pastorino
65aa6a7db1
reorder method added to ActiveRelation
...
[#4972 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-26 00:59:12 +02:00
Neeraj Singh and Santiago Pastorino
0ebb5bf659
Support for multiple selects added
...
[#4841 state:committed]
2010-06-25 15:57:04 -03:00
Santiago Pastorino
3d8ccb9240
Makes a build_select for the select part of build_arel
2010-06-25 15:06:32 -03:00
Santiago Pastorino
82dc16b7d2
Metaprogramming not needed here
2010-06-25 15:06:32 -03:00
Emilio Tagua
4b5f417e63
Only yield block if given.
2010-06-24 13:17:24 -03:00
Emilio Tagua
2c203a9413
Remove block definitions in finder methods.
2010-06-24 13:07:39 -03:00
James Harton
d0df7f1196
Fix small bug where ActiveRecord::PredicateBuilder#build_from_hash didn't test for Arel::Relation as right hand value. [ #4917 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-22 18:05:27 +02:00
Emilio Tagua
7df105b1e6
Fix order method to accept relation attributes.
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-22 16:44:10 +02:00
Emilio Tagua
7b7cedcb8d
Don't waste time building relations if there are no values presents. [ #4860 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-21 01:10:33 +02:00
Emilio Tagua
e061212e86
Refactor build_arel: move joins out and simplify havings. [ #4860 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-20 00:37:55 +02:00
Pratik Naik
4b91daff13
Special treatement for Relation#select { with block }
2010-06-02 14:42:25 +01:00
Santiago Pastorino
0c37bf8f91
To allow proper fisting of stack trace
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-05-14 10:36:59 -07:00
Xavier Noria
7321a3a7d3
revises the rdoc of #average according to 5f3bd55, and realigns when clauses
2010-05-12 08:47:55 +02:00
Santiago Pastorino
5f3bd55726
type_cast_calculated_value refactor: value is never a Fixnum here. Fix test since SQLite returns Float.
...
[#4514 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-05-11 22:29:26 -07:00
Pratik Naik
f75a6fec29
Improve code from 231d7676f7
2010-05-09 12:33:25 +01:00
Josh Kalderimis
231d7676f7
corrected AR find_each and find_in_batches to raise when the user uses select but does not specify the primary key
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-05-09 13:14:47 +03:00
Santiago Pastorino
0b4211c88b
Here the intention was to assign to different objects
2010-05-08 23:29:51 +03:00
Santiago Pastorino
9aaef59356
Make find_or_create and find_or_initialize work mixing explicit parameters and a hash [ #4457 state:committed]
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-05-07 09:40:02 -07:00
Ernie Miller
902861a43a
Fix unintuitive behavior with multiple order and group clauses
...
[#4545 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-05-06 16:00:39 -07:00
Brian Lopez
7aad851c2e
Allow pre-casted values (other than nil) to pass through from calculations un-touched
...
[#4514 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-05-04 11:57:52 -07:00
Ernie Miller
e33d304975
Fix eager loading of associations causing table name collisions
...
[#4463 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-04-28 20:28:51 -07:00
Santiago Pastorino
961aa70e4a
Some require indifferent_access added
...
Signed-off-by: Xavier Noria <fxn@ubuntu.(none)>
2010-04-21 07:45:29 -07:00
Pratik Naik
2ff73039bd
Build PredicateBuilder object only when needed
2010-04-21 02:43:52 +01:00
Jeremy Kemper
6d29f9789e
Fix evals missing context
2010-04-10 22:39:10 -07:00
Jeremy Kemper
86dda361e2
Avoid deprecated String#to_a by using Array.wrap(...) instead of Array(...)
2010-04-10 22:37:36 -07:00
Carl Lerche
6e18fa0375
Raise a StatementInvalid error when trying to build a condition with hash keys that do not correspond to columns.
2010-04-03 09:22:00 -07:00
Pratik Naik
cfa283201e
Goodbye ActiveRecord::NamedScope::Scope
2010-04-02 18:57:46 +01:00
Pratik Naik
62fe16932c
Make Relation#first and Relation#last behave like named scope's
2010-04-02 18:57:46 +01:00
Pratik Naik
b77dd218ce
Add Relation extensions
2010-04-02 17:38:02 +01:00
Pratik Naik
bc7da9b77d
Consistency when using Relation constants
2010-04-02 17:38:02 +01:00
Emilio Tagua
7006aa1a85
Arel now handles ranges with excluded end.
2010-03-29 12:30:13 -03:00
Emilio Tagua
53ddbfc460
Warn scoped order and limit are ignored. [ #4123 state:resolved]
2010-03-29 11:30:06 -03:00
Xavier Noria
76f024ac8d
adds missing requires for Object#blank? and Object#present?
2010-03-28 14:15:02 +02:00
Emilio Tagua
fc2e25734a
Move methods from association to relation finder methods.
2010-03-25 15:47:06 -03:00
Emilio Tagua
90a4709601
Refactor relation merging to create just one relation and then assign values, instead of creating multiple relation objects.
2010-03-25 13:03:30 -03:00
Emilio Tagua
d289e15af9
From and lock should be defined to be consistent with other ivars. Limit and offset are always defined, no need to test that.
...
[#4253 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-03-22 11:48:39 -07:00
Aaron Patterson
587f468282
kill where / having method redefine warnings. [ #4225 state:resolved]
...
Signed-off-by: wycats <wycats@gmail.com >
2010-03-18 13:30:59 -07:00
Emilio Tagua
e08c153a08
Arel now fallback to using Arel::Attribute if the table/column doesn't exists.
...
[#4142 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2010-03-10 13:49:11 -08:00