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

allow variables from environment in queries in ppx #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxtori
Copy link
Contributor

@maxtori maxtori commented Jan 7, 2022

This allows to set for example table names depending on the environment:
[%pgsql dbh "var=FOO" "select * from table_$FOO"]
compiled with FOO=42 dune build will select rows from table_42

Verified

This commit was signed with the committer’s verified signature.
brandonkelly Brandon Kelly
match Sys.getenv_opt v with
| None -> q
| Some nv ->
Re.Str.global_replace (Re.Str.regexp ("\\$" ^ v)) nv q) query vars in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor stylistic gripe here. It's a bit hard to read this with query vars tucked in on the last line like that. I would spread it out a bit more so it's clear this isn't a partial application of fold_left.

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

Successfully merging this pull request may close these issues.

None yet

2 participants