diff --git a/jans-pycloudlib/jans/pycloudlib/persistence/spanner.py b/jans-pycloudlib/jans/pycloudlib/persistence/spanner.py index 95dc9c0f80c..2eec8b0145d 100644 --- a/jans-pycloudlib/jans/pycloudlib/persistence/spanner.py +++ b/jans-pycloudlib/jans/pycloudlib/persistence/spanner.py @@ -293,6 +293,9 @@ def _transform_value(self, key: str, values: _t.Any) -> _t.Any: """ type_ = self.sql_data_types.get(key, {}) + if not type_: + type_ = self.sql_json_types.get(key, {}) + if not type_: attr_syntax = self.get_attr_syntax(key) type_ = self.sql_data_types_mapping[attr_syntax] diff --git a/jans-pycloudlib/jans/pycloudlib/persistence/sql.py b/jans-pycloudlib/jans/pycloudlib/persistence/sql.py index 35a38c91987..75495ce3584 100644 --- a/jans-pycloudlib/jans/pycloudlib/persistence/sql.py +++ b/jans-pycloudlib/jans/pycloudlib/persistence/sql.py @@ -171,7 +171,7 @@ def doc_id_from_dn(dn: str) -> str: if doc_id == "jans": doc_id = "_" - return doc_id + return doc_id # noqa: R504 class SqlSchemaMixin: @@ -180,11 +180,10 @@ class SqlSchemaMixin: @property def schema_files(self) -> list[str]: """Get list of schema files.""" - files = [ + return [ "/app/schema/jans_schema.json", "/app/schema/custom_schema.json", ] - return files @cached_property def sql_data_types(self) -> dict[str, dict[str, _t.Any]]: @@ -221,6 +220,20 @@ def opendj_attr_types(self) -> dict[str, str]: with open("/app/static/rdbm/opendj_attributes_syntax.json") as f: return json.loads(f.read()) # type: ignore + @cached_property + def sql_json_types(self): + json_types = {} + for attr_type in self.attr_types: + for attr in attr_type["names"]: + if not attr_type.get("rdbm_json_column"): + continue + json_types[attr] = { + "mysql": {"type": "JSON"}, + "pgsql": {"type": "JSONB"}, + "spanner": {"type": "ARRAY"}, + } + return json_types + def get_attr_syntax(self, attr: str) -> str: """Get attribute syntax. @@ -460,6 +473,9 @@ def _transform_value(self, key: str, values: _t.Any) -> _t.Any: """ type_ = self.sql_data_types.get(key, {}) + if not type_: + type_ = self.sql_json_types.get(key, {}) + if not type_: attr_syntax = self.get_attr_syntax(key) type_ = self.sql_data_types_mapping[attr_syntax]