diff options
author | Lucas Stephanou <lucas@lucas-ts.com> | 2011-05-27 17:48:34 -0300 |
---|---|---|
committer | Lucas Stephanou <lucas@lucas-ts.com> | 2011-05-27 17:48:34 -0300 |
commit | c44418ea4e09cc81da47edbc9ac5f31c7e32c1b4 (patch) | |
tree | 7b38b3bd23c93ae15eb41e08f934ed28e1f3c4e1 /activerecord | |
parent | 055c6fb010417f7e5f8596a63075fc86ff35c54a (diff) | |
download | rails-c44418ea4e09cc81da47edbc9ac5f31c7e32c1b4.tar.gz rails-c44418ea4e09cc81da47edbc9ac5f31c7e32c1b4.tar.bz2 rails-c44418ea4e09cc81da47edbc9ac5f31c7e32c1b4.zip |
[activerecord][postgresql] verify if table has a schema(not public)
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 3e390ba994..b681871673 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -659,7 +659,10 @@ module ActiveRecord # Returns the list of all tables in the schema search path or a specified schema. def tables(name = nil) query(<<-SQL, 'SCHEMA').map { |row| row[0] } - SELECT tablename + SELECT case schemaname + when 'public' then tablename + else schemaname||'.'||tablename + end as tablename FROM pg_tables WHERE schemaname = ANY (current_schemas(false)) SQL @@ -830,11 +833,7 @@ module ActiveRecord end_sql # [primary_key, sequence] - if result.second == 'public' then - sequence = result.last - else - sequence = result.second+'.'+result.last - end + sequence = result.second == 'public' ? result.last : "#{result.second}.#{result.last}" [result.first, sequence] rescue |