zodb / relstorage

A backend for ZODB that stores pickles in a relational database.
Other
54 stars 46 forks source link

RelStorage and zodbupdate #388

Closed tflorac closed 4 years ago

tflorac commented 4 years ago

Hi, I would like to update a database schema using RelStorage 3.0.1 with zodbupdate (https://pypi.org/project/zodbupdate/). But I get an exception:

Loaded 3 rename rules from pyams_site.generations:renames
Loaded 2 rename rules from pyams_catalog.generations:renames
An error occured
Traceback (most recent call last):
  File "/var/local/env/pycharm/lib/python3.5/site-packages/zodbupdate/main.py", line 186, in main
    updater()
  File "/var/local/env/pycharm/lib/python3.5/site-packages/zodbupdate/update.py", line 97, in __call__
    raise error
  File "/var/local/env/pycharm/lib/python3.5/site-packages/zodbupdate/update.py", line 74, in __call__
    for oid, serial, current in self.records:
  File "/var/local/env/pycharm/lib/python3.5/site-packages/zodbupdate/update.py", line 140, in records
    not self.storage.supportsUndo()):
AttributeError: 'RelStorage' object has no attribute 'supportsUndo'
Stopped processing, due to: 'RelStorage' object has no attribute 'supportsUndo'

I have tried to modify zodbupdate to avoid this call, but then an error message says that zodbupdate doesn't know how to handle this storage!

So is there any way to update my schema with zodbupdate (or any other method), without converting my database from and to a classic FileStorage?

Best regards, Thierry

jamadden commented 4 years ago

supportsUndo is a method of IStorageUndoable. RelStorage only implements IStorageUndoable when keep-history is true. It seems that zodbupdate incorrectly always assumes that method is available; it should be checking whether IStorageUndoable.providedBy(self.storage). It looks like the full test should be

elif (IStorageIteration.providedBy(storage) 
         and (not IStorageUndoable.providedBy(self.storage) 
              or not storage.supportsUndo())):
   …

Does that take care of it?

tflorac commented 4 years ago

Thanks for you reply! Actually if we skip this test zodbupdate exist saying that it doesn't know how to handle this kind of storage!! :(

jamadden commented 4 years ago

I'm not suggesting skipping the test, I'm suggesting modifying it like I wrote above. That should pass for a history-free RelStorage.

A history-preserving RelStorage doesn't appear to be supported by zodbupdate at this time. It needs #389

tflorac commented 4 years ago

Ho, sorry, I misread! :( I'm going to check...

tflorac commented 4 years ago

Yes, I modified zodbupdate code as you suggested and actually it seems to work! Many thanks, Thierry

tflorac commented 4 years ago

OK, I submitted a match to zodbupdate repository...!

jamadden commented 4 years ago

With https://github.com/zopefoundation/zodbupdate/pull/39 and #389, RelStorage is usable and tested with zodbupdate in both history-free and history-preserving configuratinos.