mereghost-rails_sql_views 0.8.3 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,8 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
- require 'rake/rdoctask'
4
- require 'rake/packagetask'
5
- require 'rake/gempackagetask'
3
+ require 'rdoc/task'
4
+ require 'rubygems/package_task'
6
5
 
7
6
  require File.join(File.dirname(__FILE__), 'lib/rails_sql_views', 'version')
8
7
 
@@ -2,7 +2,7 @@ module RailsSqlViews
2
2
  module ConnectionAdapters
3
3
  module AbstractAdapter
4
4
  def self.included(base)
5
- base.alias_method_chain :disable_referential_integrity, :views_excluded
5
+ #base.alias_method_chain :disable_referential_integrity, :views_excluded
6
6
  end
7
7
 
8
8
  # Subclasses should override and return true if they support views.
@@ -14,24 +14,24 @@ module RailsSqlViews
14
14
  def supports_drop_table_cascade?
15
15
  return true
16
16
  end
17
-
18
- def disable_referential_integrity_with_views_excluded(&block)
19
- self.class.send(:alias_method, :original_tables_method, :tables)
20
- self.class.send(:alias_method, :tables, :base_tables)
21
- disable_referential_integrity_without_views_excluded(&block)
22
- ensure
23
- self.class.send(:alias_method, :tables, :original_tables_method)
24
- end
25
-
17
+
18
+ #def disable_referential_integrity_with_views_excluded(&block)
19
+ # self.class.send(:alias_method, :original_tables_method, :tables)
20
+ # self.class.send(:alias_method, :tables, :base_tables)
21
+ # disable_referential_integrity_without_views_excluded(&block)
22
+ #ensure
23
+ # self.class.send(:alias_method, :tables, :original_tables_method)
24
+ #end
25
+
26
26
  def supports_view_columns_definition?
27
27
  true
28
28
  end
29
-
29
+
30
30
  # Get a list of all views for the current database
31
31
  def views(name = nil)
32
32
  raise NotImplementedError, "views is an abstract method"
33
33
  end
34
-
34
+
35
35
  # Get the select statement for the specified view
36
36
  def view_select_statement(view, name=nil)
37
37
  raise NotImplementedError, "view_select_statement is an abstract method"
@@ -1,14 +1,11 @@
1
1
  module RailsSqlViews
2
2
  module ConnectionAdapters
3
3
  module PostgreSQLAdapter
4
- def self.included(base)
5
- base.alias_method_chain :tables, :views_included
6
- end
7
4
  # Returns true as this adapter supports views.
8
5
  def supports_views?
9
6
  true
10
7
  end
11
-
8
+
12
9
  def tables_with_views_included(name = nil)
13
10
  q = <<-SQL
14
11
  SELECT table_name, table_type
@@ -19,7 +16,7 @@ module RailsSqlViews
19
16
 
20
17
  query(q, name).map { |row| row[0] }
21
18
  end
22
-
19
+
23
20
  def base_tables(name = nil)
24
21
  q = <<-SQL
25
22
  SELECT table_name, table_type
@@ -27,11 +24,11 @@ module RailsSqlViews
27
24
  WHERE table_schema IN (#{schemas})
28
25
  AND table_type = 'BASE TABLE'
29
26
  SQL
30
-
27
+
31
28
  query(q, name).map { |row| row[0] }
32
29
  end
33
30
  alias nonview_tables base_tables
34
-
31
+
35
32
  def views(name = nil) #:nodoc:
36
33
  q = <<-SQL
37
34
  SELECT table_name, table_type
@@ -39,24 +36,24 @@ module RailsSqlViews
39
36
  WHERE table_schema IN (#{schemas})
40
37
  AND table_type = 'VIEW'
41
38
  SQL
42
-
39
+
43
40
  query(q, name).map { |row| row[0] }
44
41
  end
45
42
 
46
43
  def view_select_statement(view, name = nil)
47
44
  q = <<-SQL
48
45
  SELECT view_definition
49
- FROM information_schema.views
46
+ FROM information_schema.views
50
47
  WHERE table_catalog = (SELECT catalog_name FROM information_schema.information_schema_catalog_name)
51
48
  AND table_schema IN (#{schemas})
52
49
  AND table_name = '#{view}'
53
50
  SQL
54
-
51
+
55
52
  select_value(q, name) or raise "No view called #{view} found"
56
53
  end
57
54
 
58
55
  private
59
-
56
+
60
57
  def schemas
61
58
  schema_search_path.split(/,/).map { |p| quote(p) }.join(',')
62
59
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module RailsSqlViews
3
3
  module Loader
4
- SUPPORTED_ADAPTERS = %w( Mysql PostgreSQL SQLServer SQLite OracleEnhanced )
4
+ SUPPORTED_ADAPTERS = %w( Mysql SQLServer SQLite OracleEnhanced )
5
5
 
6
6
  def self.load_extensions
7
7
  SUPPORTED_ADAPTERS.each do |db|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mereghost-rails_sql_views
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: