Class: Scenic::Adapters::MySQL

Inherits:
Object
  • Object
show all
Defined in:
lib/scenic/adapters/my_sql.rb

Defined Under Namespace

Classes: FeatureNotSupportedError

Instance Method Summary collapse

Constructor Details

#initialize(connectable = ActiveRecord::Base) ⇒ MySQL

Returns a new instance of MySQL.



12
13
14
# File 'lib/scenic/adapters/my_sql.rb', line 12

def initialize(connectable = ActiveRecord::Base)
  @connectable = connectable
end

Instance Method Details

#create_materialized_view(*_) ⇒ Object



46
47
48
# File 'lib/scenic/adapters/my_sql.rb', line 46

def create_materialized_view(*_)
  raise FeatureNotSupportedError
end

#create_view(name, sql_definition) ⇒ Object



29
30
31
# File 'lib/scenic/adapters/my_sql.rb', line 29

def create_view(name, sql_definition)
  execute "CREATE VIEW #{quote_table_name(name)} AS #{sql_definition}"
end

#drop_materialized_view(*_) ⇒ Object



54
55
56
# File 'lib/scenic/adapters/my_sql.rb', line 54

def drop_materialized_view(*_)
  raise FeatureNotSupportedError
end

#drop_view(name) ⇒ Object



37
38
39
# File 'lib/scenic/adapters/my_sql.rb', line 37

def drop_view(name)
  execute "DROP VIEW #{quote_table_name(name)}"
end

#replace_view(name, sql_definition) ⇒ Object



33
34
35
# File 'lib/scenic/adapters/my_sql.rb', line 33

def replace_view(name, sql_definition)
  execute "CREATE OR REPLACE VIEW #{quote_table_name(name)} AS #{sql_definition}"
end

#update_materialized_view(*_) ⇒ Object



50
51
52
# File 'lib/scenic/adapters/my_sql.rb', line 50

def update_materialized_view(*_)
  raise FeatureNotSupportedError
end

#update_view(name, sql_definition) ⇒ Object



41
42
43
44
# File 'lib/scenic/adapters/my_sql.rb', line 41

def update_view(name, sql_definition)
  drop_view(name)
  create_view(name, sql_definition)
end

#viewsObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/scenic/adapters/my_sql.rb', line 16

def views
  Scenic::MySQLAdapter::Views.new(
    view_names.map do |name|
      Scenic::View.new(
        name: name,
        definition: view_definition(name),
        materialized: false
      )
    end,
    dependencies
  ).tsort
end