tizoc / ppx_pgsql

Syntax extension for embedded SQL queries using PG'OCaml.
BSD 3-Clause "New" or "Revised" License
52 stars 9 forks source link

pgocaml 4.0 support? #8

Closed swuecho closed 4 years ago

swuecho commented 4 years ago
### output ###
#       ocamlc ppx/.ppx_pgsql.objs/byte/ppx_pgsql.{cmi,cmo,cmt} (exit 2)
# (cd _build/default && /Users/hwu/.opam/4.08.1/bin/ocamlc.opt -w -40 -safe-string -g -bin-annot -I ppx/.ppx_pgsql.objs/byte -I /Users/hwu/.opam/4.08.1/lib/base -I /Users/hwu/.opam/4.08.1/lib/base/base_internalhash_types -I /Users/hwu/.opam/4.08.1/lib/base/caml -I /Users/hwu/.opam/4.08.1/lib/base/shadow_stdlib -I /Users/hwu/.opam/4.08.1/lib/bigarray-compat -I /Users/hwu/.opam/4.08.1/lib/bytes -[...]
# File "ppx/ppx_pgsql.ml", line 40, characters 4-24:
# 40 |     PGOCaml.name_of_type ?modifier oid
#          ^^^^^^^^^^^^^^^^^^^^
# Error: This function has type PGOCaml.oid -> string
#        It is applied to too many arguments; maybe you forgot a `;'.
tizoc commented 4 years ago

@swuecho my ocaml install is a bit broken at the moment so I cannot try the fix, but I see the ?modifier parameter is gone from that function, I think that removing all 3 references to that parameter in the name_of_type function in ppx/ppx_pgsql.ml (line 38) should do the trick.

Can you give that a try? If that works I will update the code (or you can submit a PR with that change if you want).

swuecho commented 4 years ago

@tizoc thanks for quick reply. I changed the modifier, but there are other problem.

### output ###
# 163 |         Re.get subs 3, Re.test subs 1, Re.test subs 2 in
# [...]
# Alert deprecated: Re.test
# Use Group.test
# File "ppx/ppx_pgsql.ml", line 163, characters 39-46:
# 163 |         Re.get subs 3, Re.test subs 1, Re.test subs 2 in
#                                              ^^^^^^^
# Alert deprecated: Re.test
# Use Group.test
# File "ppx/ppx_pgsql.ml", line 189, characters 30-67:
# 189 |          let to_string_func = [%expr PGOCaml.([%e to_string_func])] in
#                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: Unbound record field pexp_loc_stack
tizoc commented 4 years ago

I see. I think it is related to https://github.com/ocaml-ppx/ppx_tools/issues/77 and https://github.com/ocaml-ppx/ppx_tools/issues/75

One of those has been fixed, the other is still open but someone failed to reproduce the problem. Is your ppx_tools package up to date?

swuecho commented 4 years ago

my ocaml version is 4.08.1.

$ opam install ppx_tools    
[NOTE] Package ppx_tools is already installed (current version is 5.3+4.08.0).

same with bug reporter in ocaml-ppx/ppx_tools#77. I will create a 4.09 switch.

tizoc commented 4 years ago

I'm fixing my ocaml install, should be able to test this stuff soon.

swuecho commented 4 years ago

4.09 same problem.

tried the code in #77 in 4.08.1, works fine.

ocamlc -c -ppx ~/.opam/4.08.1/lib/ppx_tools/ppx_metaquot a.ml -I +compiler-libs -dsource let x = { Parsetree.pexp_desc = (Parsetree.Pexp_constant (Parsetree.Pconst_string ("test", None))); Parsetree.pexp_loc = (Stdlib.(!) Ast_helper.default_loc); Parsetree.pexp_loc_stack = []; Parsetree.pexp_attributes = [] }

maybe another bug in ppx_tools? I wish I know more ppx to understand what is going on.

tizoc commented 4 years ago

@swuecho I think I fixed it, will commit it in a bit

tizoc commented 4 years ago

@swuecho pushed, upgrade and see if it works for you

swuecho commented 4 years ago

work! thanks

tizoc commented 4 years ago

Fixed in https://github.com/tizoc/ppx_pgsql/commit/b94132f561e0fee5f5f27649859cb5834b716ab6 and https://github.com/tizoc/ppx_pgsql/commit/eb9980371fe96b30f68cbcbe40ef25a494341962

Closing.