Skip to content

Commit

Permalink
added nonview_tables where missing. need to get tests running again
Browse files Browse the repository at this point in the history
  • Loading branch information
aeden committed Nov 4, 2008
1 parent f5a2b22 commit 8f9060f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Expand Up @@ -18,4 +18,5 @@
* Updated tests to include new table to support union test

0.7.0
* Updated dependency versions to get on ActiveRecord 2.x. May not be compatible with Rails versions less than 2.x.
* Updated dependency versions to get on ActiveRecord 2.x. May not be compatible with Rails versions less than 2.x.
* Add nonview_tables support to *all* of the adapters (was missing from Postgres and SQLServer)
2 changes: 1 addition & 1 deletion lib/rails_sql_views/connection_adapters/oci_adapter.rb
Expand Up @@ -6,7 +6,7 @@ def supports_views?
true
end

def tables(name = nil) #:nodoc:
def nonview_tables(name = nil) #:nodoc:
tables = []
execute("SELECT TABLE_NAME FROM USER_TABLES", name).each { |row| tables << row[0] }
tables
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_sql_views/connection_adapters/oracle_adapter.rb
Expand Up @@ -6,7 +6,7 @@ def supports_views?
true
end

def tables(name = nil) #:nodoc:
def nonview_tables(name = nil) #:nodoc:
tables = []
execute("SELECT TABLE_NAME FROM USER_TABLES", name).each { |row| tables << row[0] }
tables
Expand Down
11 changes: 11 additions & 0 deletions lib/rails_sql_views/connection_adapters/postgresql_adapter.rb
Expand Up @@ -6,6 +6,17 @@ def supports_views?
true
end

def nonview_tables(name = nil)
q = <<-SQL
SELECT table_name, table_type
FROM information_schema.tables
WHERE table_schema IN (#{schemas})
AND table_type = 'BASE_TABLE'
SQL

query(q, name).map { |row| row[0] }
end

def views(name = nil) #:nodoc:
q = <<-SQL
SELECT table_name, table_type
Expand Down
6 changes: 6 additions & 0 deletions lib/rails_sql_views/connection_adapters/sqlserver_adapter.rb
Expand Up @@ -6,6 +6,12 @@ def supports_views?
true
end

# Get all of the non-view tables from the currently connected schema
def nonview_tables(name = nil)
# this is untested
select_values("SELECT table_name FROM information_schema.tables", name)
end

# Returns all the view names from the currently connected schema.
def views(name = nil)
select_values("SELECT table_name FROM information_schema.views", name)
Expand Down
1 change: 1 addition & 0 deletions test/README
Expand Up @@ -25,6 +25,7 @@ If you would like to implement an adapter, it should go in lib/rails_sql_views/c
of the other adapters currently implemented. Every adapter must implement the following methods:

supports_views?
nonview_tables(name = nil)
views(name = nil)
view_select_statement(view, name=nil)

Expand Down

0 comments on commit 8f9060f

Please sign in to comment.