Class: Dbee::Providers::ActiveRecordProvider::ExpressionBuilder

Inherits:
Maker
  • Object
show all
Defined in:
lib/dbee/providers/active_record_provider/expression_builder.rb

Overview

This class can generate an Arel expression tree given a Dbee::Schema and Dbee::Query.

Defined Under Namespace

Classes: MissingConstraintError

Instance Method Summary collapse

Constructor Details

#initialize(schema, table_alias_maker, column_alias_maker) ⇒ ExpressionBuilder

Returns a new instance of ExpressionBuilder.



20
21
22
23
24
25
# File 'lib/dbee/providers/active_record_provider/expression_builder.rb', line 20

def initialize(schema, table_alias_maker, column_alias_maker)
  super(column_alias_maker)

  @schema            = schema
  @table_alias_maker = table_alias_maker
end

Instance Method Details

#to_sql(query) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/dbee/providers/active_record_provider/expression_builder.rb', line 27

def to_sql(query)
  reset_query_state
  build_query(query)

  return statement.project(select_maker.star(base_table)).to_sql if select_all

  statement.to_sql
end