diff options
author | Daniel Schierbeck <daniel.schierbeck@gmail.com> | 2011-07-09 14:24:28 +0200 |
---|---|---|
committer | Daniel Schierbeck <daniel.schierbeck@gmail.com> | 2011-07-09 14:24:28 +0200 |
commit | a982443ae5bd12535405dbdb40f27df2d612256e (patch) | |
tree | 126f4f6f405f8c5f8ba051dc1bb3dd4d27e8dd43 /activerecord/lib/active_record | |
parent | 111968d4024fdccc386979551cdfc7799b39cff0 (diff) | |
download | rails-a982443ae5bd12535405dbdb40f27df2d612256e.tar.gz rails-a982443ae5bd12535405dbdb40f27df2d612256e.tar.bz2 rails-a982443ae5bd12535405dbdb40f27df2d612256e.zip |
Make #extract_schema_and_table an instance method in Utils
Also, move the utils test into its own test case.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index a84f73c73f..df753d087c 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -948,6 +948,8 @@ module ActiveRecord end module Utils + extend self + # 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+) @@ -958,7 +960,7 @@ module ActiveRecord # * <tt>schema_name.table_name</tt> # * <tt>schema_name."table.name"</tt> # * <tt>"schema.name"."table name"</tt> - def self.extract_schema_and_table(name) + def extract_schema_and_table(name) table, schema = name.scan(/[^".\s]+|"[^"]*"/)[0..1].collect{|m| m.gsub(/(^"|"$)/,'') }.reverse [schema, table] end |