lib/conceptql/nodes/define.rb in conceptql-0.1.0 vs lib/conceptql/nodes/define.rb in conceptql-0.1.1
- old
+ new
@@ -44,16 +44,24 @@
def query(db)
# We'll wrap the creation of the temp table in memoization
# That way we can call #query multiple times, but only suffer the
# cost of creating the temp table just once
@_run ||= begin
- db.create_table!(table_name, temp: true, as: stream.evaluate(db))
+ if tree.opts[:sql_only]
+ db.create_table!(table_name, temp: true, as: fake_row(db))
+ else
+ db.create_table!(table_name, temp: true, as: stream.evaluate(db))
+ end
true
end
db.from(table_name)
end
+ def columns(query, local_type)
+ COLUMNS
+ end
+
def types
stream.types
end
def sql(db)
@@ -67,9 +75,21 @@
private
def table_name
@table_name ||= namify(arguments.first)
+ end
+
+ def fake_row(db)
+ db
+ .select(Sequel.cast(nil, Bignum).as(:person_id))
+ .select_append(Sequel.cast(nil, Bignum).as(:criterion_id))
+ .select_append(Sequel.cast(nil, String).as(:criterion_type))
+ .select_append(Sequel.cast(nil, Date).as(:start_date))
+ .select_append(Sequel.cast(nil, Date).as(:end_date))
+ .select_append(Sequel.cast(nil, Bignum).as(:value_as_numeric))
+ .select_append(Sequel.cast(nil, String).as(:value_as_string))
+ .select_append(Sequel.cast(nil, Bignum).as(:value_as_concept_id))
end
end
end
end