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
Support querying for JSON data in external sql pillar. #59777
Conversation
ffd96d9
to
5a0554b
Compare
I added changelog entry in format PR#.added as I did not create issue before. Is it ok, or should I create issue and link issue instead? |
905d42b
to
2ea5efe
Compare
Implements #60905 |
2255513
to
fbb5309
Compare
@Ch3LL could you or someone in the core team have a look at this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbosdo Looks great! Just one comment that needs addressing, then I can go ahead and approve 👍 thanks!
Several SQL databases support native JSON storage. When storing pillars in this way, SQL query result already returns dict and without the need to have key column.
Use salt.utils.update() to recursively merge the JSON dicts of the returned SQL queries.
f373340
to
46b63e5
Compare
salt/pillar/sql_base.py
Outdated
@@ -147,6 +174,9 @@ | |||
|
|||
Configuration of the connection depends on the adapter in use. | |||
|
|||
.. versionadded:: 3005 | |||
The *to_json* parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The *to_json* parameter. | |
The *as_json* parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed now
Congratulations on your first PR being merged! 🎉 |
What does this PR do?
Querying database for single column JSON data (like postgres JSONB) returns dict. Dict is not hashable and results in error in sql external pillar. This PR add option
as_json
which assumes that the query result is dict and merges result with returning pillar dict.What issues does this PR fix or reference?
Fixes:
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
No
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.