Class: NoSE::Statement
- Defined in:
- lib/nose/indexes.rb,
lib/nose/statements.rb
Overview
A CQL statement and its associated data
Direct Known Subclasses
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#entity ⇒ Object
readonly
Returns the value of attribute entity.
-
#eq_fields ⇒ Object
readonly
Returns the value of attribute eq_fields.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#key_path ⇒ Object
readonly
Returns the value of attribute key_path.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#range_field ⇒ Object
readonly
Returns the value of attribute range_field.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
-
.parse(text, model, group: nil, label: nil, support: false) ⇒ Object
Parse either a query or an update.
Instance Method Summary collapse
-
#initialize(params, text, group: nil, label: nil) ⇒ Statement
constructor
A new instance of Statement.
-
#materialize_view ⇒ Index
Construct an index which acts as a materialized view for a query.
-
#read_only? ⇒ Boolean
Specifies if the statement modifies any data.
-
#requires_delete?(_index) ⇒ Boolean
Specifies if the statement will require data to be deleted.
-
#requires_insert?(_index) ⇒ Boolean
Specifies if the statement will require data to be inserted.
-
#to_color ⇒ Object
:nocov:.
Constructor Details
#initialize(params, text, group: nil, label: nil) ⇒ Statement
Returns a new instance of Statement.
399 400 401 402 403 404 405 406 407 408 |
# File 'lib/nose/statements.rb', line 399 def initialize(params, text, group: nil, label: nil) @entity = params[:entity] @key_path = params[:key_path] @longest_entity_path = @key_path.entities @graph = params[:graph] @model = params[:model] @text = text @group = group @label = label end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def comment @comment end |
#entity ⇒ Object (readonly)
Returns the value of attribute entity.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def entity @entity end |
#eq_fields ⇒ Object (readonly)
Returns the value of attribute eq_fields.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def eq_fields @eq_fields end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def graph @graph end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def group @group end |
#key_path ⇒ Object (readonly)
Returns the value of attribute key_path.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def key_path @key_path end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def label @label end |
#range_field ⇒ Object (readonly)
Returns the value of attribute range_field.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def range_field @range_field end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
276 277 278 |
# File 'lib/nose/statements.rb', line 276 def text @text end |
Class Method Details
.parse(text, model, group: nil, label: nil, support: false) ⇒ Object
Parse either a query or an update
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/nose/statements.rb', line 280 def self.parse(text, model, group: nil, label: nil, support: false) klass = statement_class text, support tree = parse_tree text, klass # Ensure we have a valid path in the parse tree tree[:path] ||= [tree[:entity]] fail InvalidStatementException, "FROM clause must start with #{tree[:entity]}" \ if tree[:entity] && tree[:path].first != tree[:entity] params = statement_parameters tree, model statement = klass.parse tree, params, text, group: group, label: label statement.instance_variable_set :@comment, tree[:comment].to_s # Support queries need to populate extra values before finalizing unless support statement.hash statement.freeze end statement end |
Instance Method Details
#materialize_view ⇒ Index
Construct an index which acts as a materialized view for a query
201 202 203 204 205 206 207 |
# File 'lib/nose/indexes.rb', line 201 def materialize_view eq = materialized_view_eq join_order.first order_fields = materialized_view_order(join_order.first) - eq Index.new(eq, order_fields, all_fields - (@eq_fields + @order).to_set, @graph) end |
#read_only? ⇒ Boolean
Specifies if the statement modifies any data
412 413 414 |
# File 'lib/nose/statements.rb', line 412 def read_only? false end |
#requires_delete?(_index) ⇒ Boolean
Specifies if the statement will require data to be deleted
424 425 426 |
# File 'lib/nose/statements.rb', line 424 def requires_delete?(_index) false end |
#requires_insert?(_index) ⇒ Boolean
Specifies if the statement will require data to be inserted
418 419 420 |
# File 'lib/nose/statements.rb', line 418 def requires_insert?(_index) false end |
#to_color ⇒ Object
:nocov:
429 430 431 |
# File 'lib/nose/statements.rb', line 429 def to_color "#{@text} [magenta]#{@longest_entity_path.map(&:name).join ', '}[/]" end |