Newer SQLAlchemy versions seem to track the `binary` attribute of
`BinaryMetadata`. This means the association proxy in `DBBinary`
would first create a `BinaryMetadata` with `binary` set to `None`,
flush this to the database and then set the actual value of `binary`
we want. However the flush fails, as `NULL` is not allowed for the
`binary_id` column.
The problem can be avoided by not setting `binary` to `None`. This is
treated as an "undefined value" by SQLAlchemy and changing it later
means the database row never sees `NULL`.
The same applies to the `source` attribute of `SourceMetadata`.
def __init__(self, key = None, value = None, binary = None):
self.key = key
self.value = value
- self.binary = binary
+ if binary is not None:
+ self.binary = binary
def properties(self):
return ['binary', 'key', 'value']
def __init__(self, key = None, value = None, source = None):
self.key = key
self.value = value
- self.source = source
+ if source is not None:
+ self.source = source
def properties(self):
return ['source', 'key', 'value']