Created
February 25, 2011 10:31
Revisions
-
rubypanther revised this gist
Feb 25, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ def table_exists?(name) table, schema = name.split('.', 2).reverse # avoid futzing with no schema case if name =~ /^"/ # Handle quoted table names table = name.gsub(/^"|"$/,'') schema = nil end -
rubypanther revised this gist
Feb 25, 2011 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,8 +12,8 @@ def table_exists?(name) not query(<<-SQL).blank? SELECT TRUE FROM pg_tables, pg_views WHERE (pg_tables.tablename = '#{table}' OR pg_views.viewname = '#{table}') #{schema ? "AND schemaname = '#{schema}'" : ''} LIMIT 1 SQL end -
rubypanther revised this gist
Feb 25, 2011 . 2 changed files with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ class ApplicationController < ActionController::Base require 'postgresql_view_monkey' end File renamed without changes. -
rubypanther renamed this gist
Feb 25, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rubypanther created this gist
Feb 25, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ module ActiveRecord module ConnectionAdapters class PostgreSQLAdapter def table_exists?(name) name = name.to_s table, schema = name.split('.', 2).reverse # avoid futzing with no schema case if name =~ /^"/ # Handle quoted table names table = name.gsub(/(^"|"$)/,'') schema = nil end not query(<<-SQL).blank? SELECT TRUE FROM pg_tables, pg_views WHERE (pg_tables.tablename = '#{tn}' OR pg_views.viewname = '#{tn}') #{schema ? "AND schemaname = '#{schema}'" : ''} LIMIT 1 SQL end end end end