roddyyaga / ppx_rapper

Syntax extension for writing SQL in OCaml
Other
139 stars 18 forks source link

Add list and custom type support in the style of ppx_mysql #1

Closed anmonteiro closed 4 years ago

anmonteiro commented 4 years ago

This diff does a few things:

  1. ports from core to base which is much lighter weight
  2. Adds list support in the input parameters
  3. As part of 2. a new sub-library is added which makes this PPX have a small runtime for dynamic parameters in the style of https://github.com/paurkedal/ocaml-caqti/issues/15#issuecomment-386793041

There are a couple things left to do here:

Note: because queries containing list parameters are dynamically constructed, they need to be ~oneshot:true as per Caqti's docs.

roddyyaga commented 4 years ago

Thanks, this is great. I'll take a closer look tomorrow.

anmonteiro commented 4 years ago

Just added support for custom types too, and I'm gonna work on adding some docs to the README.

I tried to separate this PR into different relevant commits, so while it's become a little large, it's still best reviewed commit by commit. Let me know if you want me to open different PRs instead.

roddyyaga commented 4 years ago

Single PR is fine; everything looks good. Is there anything else you want to add to this PR? Will merge if not.

mxmzdlv commented 4 years ago

It seems that new base types (e.g. ptime) don't work:

Fatal error: exception Error in ppx_rapper: Unknown type specification 'ptime'.

I think new types need to be added to build_param function in query.mll

anmonteiro commented 4 years ago

oh good point, I'll fix later

anmonteiro commented 4 years ago

I just fixed the support for ptime and all the other added types. Thanks again for pointing it out, @mxmzdlv