Created
October 17, 2011 21:37
-
-
Save willgorman/1293900 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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