File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
lib/spectacles/schema_statements Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,12 @@ module Mysql2Adapter
55
66 def views ( name = nil ) # :nodoc:
77 result = execute ( "SHOW FULL TABLES WHERE TABLE_TYPE='VIEW'" )
8-
9- rows_from ( result ) . map ( &:first )
8+ values_from ( result ) . map ( &:first )
109 end
1110
1211 def view_build_query ( view , name = nil )
1312 result = execute ( "SHOW CREATE VIEW #{ view } " , name )
14- algorithm_string = rows_from ( result ) . first [ 1 ]
13+ algorithm_string = values_from ( result ) . first [ 1 ]
1514
1615 algorithm_string . gsub ( /CREATE .*? (AS)+/i , "" )
1716 rescue ActiveRecord ::StatementInvalid => e
@@ -20,8 +19,8 @@ def view_build_query(view, name = nil)
2019
2120 private
2221
23- def rows_from ( result )
24- result . respond_to? ( :rows ) ? result . rows : result
22+ def values_from ( result )
23+ result . first . respond_to? ( :values ) ? result . map ( & :values ) : result
2524 end
2625 end
2726 end
Original file line number Diff line number Diff line change @@ -17,12 +17,18 @@ def self.execute(query)
1717 describe "ActiveRecord::SchemaDumper#dump" do
1818 before ( :each ) do
1919 ActiveRecord ::Base . connection . drop_view ( :new_product_users )
20+ ActiveRecord ::Base . connection . drop_view ( :other_product_users )
2021
2122 ActiveRecord ::Base . connection . create_view ( :new_product_users ) do
2223 "SELECT name AS product_name, first_name AS username FROM
2324 products JOIN users ON users.id = products.user_id"
2425 end
2526
27+ ActiveRecord ::Base . connection . create_view ( :other_product_users ) do
28+ "SELECT name AS product_name, first_name AS username FROM
29+ products JOIN users ON users.id = products.user_id"
30+ end
31+
2632 if ActiveRecord ::Base . connection . supports_materialized_views?
2733 ActiveRecord ::Base . connection . drop_materialized_view ( :materialized_product_users )
2834 ActiveRecord ::Base . connection . drop_materialized_view ( :empty_materialized_product_users )
You can’t perform that action at this time.
0 commit comments