Skip to content

Instantly share code, notes, and snippets.

@willgorman
Created October 17, 2011 21:37
Show Gist options
  • Save willgorman/1293900 to your computer and use it in GitHub Desktop.
Save willgorman/1293900 to your computer and use it in GitHub Desktop.
module Sequel
module Plugins
module OracleSequence
module InstanceMethods
def before_create
seq_name = model.dataset.opts[:sequence]
unless self.class.simple_pk.nil? or seq_name.nil?
method = "#{self.primary_key.to_s}=".to_sym
self.send(method, DB.fetch("SELECT #{seq_name}.NEXTVAL FROM DUAL").first[:nextval])
end
super
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment