The PostgreSQLAdapter
does not currently define #next_sequence_value
. If I have a User
model, then User.respond_to?(:next_sequence_value)
will return true
, but calling it will raise a NoMethodError
, since that method is delegated to the database adapter.
Implementing this seems to be fairly simple, pending any weirdness across different Postgres versions:
# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
def next_sequence_value(sequence_name)
execute("SELECT nextval(#{quote(sequence_name)})").first['nextval']
end
Am I missing anything that would make this change any more complicated? As is, this works locally for me (albeit only tested against the one version of Postgres I am running).