aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2009-05-17 15:00:10 -0400
committerBryan Helmkamp <bryan@brynary.com>2009-05-17 15:00:10 -0400
commit9d77c08cf8a75636b058c1b85af52ef96e07cee5 (patch)
tree2268fb1875355c2b6a59fee26ef980adeafccb8a
parent2753d8f5768ce0b5f91a96cf81c6ba1d747aeea9 (diff)
downloadrails-9d77c08cf8a75636b058c1b85af52ef96e07cee5.tar.gz
rails-9d77c08cf8a75636b058c1b85af52ef96e07cee5.tar.bz2
rails-9d77c08cf8a75636b058c1b85af52ef96e07cee5.zip
made block stuff read nicer
Conflicts: doc/TODO
-rw-r--r--doc/TODO30
-rw-r--r--lib/arel/algebra/relations/operations/group.rb3
-rw-r--r--lib/arel/algebra/relations/operations/order.rb3
-rw-r--r--lib/arel/algebra/relations/operations/project.rb3
-rw-r--r--lib/arel/algebra/relations/utilities/compound.rb5
5 files changed, 26 insertions, 18 deletions
diff --git a/doc/TODO b/doc/TODO
index dfbf09de9d..d7e3bb280d 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,31 +1,24 @@
todo:
-- projection is by definition distincting
-- union/intersection
-- refactor adapter pattern
- result sets to attr correlation too
- result sets should be array relations
+- fix AR
- clean up block_given stuff
- reorganize sql tests
- audit unit coverage of algebra
-- break out adapters into sep modules
+- implement mnesia adapter
- data objects
- remove all explicit aliasing
- blocks for joins
-- implement in memory adapter
-- implement mnesia adapter
-- test ordering
-- joins become subselects in writes:
-users.delete().where(
- addresses.c.user_id==
- select([users.c.id]).
- where(users.c.name=='jack')
- )
- rename externalize to derived.
- and/or w/ predicates
+- scoped writes
+- refactor adapter pattern
+- break out adapters into sep modules
+- projection is by definition distincting?
+- union/intersection
+- test ordering
- cache expiry on write
- transactions
-- scoped writes
-- asc/desc for orderings
done:
- and/or w/ predicates
@@ -93,6 +86,7 @@ done:
- joining with LIMIT is like aggregations!!
- blocks for non-joins
- expressions should be class-based, and joins too, anything _sql should be renamed
+- implement in memory adapter
icebox:
- #bind in Attribute and Expression should be doing a descend?
@@ -107,3 +101,9 @@ icebox:
@reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" }
- lock
- SELECT suchandsuch FOR UPDATE
+- joins become subselects in writes:
+users.delete().where(
+ addresses.c.user_id==
+ select([users.c.id]).
+ where(users.c.name=='jack')
+ ) \ No newline at end of file
diff --git a/lib/arel/algebra/relations/operations/group.rb b/lib/arel/algebra/relations/operations/group.rb
index 04fd9fea62..879f2352c5 100644
--- a/lib/arel/algebra/relations/operations/group.rb
+++ b/lib/arel/algebra/relations/operations/group.rb
@@ -5,7 +5,8 @@ module Arel
def initialize(relation, *groupings, &block)
@relation = relation
- @groupings = (groupings + (block_given?? [yield(relatoin)] : [])).collect { |g| g.bind(relation) }
+ @groupings = (groupings + arguments_from_block(relation, &block)) \
+ .collect { |g| g.bind(relation) }
end
def externalizable?
diff --git a/lib/arel/algebra/relations/operations/order.rb b/lib/arel/algebra/relations/operations/order.rb
index eccd8bcda0..4e7133f5a8 100644
--- a/lib/arel/algebra/relations/operations/order.rb
+++ b/lib/arel/algebra/relations/operations/order.rb
@@ -5,7 +5,8 @@ module Arel
def initialize(relation, *orderings, &block)
@relation = relation
- @orderings = (orderings + (block_given?? [yield(relation)] : [])).collect { |o| o.bind(relation) }
+ @orderings = (orderings + arguments_from_block(relation, &block)) \
+ .collect { |o| o.bind(relation) }
end
# TESTME
diff --git a/lib/arel/algebra/relations/operations/project.rb b/lib/arel/algebra/relations/operations/project.rb
index 5507ea3163..223d320e22 100644
--- a/lib/arel/algebra/relations/operations/project.rb
+++ b/lib/arel/algebra/relations/operations/project.rb
@@ -5,7 +5,8 @@ module Arel
def initialize(relation, *projections, &block)
@relation = relation
- @projections = (projections + (block_given?? [yield(relation)] : [])).collect { |p| p.bind(relation) }
+ @projections = (projections + arguments_from_block(relation, &block)) \
+ .collect { |p| p.bind(relation) }
end
def attributes
diff --git a/lib/arel/algebra/relations/utilities/compound.rb b/lib/arel/algebra/relations/utilities/compound.rb
index 4d7cece812..99c3d02748 100644
--- a/lib/arel/algebra/relations/utilities/compound.rb
+++ b/lib/arel/algebra/relations/utilities/compound.rb
@@ -13,5 +13,10 @@ module Arel
end
OPERATION
end
+
+ private
+ def arguments_from_block(relation, &block)
+ block_given?? [yield(relation)] : []
+ end
end
end