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

Add an option to bypass double question mark #533

Closed
igrishaev opened this issue Jun 13, 2024 · 0 comments
Closed

Add an option to bypass double question mark #533

igrishaev opened this issue Jun 13, 2024 · 0 comments

Comments

@igrishaev
Copy link

As I mentioned in Slack, I use HoneySQL to generate a JSONpath expression for Postgres. JSONpath has got its own atmosphere, for example, it has the ? operator to filter the left part with a subquery:

$.track.segments[*].HR ? (@ > 130)

$.track.segments[*] ? (@.location[1] < 13.4) ? (@.HR > 130)."start time"

The thing is, whenever one uses the :? operator in HoneySQL, it produces a double ?? sign to comply with JDBC quoting rules.

At the moment, I've figured out with a crutch like this:

(def BLANK (keyword ""))

(sql/register-op! BLANK)

(defn ?-op [field1 field2]
  [BLANK field1 [:raw "?"] field2])

which produces

... field1 ? field2

I believe it would be nice to have an extra flag for the format function to bypass quoting the question mark. For example:

(honey.sql/format {sql-map} {:skip-?-quoting true})

or similar. The naming is completely up to you, I don't have any preferences. A dynamic var is also fine (just in case it's easier to tweak this behaviour with a dynamic var).

Links:

  • The Slack thread for more context: 1
  • PostgreSQL JSON path spec: 2
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

No branches or pull requests

1 participant