Skip to content

Commit

Permalink
Query for sequence info also should be markd as SCHEMA.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyj committed Sep 15, 2012
1 parent 8933efb commit 3dc4021
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -252,7 +252,7 @@ def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
if pk && sequence if pk && sequence
quoted_sequence = quote_table_name(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) 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_sql
end end
Expand All @@ -262,7 +262,7 @@ def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
def pk_and_sequence_for(table) #:nodoc: def pk_and_sequence_for(table) #:nodoc:
# First try looking for a sequence with a dependency on the # First try looking for a sequence with a dependency on the
# given table's primary key. # 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 SELECT attr.attname, seq.relname
FROM pg_class seq, FROM pg_class seq,
pg_attribute attr, 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. # If that fails, try parsing the primary key's default value.
# Support the 7.x and 8.0 nextval('foo'::text) as well as # Support the 7.x and 8.0 nextval('foo'::text) as well as
# the 8.1+ nextval('foo'::regclass). # the 8.1+ nextval('foo'::regclass).
result = query(<<-end_sql, 'PK and custom sequence')[0] result = query(<<-end_sql, 'SCHEMA')[0]
SELECT attr.attname, SELECT attr.attname,
CASE CASE
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
Expand Down

0 comments on commit 3dc4021

Please sign in to comment.