From e1efe0c5ee9f7568a28fff59cab0e3cd4319f37e Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt Date: Sun, 1 May 2016 16:48:22 +0200 Subject: [PATCH] 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`. --- daklib/dbconn.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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'] -- 2.39.5