Class: Bmg::Sql::Relation

Inherits:
Object
  • Object
show all
Includes:
Relation
Defined in:
lib/bmg/sql/relation.rb

Direct Known Subclasses

Bmg::Sequel::Relation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Relation

#debug, empty, #empty?, new, #one, #one_or_nil, #to_csv, #to_json, #visit, #with_typecheck, #without_typecheck, #y_by_x, #ys_by_x

Methods included from Algebra

#allbut, #autosummarize, #autowrap, #constants, #extend, #group, #image, #join, #left_join, #matching, #materialize, #not_matching, #page, #project, #rename, #restrict, #spied, #summarize, #transform, #union, #unspied

Methods included from Algebra::Shortcuts

#image, #join, #left_join, #matching, #not_matching, #prefix, #rxmatch, #suffix

Constructor Details

#initialize(type, builder, expr) ⇒ Relation

Returns a new instance of Relation.



6
7
8
9
10
# File 'lib/bmg/sql/relation.rb', line 6

def initialize(type, builder, expr)
  @type = type
  @builder = builder
  @expr = expr
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



12
13
14
# File 'lib/bmg/sql/relation.rb', line 12

def type
  @type
end

Instance Method Details

#bind(binding) ⇒ Object



21
22
23
24
25
# File 'lib/bmg/sql/relation.rb', line 21

def bind(binding)
  expr = before_use(self.expr)
  expr = Processor::Bind.new(binding, builder).call(expr)
  _instance(type, builder, expr)
end

#deleteObject

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/bmg/sql/relation.rb', line 31

def delete
  raise NotImplementedError
end

#each(&bl) ⇒ Object

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/bmg/sql/relation.rb', line 27

def each(&bl)
  raise NotImplementedError
end

#insert(arg) ⇒ Object

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/bmg/sql/relation.rb', line 35

def insert(arg)
  raise NotImplementedError
end

#to_astObject



195
196
197
# File 'lib/bmg/sql/relation.rb', line 195

def to_ast
  [:sql, to_sql]
end

#to_sObject Also known as: inspect



199
200
201
# File 'lib/bmg/sql/relation.rb', line 199

def to_s
  "(sql #{to_sql})"
end

#to_sqlObject



191
192
193
# File 'lib/bmg/sql/relation.rb', line 191

def to_sql
  expr.to_sql("", Dialect.default)
end

#update(arg) ⇒ Object

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/bmg/sql/relation.rb', line 39

def update(arg)
  raise NotImplementedError
end