[sqlalchemy] Re: Versioning and Foreign Keys
Oops, above references to versioned_meta should read history_meta. Sorry -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/0ZtFX94qz_wJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Re: Versioning and multi-level inheritance
version is only on your Container table since it will always have a row corresponding to each Box row, so box.version is not necessary. You can change this by changing: if not super_history_mapper: cls.version = Column('version', Integer, default=1, nullable=False) to: cls.version = Column('version', Integer, default=1, nullable=False) then ensuring that Box.version is also written on update. On Aug 31, 2011, at 10:28 AM, JPLaverdure wrote: I just realised the following issue: When I create the following relationship: class Container(Base): __metaclass__ = VersionedMeta __tablename__ = 'container' __table_args__ = {'schema':'storage'} id = Column(Integer, primary_key=True) discriminator = Column('type', String(64)) token = Column(String(128), nullable=False) description = Column(String) __mapper_args__ = {'polymorphic_on': discriminator, 'polymorphic_identity':'container'} class Box(Container): __metaclass__ = VersionedMeta __tablename__ = 'box' __table_args__ = {'schema':'storage'} __mapper_args__ = {'polymorphic_identity': 'box'} id = Column(Integer, ForeignKey('storage.container.id', onupdate=cascade, ondelete=cascade), primary_key=True) barcode = Column(String(64)) Even though box_history gets created, no version column is added to the box table and any modification to a Box entity does not log the change in the _history table. Could anyone please point out what I'm doing wrong ? I tried removing the metaclass declaration from the Box entity since it would basically inherit it from Container but that didn't help in solving my issue. Thank you !! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/PK3kVAsuh5QJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Re: Versioning and multi-level inheritance
Hi Michael, Thank you for your reply. Unfortunately, the mistake was all mine... At some point (and for an obscure reason...), I had stopped using the VersionedListener so changes were no longer registering in the DB :-/ So sorry ! JP -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/WhQyp4AmxWsJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Re: Versioning and multi-level inheritance
Hi Michael, Thank you for your reply. Unfortunately, the mistake was all mine... At some point (and for an obscure reason...), I had stopped using the VersionedListener so changes were no longer registering in the DB :-/ So sorry ! JP On Wed, Aug 31, 2011 at 12:23 PM, Michael Bayer mike...@zzzcomputing.comwrote: version is only on your Container table since it will always have a row corresponding to each Box row, so box.version is not necessary. You can change this by changing: if not super_history_mapper: cls.version = Column('version', Integer, default=1, nullable=False) to: cls.version = Column('version', Integer, default=1, nullable=False) then ensuring that Box.version is also written on update. On Aug 31, 2011, at 10:28 AM, JPLaverdure wrote: I just realised the following issue: When I create the following relationship: class Container(Base): __metaclass__ = VersionedMeta __tablename__ = 'container' __table_args__ = {'schema':'storage'} id = Column(Integer, primary_key=True) discriminator = Column('type', String(64)) token = Column(String(128), nullable=False) description = Column(String) __mapper_args__ = {'polymorphic_on': discriminator, 'polymorphic_identity':'container'} class Box(Container): __metaclass__ = VersionedMeta __tablename__ = 'box' __table_args__ = {'schema':'storage'} __mapper_args__ = {'polymorphic_identity': 'box'} id = Column(Integer, ForeignKey('storage.container.id', onupdate=cascade, ondelete=cascade), primary_key=True) barcode = Column(String(64)) Even though box_history gets created, no version column is added to the box table and any modification to a Box entity does not log the change in the _history table. Could anyone please point out what I'm doing wrong ? I tried removing the metaclass declaration from the Box entity since it would basically inherit it from Container but that didn't help in solving my issue. Thank you !! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/PK3kVAsuh5QJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- Je-Pe -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: versioning and complex collection
Michael, thanks a lot for your thorough and informative reply. I'll take my time and think about all that / try out stuff. Just so you know why it's taking so long till I answer again... Tim -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: versioning when updating a relationship
The versioning example appears to be cautious about determining if there was a net change present. The good news is that we don't actually need the new value of customer_ref when we create the historical entry, we need the current entry, which should be present in the object's dict. Within create_version(), if we see no net change on column-based attributes, we assume nothing changed. All we really need to do is check all the relationship() based attributes as well - I'll commit the attached patch which adds: if not obj_changed: # not changed, but we have relationships. OK # check those too for prop in obj_mapper.iterate_properties: if isinstance(prop, RelationshipProperty) and \ attributes.get_history(obj, prop.key).has_changes(): obj_changed = True break Great, that will work well. Many thanks, A. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Versioning
Sam schrieb: One of the things I really liked about sqlobject was its versioning plug-in. ( http://www.sqlobject.org/Versioning.html ) Is there anything similar for sqlalchemy? A google search turned up versioned ( http://elixir.ematia.de/apidocs/elixir.ext.versioned.html ) This is a plug-in for elixir, but I'm not using elixir. Could I make it work without having to use elixir? Are there other alternatives? Maybe sqlalchmey.migrate is what you are looking for? Diez --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Versioning
On Friday 12 September 2008 05:37:35 Sam wrote: One of the things I really liked about sqlobject was its versioning plug-in. ( http://www.sqlobject.org/Versioning.html ) Is there anything similar for sqlalchemy? A google search turned up versioned ( http://elixir.ematia.de/apidocs/elixir.ext.versioned.html ) This is a plug-in for elixir, but I'm not using elixir. Could I make it work without having to use elixir? Are there other alternatives? i have a bitemporal-versions mixin but it isn't that simple and API-finished as the above. http://dbcook.svn.sourceforge.net/viewvc/dbcook/trunk/dbcook/misc/timed/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Versioning
On Fri, Sep 12, 2008 at 4:37 AM, Sam [EMAIL PROTECTED] wrote: One of the things I really liked about sqlobject was its versioning plug-in. ( http://www.sqlobject.org/Versioning.html ) Is there anything similar for sqlalchemy? A google search turned up versioned ( http://elixir.ematia.de/apidocs/elixir.ext.versioned.html ) This is a plug-in for elixir, but I'm not using elixir. Could I make it work without having to use elixir? Are there other alternatives? Not sure what's it worth but this might be what you are looking for: http://www.okfn.org/vdm/ -- Gaëtan de Menten http://openhex.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---