Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pycloudlib): set default values for JSONB column #2651

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-jans-auth-server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pinned to py3-grpcio version to avoid failure on native extension build
grpcio==1.41.0
libcst<0.4
git+https://github.com/JanssenProject/jans@e74ea8e27e59d35ff6e3c6f997e6c1df6a04ec83#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@7a59327522eac064cf03c296c71593dea506cd75#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
2 changes: 1 addition & 1 deletion docker-jans-certmanager/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
grpcio==1.41.0
click==6.7
libcst<0.4
git+https://github.com/JanssenProject/jans@e74ea8e27e59d35ff6e3c6f997e6c1df6a04ec83#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@7a59327522eac064cf03c296c71593dea506cd75#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
2 changes: 1 addition & 1 deletion docker-jans-config-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pinned to py3-grpcio version to avoid failure on native extension build
grpcio==1.41.0
libcst<0.4
git+https://github.com/JanssenProject/jans@e74ea8e27e59d35ff6e3c6f997e6c1df6a04ec83#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@7a59327522eac064cf03c296c71593dea506cd75#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
2 changes: 1 addition & 1 deletion docker-jans-configurator/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ click==6.7
marshmallow==3.10.0
fqdn==1.4.0
libcst<0.4
git+https://github.com/JanssenProject/jans@e74ea8e27e59d35ff6e3c6f997e6c1df6a04ec83#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@7a59327522eac064cf03c296c71593dea506cd75#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
2 changes: 1 addition & 1 deletion docker-jans-fido2/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pinned to py3-grpcio version to avoid failure on native extension build
grpcio==1.41.0
libcst<0.4
git+https://github.com/JanssenProject/jans@e74ea8e27e59d35ff6e3c6f997e6c1df6a04ec83#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@7a59327522eac064cf03c296c71593dea506cd75#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
2 changes: 1 addition & 1 deletion docker-jans-persistence-loader/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
grpcio==1.41.0
libcst<0.4
ruamel.yaml==0.16.10
git+https://github.com/JanssenProject/jans@e74ea8e27e59d35ff6e3c6f997e6c1df6a04ec83#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@7a59327522eac064cf03c296c71593dea506cd75#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
2 changes: 1 addition & 1 deletion docker-jans-scim/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pinned to py3-grpcio version to avoid failure on native extension build
grpcio==1.41.0
libcst<0.4
git+https://github.com/JanssenProject/jans@e74ea8e27e59d35ff6e3c6f997e6c1df6a04ec83#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@7a59327522eac064cf03c296c71593dea506cd75#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
12 changes: 10 additions & 2 deletions jans-pycloudlib/jans/pycloudlib/persistence/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,19 @@ def insert_into(self, table_name: str, column_mapping: dict[str, _t.Any]) -> Non

for column in table.c:
unmapped = column.name not in column_mapping
is_json = column.type.__class__.__name__.lower() == "json"

if self.dialect == "mysql":
json_type = "json"
json_default_values: dict[str, _t.Any] | list[_t.Any] = {"v": []}
else:
json_type = "jsonb"
json_default_values = []

is_json = bool(column.type.__class__.__name__.lower() == json_type)

if not all([unmapped, is_json]):
continue
column_mapping[column.name] = {"v": []}
column_mapping[column.name] = json_default_values

query = table.insert().values(column_mapping)
with self.engine.connect() as conn:
Expand Down