pretty_print removed

subqueries
Denis Knauf 2011-09-27 16:51:18 +02:00
parent db5bbcb93a
commit 93fd3eeda4
2 changed files with 1 additions and 6 deletions

View File

@ -250,7 +250,6 @@ class SmqlToAR
def build builder, table
@cols.each do |col, sub|
t = table+col.to_a
p t: t, sub: sub
builder.sub_join t, col, *sub[0..1]
sub[2..-1].each &it.build( builder, t)
end

View File

@ -79,24 +79,20 @@ class SmqlToAR
end
def sub_join table, col, model, query
pp [:sub_join, table, col. model, query]
prefix, base_table = "#{@prefix}_sub", col.col
join_ table, model, "(#{query.build( prefix, base_table).tap{|q| p :sub_join => q }.ar.to_sql})"
join_ table, model, "(#{query.build( prefix, base_table).ar.to_sql})"
end
def join_ table, model, query, pretable = nil
pp [:join_, table, model, query]
pretable ||= table[0...-1]
@table_model[ table] = model
premodel = @table_model[ pretable]
t = @table_alias[ table]
pt = quote_table_name @table_alias[ table[ 0...-1]]
pp premodel: premodel, table: table
refl = premodel.reflections[table.last]
case refl
when ActiveRecord::Reflection::ThroughReflection
through = refl.through_reflection
pp refl: refl
throughtable = table[0...-1]+[through.name.to_sym]
srctable = throughtable+[refl.source_reflection.name]
@table_model[ srctable] = model