Skip to content

Commit

Permalink
feat(jans-pycloudlib): handle rdbm_json_column in schema definitions
Browse files Browse the repository at this point in the history
Signed-off-by: iromli <isman.firmansyah@gmail.com>
  • Loading branch information
iromli committed Apr 20, 2024
1 parent 1b6bb3e commit 9cf11bc
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions jans-pycloudlib/jans/pycloudlib/persistence/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]]:
Expand Down Expand Up @@ -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] = {

Check warning on line 230 in jans-pycloudlib/jans/pycloudlib/persistence/sql.py

View check run for this annotation

Codecov / codecov/patch

jans-pycloudlib/jans/pycloudlib/persistence/sql.py#L225-L230

Added lines #L225 - L230 were not covered by tests
"mysql": {"type": "JSON"},
"pgsql": {"type": "JSONB"},
"spanner": {"type": "ARRAY<STRING(MAX)>"},
}
return json_types

Check warning on line 235 in jans-pycloudlib/jans/pycloudlib/persistence/sql.py

View check run for this annotation

Codecov / codecov/patch

jans-pycloudlib/jans/pycloudlib/persistence/sql.py#L235

Added line #L235 was not covered by tests

def get_attr_syntax(self, attr: str) -> str:
"""Get attribute syntax.
Expand Down

0 comments on commit 9cf11bc

Please sign in to comment.