Skip to content

Conversation

@majiayu000
Copy link
Contributor

Summary

This PR implements PostgreSQL JSON path query functions as part of #4216:

  • New Jsonpath SQL type: Added support for PostgreSQL's jsonpath type with OID 4072
  • 24 new functions implemented:
    • jsonb_path_exists (with _with_vars and _with_vars_and_silent variants)
    • jsonb_path_match (with _with_vars and _with_vars_and_silent variants)
    • jsonb_path_query_array (with _with_vars and _with_vars_and_silent variants)
    • jsonb_path_query_first (with _with_vars and _with_vars_and_silent variants)
    • All timezone-aware _tz variants for the above functions

Each function includes:

  • Full documentation with examples
  • Support for nullable types
  • #[auto_type] test coverage

Test plan

  • Code compiles with cargo check -p diesel --features "postgres serde_json"
  • Code formatting passes cargo fmt --all -- --check
  • Added #[auto_type] tests for all new functions
  • Run full test suite with PostgreSQL database

Related issues

Partially addresses #4216

majiayu000 and others added 2 commits December 26, 2025 11:40
This commit implements the following PostgreSQL JSON path functions:
- jsonb_path_exists (with variants for vars, silent)
- jsonb_path_match (with variants for vars, silent)
- jsonb_path_query_array (with variants for vars, silent)
- jsonb_path_query_first (with variants for vars, silent)

Also adds timezone-aware variants (_tz) for all the above functions.

Closes: diesel-rs#4216 (partial)
Signed-off-by: majiayu000 <[email protected]>
Add all jsonb_path_* function types to the list of shadowed types
in make_proxy_mod macro to prevent duplicate re-export errors when
both helper_types_proxy and expression_dsl_proxy glob-import these
types.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@weiznich weiznich requested a review from a team December 28, 2025 08:36
Copy link
Member

@weiznich weiznich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this PR and sorry for taking that long to have at least an initial look at the change.

Overall this addition looks good to me. I still want to verify the null value handling on the newly added functions and see if there is a reasonable set of tests there. Hopefully I get that done next week.

Otherwise the tests still seem to fail with a failure related to this change. Would you mind having a look at that? Do you need help there?

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.

2 participants