diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-05-30 10:53:24 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-05-30 10:53:24 +0200 |
commit | 7b8d95d58fbadf71e1f27a848427de27e0a2742a (patch) | |
tree | c9f644d0e87e4de43cfc93550b4cf18409bf812f /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | |
parent | 6963e33829c11f7036b8c8015e2c5222a469c118 (diff) | |
download | rails-7b8d95d58fbadf71e1f27a848427de27e0a2742a.tar.gz rails-7b8d95d58fbadf71e1f27a848427de27e0a2742a.tar.bz2 rails-7b8d95d58fbadf71e1f27a848427de27e0a2742a.zip |
pg, `PostgreSQL::Name` to hold schema qualified names.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index b4d53eba26..e29f97dcbf 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -97,16 +97,16 @@ module ActiveRecord # If the schema is not specified as part of +name+ then it will only find tables within # the current schema search path (regardless of permissions to access tables in other schemas) def table_exists?(name) - schema, table = Utils.extract_schema_and_table(name.to_s) - return false unless table + name = Utils.extract_schema_qualified_name(name.to_s) + return false unless name.identifier exec_query(<<-SQL, 'SCHEMA').rows.first[0].to_i > 0 SELECT COUNT(*) FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r','v','m') -- (r)elation/table, (v)iew, (m)aterialized view - AND c.relname = '#{table.gsub(/(^"|"$)/,'')}' - AND n.nspname = #{schema ? "'#{schema}'" : 'ANY (current_schemas(false))'} + AND c.relname = '#{name.identifier}' + AND n.nspname = #{name.schema ? "'#{name.schema}'" : 'ANY (current_schemas(false))'} SQL end |