Class: ConceptQL::Query
- Inherits:
-
Object
- Object
- ConceptQL::Query
- Defined in:
- lib/conceptql/query.rb
Instance Attribute Summary collapse
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
Instance Method Summary collapse
-
#execute ⇒ Object
To avoid a performance penalty, only execute the last SQL statement in an array of ConceptQL statements so that define’s “create_table” SQL isn’t executed twice.
-
#initialize(db, statement, tree = Tree.new) ⇒ Query
constructor
A new instance of Query.
- #queries ⇒ Object
- #query ⇒ Object
- #sql ⇒ Object
- #types ⇒ Object
Constructor Details
#initialize(db, statement, tree = Tree.new) ⇒ Query
Returns a new instance of Query.
7 8 9 10 11 |
# File 'lib/conceptql/query.rb', line 7 def initialize(db, statement, tree = Tree.new) @db = db @statement = statement @tree = tree end |
Instance Attribute Details
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
6 7 8 |
# File 'lib/conceptql/query.rb', line 6 def statement @statement end |
Instance Method Details
#execute ⇒ Object
To avoid a performance penalty, only execute the last SQL statement in an array of ConceptQL statements so that define’s “create_table” SQL isn’t executed twice
29 30 31 |
# File 'lib/conceptql/query.rb', line 29 def execute query.all end |
#queries ⇒ Object
13 14 15 |
# File 'lib/conceptql/query.rb', line 13 def queries build_query(db) end |
#query ⇒ Object
17 18 19 |
# File 'lib/conceptql/query.rb', line 17 def query queries.last end |
#sql ⇒ Object
21 22 23 24 |
# File 'lib/conceptql/query.rb', line 21 def sql tree.opts[:sql_only] = true nodes.map { |node| node.sql(db) }.join(";\n") + ';' end |
#types ⇒ Object
33 34 35 |
# File 'lib/conceptql/query.rb', line 33 def types tree.root(self).last.types end |