You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
module ClassMethods
def define_version_property(property)
type = case property
when DataMapper::Property::Discriminator then Class
when DataMapper::Property::Serial then Integer
else
property.class
end
options = property.options.merge(:key => property.name == @on)
options[:key] = true if options.delete(:serial)
return property.name, type, options
end
def const_missing(name)
if name == :Version
model = DataMapper::Model.new(name, self)
properties.each do |property|
name, type, options = define_version_property property
model.property(property.name, type, options)
end
model
else
super
end
end
end # ClassMethods
And then the consumer need only override define_version_property to adjust the options hash
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
If you try to version a resource that does not user a serial primary key, you run into integrity issues due to the tight coupling between property option values and the construction of the primary key (https://github.com/datamapper/dm-is-versioned/blob/master/lib/dm-is-versioned/is/versioned.rb#L88). If a natural key is used, then the original key is ignored in the version table.
There is no method used for the consuming class to override this behaviour - this could be easily remedied by extracting the property argument creation logic to a new method that can be overrriden (https://github.com/datamapper/dm-is-versioned/blob/master/lib/dm-is-versioned/is/versioned.rb#L78-L88), eg:
And then the consumer need only override define_version_property to adjust the options hash
The text was updated successfully, but these errors were encountered: