Skip to content

Commit

Permalink
Makes supports_views? public in MysqlAdapter when defined as private …
Browse files Browse the repository at this point in the history
…in AR

 - Fixes issue with Rails 3 schema dump

[activewarehouse#5 state:fixed]
  • Loading branch information
rgabo authored and laripk committed Jun 2, 2011
1 parent 6eab507 commit 3bf63c9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/rails_sql_views/connection_adapters/mysql_adapter.rb
@@ -1,9 +1,13 @@
module RailsSqlViews
module ConnectionAdapters
module MysqlAdapter
REQUIRED_METHODS = [:supports_views?]

def self.included(base)
if base.private_method_defined?(:supports_views?)
base.send(:public, :supports_views?)
base.class_eval do
def self.method_added(method)
public(method) if REQUIRED_METHODS.include?(method) && !self.public_method_defined?(method)
end
end
end

Expand All @@ -18,7 +22,7 @@ def base_tables(name = nil) #:nodoc:
tables
end
alias nonview_tables base_tables

def views(name = nil) #:nodoc:
views = []
execute("SHOW FULL TABLES WHERE TABLE_TYPE='VIEW'").each{|row| views << row[0]}
Expand All @@ -28,7 +32,7 @@ def views(name = nil) #:nodoc:
def tables_with_views_included(name = nil)
nonview_tables(name) + views(name)
end

def structure_dump
structure = ""
base_tables.each do |table|
Expand All @@ -52,7 +56,7 @@ def view_select_statement(view, name=nil)
raise "No view called #{view} found"
end
end

private
def convert_statement(s)
s.gsub!(/.* AS (select .*)/, '\1')
Expand Down

0 comments on commit 3bf63c9

Please sign in to comment.