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

Feat/json queries #8

Merged
merged 4 commits into from
Jan 31, 2024
Merged

Feat/json queries #8

merged 4 commits into from
Jan 31, 2024

Conversation

pjwerneck
Copy link
Owner

@pjwerneck pjwerneck commented Dec 10, 2023

This PR adds handling for JSON columns.

  • It works with the generic sqlalchemy.JSON. Should work with vendor-specific JSON types.
  • JSON fields are resolved as an operation with the getitem operator, therefore it should work seamlessly with normal columns and relationships, regardless of nesting levels or dict/array targets.
  • JSON values are automatically cast to the type of the other operand during comparisons. Only JSON types are supported: string, boolean, integer, float. Numbers can be cast to float or decimal, depending on the type of the other operand.
  • Equality comparisons against missing keys or JSON null values are converted to JSON.NULL, avoiding the different semantics from SQL null.

It doesn't seem appropriate to test query generation and results with
another query. Creating the expected result set in pure python is
simpler and more robust.
@pjwerneck
Copy link
Owner Author

@stout-yeoman Any suggestions before I merge this?

- Handles missing key comparisons as JSON null instead of SQL null
- Handles decimals
@pjwerneck pjwerneck merged commit 5857a71 into develop Jan 31, 2024
5 checks passed
@pjwerneck pjwerneck deleted the feat/json-queries branch January 31, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant