mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
[activerecord][postgresql] verify if table has a schema(not public)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user