Skip to content

Commit

Permalink
Merge pull request rails#7648 from kennyj/rename_2_schema
Browse files Browse the repository at this point in the history
Query for loading index info should be marked as SCHEMA.
  • Loading branch information
rafaelfranca committed Sep 15, 2012
2 parents 714e348 + 3dc4021 commit 56c60ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -111,7 +111,7 @@ def indexes(table_name, name = nil)
inddef = row[3]
oid = row[4]

columns = Hash[query(<<-SQL, "Columns for index #{row[0]} on #{table_name}")]
columns = Hash[query(<<-SQL, "SCHEMA")]
SELECT a.attnum, a.attname
FROM pg_attribute a
WHERE a.attrelid = #{oid}
Expand Down Expand Up @@ -252,7 +252,7 @@ def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
if pk && sequence
quoted_sequence = quote_table_name(sequence)

select_value <<-end_sql, 'Reset sequence'
select_value <<-end_sql, 'SCHEMA'
SELECT setval('#{quoted_sequence}', (SELECT COALESCE(MAX(#{quote_column_name pk})+(SELECT increment_by FROM #{quoted_sequence}), (SELECT min_value FROM #{quoted_sequence})) FROM #{quote_table_name(table)}), false)
end_sql
end
Expand All @@ -262,7 +262,7 @@ def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
def pk_and_sequence_for(table) #:nodoc:
# First try looking for a sequence with a dependency on the
# given table's primary key.
result = query(<<-end_sql, 'PK and serial sequence')[0]
result = query(<<-end_sql, 'SCHEMA')[0]
SELECT attr.attname, seq.relname
FROM pg_class seq,
pg_attribute attr,
Expand All @@ -283,7 +283,7 @@ def pk_and_sequence_for(table) #:nodoc:
# If that fails, try parsing the primary key's default value.
# Support the 7.x and 8.0 nextval('foo'::text) as well as
# the 8.1+ nextval('foo'::regclass).
result = query(<<-end_sql, 'PK and custom sequence')[0]
result = query(<<-end_sql, 'SCHEMA')[0]
SELECT attr.attname,
CASE
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
Expand Down
Expand Up @@ -403,7 +403,7 @@ def indexes(table_name, name = nil) #:nodoc:
table_name,
row['name'],
row['unique'] != 0,
exec_query("PRAGMA index_info('#{row['name']}')", "Columns for index #{row['name']} on #{table_name}").map { |col|
exec_query("PRAGMA index_info('#{row['name']}')", "SCHEMA").map { |col|
col['name']
})
end
Expand Down

0 comments on commit 56c60ca

Please sign in to comment.