Commit Graph

134 Commits

Author SHA1 Message Date
Neeraj Singh
4e40f00565 minor formatting fixes 2010-08-25 07:39:47 -04:00
Aaron Patterson
5931a1dbd3 sql literal strings should be marked as sql literal strings 2010-08-23 13:57:22 -07:00
Aaron Patterson
a70248c3d8 we should wrap strings as sql literals 2010-08-19 10:35:09 -07:00
Aaron Patterson
e4f424d577 refactoring to remove duplicate logic 2010-08-18 12:10:48 -07:00
Aaron Patterson
93f335b6fb call to present? is not necessary 2010-08-18 11:51:59 -07:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
Prem Sichanugrist
a7eb8d97a4 Removing most of the symbol to proc usage in Active Record
This will hopefully make Active Record run a bit more faster.
2010-08-13 16:24:49 -07:00
Aaron Patterson
b9eec677c4 avoid direct use of arel constants 2010-08-13 13:33:08 -07:00
Neeraj Singh
6ed1ba472e Ensure we can nest include calls [#5285 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:10:58 -03:00
Aaron Patterson
7de03ec765 subtracting blank strings is slightly faster than blank? 2010-08-11 15:45:06 -07:00
Aaron Patterson
06dc884454 avoid multiple hash lookups 2010-08-11 15:00:08 -07:00
Aaron Patterson
0f502ab88f avoiding tap saves us time 2010-08-11 11:44:08 -07:00
Aaron Patterson
2b8f24998e unless Array#empty? is faster than if Array#present? 2010-08-11 11:44:04 -07:00
Aaron Patterson
3c11e92616 stop using private methods 2010-08-11 11:43:57 -07:00
Xavier Noria
4f7565c4de adds missing requires for Object#try 2010-08-09 15:25:21 +02:00
Aaron Patterson
117b096d0a avoid passing lists of lists to the group clause 2010-08-04 16:24:01 -07:00
Aaron Patterson
ec736dff7b call to_a since we are not passing anything to all() 2010-08-04 14:22:29 -07:00
Aaron Patterson
30abb01d07 fisting indentation 2010-08-04 14:11:30 -07:00
Aaron Patterson
cff7f53fbc do not pass AR objects to ARel 2010-08-04 08:44:53 -07:00
Aaron Patterson
6d6ed55324 avoid passing AR::Base objects to Arel when we can 2010-08-03 17:58:56 -07:00
Aaron Patterson
41c1aa607d order query is already a string, no need to to_s 2010-08-03 09:16:01 -07:00
Neeraj Singh
1ce40ca562 ensuring that description does not exceed 100 columns 2010-08-02 12:25:26 -04:00
Aaron Patterson
834e304b22 reverting where() functionality, adding a test 2010-07-30 14:12:01 -07:00
Aaron Patterson
ecfb252e7a fewer method calls, using faster methods when possible 2010-07-30 14:05:26 -07:00
Aaron Patterson
d1c53a9ad2 reducing function calls and using faster methods for testing 2010-07-30 13:38:09 -07:00
Aaron Patterson
a7a6a2ff46 got the ternary backwards. somehow the sqlite tests passed! 2010-07-29 16:08:30 -07:00
Aaron Patterson
f171bc64a2 PERF: avoiding splat args and reducing function calls 2010-07-29 14:55:57 -07:00
Aaron Patterson
d69949ed0d Shouldn't have committed this! Revert "avoid calling to_sql twice"
This reverts commit 1c030a3c3c.
2010-07-28 17:03:52 -07:00
Aaron Patterson
1c030a3c3c avoid calling to_sql twice 2010-07-28 17:01:32 -07:00
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