From 3e680c604d8a83b7d510bc5c3cd729bbbd65830d Mon Sep 17 00:00:00 2001 From: Isman Firmansyah Date: Sun, 28 Apr 2024 19:35:57 +0700 Subject: [PATCH] fix(docker-jans-persistence-loader): handle missing data type for overriden column (#8392) * fix(docker-jans-persistence-loader): handle missing data type for overriden column Signed-off-by: iromli * fix: handle scripts properties changes Signed-off-by: iromli * fix: handle non-collection properties Signed-off-by: iromli --------- Signed-off-by: iromli Former-commit-id: 5b257660ee914277fd06ec574a26fd28f9a22bb7 --- .../scripts/spanner_setup.py | 3 +++ docker-jans-persistence-loader/scripts/sql_setup.py | 3 +++ docker-jans-persistence-loader/scripts/upgrade.py | 10 +++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docker-jans-persistence-loader/scripts/spanner_setup.py b/docker-jans-persistence-loader/scripts/spanner_setup.py index 0569db7205e..51e7c22419f 100644 --- a/docker-jans-persistence-loader/scripts/spanner_setup.py +++ b/docker-jans-persistence-loader/scripts/spanner_setup.py @@ -46,6 +46,9 @@ def get_data_type(self, attr, table=None): type_ = type_def.get(self.client.dialect) + if not type_: + continue + if table in type_.get("tables", {}): type_ = type_["tables"][table] diff --git a/docker-jans-persistence-loader/scripts/sql_setup.py b/docker-jans-persistence-loader/scripts/sql_setup.py index f2abb54d6b5..f030844d4ba 100644 --- a/docker-jans-persistence-loader/scripts/sql_setup.py +++ b/docker-jans-persistence-loader/scripts/sql_setup.py @@ -54,6 +54,9 @@ def get_data_type(self, attr, table=None): type_ = type_def.get(self.client.dialect) or type_def["mysql"] + if not type_: + continue + if table in type_.get("tables", {}): type_ = type_["tables"][table] diff --git a/docker-jans-persistence-loader/scripts/upgrade.py b/docker-jans-persistence-loader/scripts/upgrade.py index 8f359b12f2a..870d6f4cfe8 100644 --- a/docker-jans-persistence-loader/scripts/upgrade.py +++ b/docker-jans-persistence-loader/scripts/upgrade.py @@ -369,9 +369,10 @@ def update_scripts_entries(self): else: props = agama_entry.attrs["jansConfProperty"] - if self.backend.type != "couchbase": - # try converting to mapping - props = [json.loads(prop) for prop in props] + if not isinstance(props, list): + props = [props] + + props = [json.loads(prop) for prop in props] # filter out unwanted properties new_props = [ @@ -380,8 +381,7 @@ def update_scripts_entries(self): ] if new_props != props: - if self.backend.type != "couchbase": - new_props = [json.dumps(prop) for prop in new_props] + new_props = [json.dumps(prop) for prop in new_props] if self.backend.type == "sql" and self.backend.client.dialect == "mysql": agama_entry.attrs["jansConfProperty"]["v"] = new_props