Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow creating helper functions for user registered clauses #381

Closed
shay-rf opened this issue Jan 22, 2022 · 2 comments
Closed

Allow creating helper functions for user registered clauses #381

shay-rf opened this issue Jan 22, 2022 · 2 comments
Assignees
Labels
documentation I need to write something up! enhancement

Comments

@shay-rf
Copy link

shay-rf commented Jan 22, 2022

As per #380 :
Once a clause has been registered to mimic existing clause, the usage of that clause is foreign to the surrounding code.

It would be nice if the ergonomics of the existing helpers can be exposed and made public to allow reuse.

Example:
(sql/register-clause! :qualify :having :window )
Usage:
(-> (h/select :*) (h/from :foo) (h/where [:= :a "a"]) (my-qualify [...] )

@seancorfield
Copy link
Owner

I definitely would not want register-clause! or register-fn! to automatically create a helper in the calling namespace (I don't think that's what you're suggesting but I want to clarify that this should be explicit).

Possibilities include:

  • exposing versions of generic and generic-1 with better names as public functions in honey.sql.helpers
  • providing machinery in honey.sql to define such helpers (via a macro -- which would be the first and only macro in HoneySQL)
  • simply documenting the private generic and generic-1 functions as a way to do this

(implied in #1 and #2: document the new functions/machinery)

@shay-rf
Copy link
Author

shay-rf commented Jan 24, 2022

For me, option 1 sounds proper - to allow users to participate in the helpers arena. And a bit more telling names for the public functions would assist with that.
A macro would be fine too.

@seancorfield seancorfield self-assigned this Jan 24, 2022
@seancorfield seancorfield added documentation I need to write something up! enhancement labels Jan 24, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
documentation I need to write something up! enhancement
Projects
None yet
Development

No branches or pull requests

2 participants