aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-05-19 12:20:30 +0200
committerYves Senn <yves.senn@gmail.com>2014-05-19 12:20:30 +0200
commitd4cec3124085ee7070986d13e9e44664d0aa9d2a (patch)
treeba3f5c46439ab2b74d48c7aa86a876ed77455011 /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
parent881cab448c698dde1d698ea8ad048561c6bcf702 (diff)
downloadrails-d4cec3124085ee7070986d13e9e44664d0aa9d2a.tar.gz
rails-d4cec3124085ee7070986d13e9e44664d0aa9d2a.tar.bz2
rails-d4cec3124085ee7070986d13e9e44664d0aa9d2a.zip
pg, re-introduce `PostgreSQL::Utils` to unify schema/table extraction.
Partial revert of c0bfc3f412834ffe8327a15ae3a46602cc28e425
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.rb19
1 files changed, 1 insertions, 18 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 dd983562fb..539ba38c4a 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -97,7 +97,7 @@ 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 = extract_schema_and_table(name.to_s)
+ schema, table = Utils.extract_schema_and_table(name.to_s)
return false unless table
exec_query(<<-SQL, 'SCHEMA').rows.first[0].to_i > 0
@@ -488,23 +488,6 @@ module ActiveRecord
[super, *order_columns].join(', ')
end
-
- private
-
- # Returns an array of <tt>[schema_name, table_name]</tt> extracted from +name+.
- # +schema_name+ is nil if not specified in +name+.
- # +schema_name+ and +table_name+ exclude surrounding quotes (regardless of whether provided in +name+)
- # +name+ supports the range of schema/table references understood by PostgreSQL, for example:
- #
- # * <tt>table_name</tt>
- # * <tt>"table.name"</tt>
- # * <tt>schema_name.table_name</tt>
- # * <tt>schema_name."table.name"</tt>
- # * <tt>"schema.name"."table name"</tt>
- def extract_schema_and_table(name)
- table, schema = name.scan(/[^".\s]+|"[^"]*"/)[0..1].collect{|m| m.gsub(/(^"|"$)/,'') }.reverse
- [schema, table]
- end
end
end
end