From: Ansgar Burchardt Date: Sun, 1 May 2016 14:48:22 +0000 (+0200) Subject: Work with newer SQLAlchemy versions X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e1efe0c5ee9f7568a28fff59cab0e3cd4319f37e;p=dak.git Work with newer SQLAlchemy versions 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`. --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 3a7f55bb..3d3561f5 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2158,7 +2158,8 @@ class BinaryMetadata(ORMObject): 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'] @@ -2174,7 +2175,8 @@ class SourceMetadata(ORMObject): 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']