mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
externalization now includes limits
This commit is contained in:
parent
41f80e494a
commit
191b2b7b7e
11 changed files with 28 additions and 6 deletions
15
doc/TODO
15
doc/TODO
|
@ -1,4 +1,19 @@
|
|||
todo:
|
||||
- joining with LIMIT is like aggregations!!
|
||||
|
||||
users.delete().where(
|
||||
addresses.c.user_id==
|
||||
select([users.c.id]).
|
||||
where(users.c.name=='jack')
|
||||
)
|
||||
|
||||
SELECT id, name,
|
||||
(select count(*) FROM addresses WHERE
|
||||
user_id=users.id)
|
||||
FROM users
|
||||
|
||||
SELECT users.*, (SELECT count(id) FROM addresses WHERE
|
||||
addresses.user_id=users.id) FROM users
|
||||
- and/or w/ predicates
|
||||
- blocks for all operations
|
||||
- result sets to attr correlation too
|
||||
|
|
|
@ -75,7 +75,7 @@ module Arel
|
|||
end
|
||||
|
||||
def find_correlate_in(relation)
|
||||
relation[self]
|
||||
relation[self] || self
|
||||
end
|
||||
|
||||
def descends_from?(other)
|
||||
|
|
|
@ -5,7 +5,7 @@ module Arel
|
|||
|
||||
def initialize(relation, *groupings, &block)
|
||||
@relation = relation
|
||||
@groupings = (groupings + (block_given?? [yield(self)] : [])).collect { |g| g.bind(relation) }
|
||||
@groupings = (groupings + (block_given?? [yield(relatoin)] : [])).collect { |g| g.bind(relation) }
|
||||
end
|
||||
|
||||
def externalizable?
|
||||
|
|
|
@ -31,6 +31,7 @@ module Arel
|
|||
end
|
||||
|
||||
def wheres
|
||||
# TESTME bind to self?
|
||||
relation1.externalize.wheres
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Arel
|
|||
|
||||
def initialize(relation, *orderings, &block)
|
||||
@relation = relation
|
||||
@orderings = (orderings + (block_given?? [yield(self)] : [])).collect { |o| o.bind(relation) }
|
||||
@orderings = (orderings + (block_given?? [yield(relation)] : [])).collect { |o| o.bind(relation) }
|
||||
end
|
||||
|
||||
# TESTME
|
||||
|
|
|
@ -5,7 +5,7 @@ module Arel
|
|||
|
||||
def initialize(relation, *projections, &block)
|
||||
@relation = relation
|
||||
@projections = (projections + (block_given?? [yield(self)] : [])).collect { |p| p.bind(relation) }
|
||||
@projections = (projections + (block_given?? [yield(relation)] : [])).collect { |p| p.bind(relation) }
|
||||
end
|
||||
|
||||
def attributes
|
||||
|
|
|
@ -4,7 +4,7 @@ module Arel
|
|||
deriving :==
|
||||
|
||||
def initialize(relation, *predicates, &block)
|
||||
predicate = block_given?? yield(self) : predicates.shift
|
||||
predicate = block_given?? yield(relation) : predicates.shift
|
||||
@relation = predicates.empty?? relation : Where.new(relation, *predicates)
|
||||
@predicate = predicate.bind(@relation)
|
||||
end
|
||||
|
|
|
@ -39,6 +39,10 @@ module Arel
|
|||
self
|
||||
end
|
||||
|
||||
def root
|
||||
self
|
||||
end
|
||||
|
||||
def christener
|
||||
@christener ||= Sql::Christener.new
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'arel/relations/utilities/compound'
|
||||
require 'arel/relations/utilities/recursion'
|
||||
require 'arel/relations/utilities/nil'
|
||||
require 'arel/relations/utilities/aggregation'
|
||||
require 'arel/relations/utilities/externalization'
|
||||
require 'arel/relations/utilities/recursion'
|
|
@ -16,6 +16,7 @@ module Arel
|
|||
@attributes ||= relation.attributes.collect(&:to_attribute).collect { |a| a.bind(self) }
|
||||
end
|
||||
|
||||
# REMOVEME
|
||||
def name
|
||||
relation.name + '_external'
|
||||
end
|
|
@ -16,6 +16,7 @@ module Arel
|
|||
end
|
||||
|
||||
describe '#to_sql' do
|
||||
# CLEANUP
|
||||
it '' do
|
||||
@relation1.join(@relation2.take(3)).on(@predicate).to_sql.should be_like("
|
||||
SELECT `users`.`id`, `users`.`name`, `photos_external`.`id`, `photos_external`.`user_id`, `photos_external`.`camera_id`
|
||||
|
|
Loading…
Reference in a new issue