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

Feature request: PPX support format to include value #75

Open
Et7f3 opened this issue Aug 8, 2019 · 1 comment
Open

Feature request: PPX support format to include value #75

Et7f3 opened this issue Aug 8, 2019 · 1 comment

Comments

@Et7f3
Copy link
Contributor

Et7f3 commented Aug 8, 2019

~~

let a = 4 in
[%pgsql dbh "execute" "something $a"]

~~
I think it work fine but I have tested something="drop table" and something="select" the last one work under MySQL but don't under postgresql. So I shout manually escape and execute ... 😭

this is also in feature request: ```
let b = Printf.sprintf "something '%d'" 5 in
[%pgsql dbh "execute" b]


EDIT: explain why I have strike text.
@Et7f3 Et7f3 changed the title PPX support format to include value Feature request: PPX support format to include value Aug 8, 2019
@chrismamo1
Copy link
Contributor

I'm not sure I understand your first problem. Can you please provide more details?

As for the feature request:

let b = Printf.sprintf "something '%d'" 5 in
[%pgsql dbh "execute" b]

This is impossible, because of how the PPX works. The SQL expression (the string at the end of [% ... ]) is dealt with entirely at compile time, and cannot be made from a runtime value. Please let me know if this is clear enough, or check https://github.com/darioteixeira/pgocaml/blob/master/doc/HOW_IT_WORKS.txt for a better (albeit slightly outdated) explanation.

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

2 participants