From eced79b278426084ad28906abe7b221f5819a24c Mon Sep 17 00:00:00 2001 From: Logan Williams Date: Fri, 3 Mar 2023 10:47:21 +0100 Subject: [PATCH] Fix issue with insert_or_select --- cisticola/transformer/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cisticola/transformer/base.py b/cisticola/transformer/base.py index b146ebc..0c72297 100644 --- a/cisticola/transformer/base.py +++ b/cisticola/transformer/base.py @@ -115,7 +115,11 @@ class ETLController: # This is using some adhoc unique constraints that might be worth formalizing at some point if type(obj) == Channel: - instance = session.query(Channel).filter_by(url=obj.url, platform_id=str(obj.platform_id or '') or obj.platform_id, platform=obj.platform).first() + instance = session.query(Channel).filter( + (((Channel.url==obj.url)&(Channel.url!='')&(Channel.url is not None)&(Channel.url!='https://t.me/s/'))| + ((Channel.platform_id==str(obj.platform_id))&(Channel.platform_id!='')&(Channel.platform_id is not None))| + ((Channel.screenname==obj.screenname)&(Channel.screenname!='')&(Channel.screenname is not None)))& + (Channel.platform==obj.platform)).first() elif type(obj) == Post: instance = None