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

Constant string expressions for type provider parameters #11

Open
NickDarvey opened this issue Dec 10, 2021 · 1 comment
Open

Constant string expressions for type provider parameters #11

NickDarvey opened this issue Dec 10, 2021 · 1 comment

Comments

@NickDarvey
Copy link

Type providers like FSharp.Data.Npgsql accept a SQL string constant as a type argument.

e.g.

use cmd = DvdRental.CreateCommand<"SELECT title FROM public.film WHERE length > @longer_than">(dvdRental)

Can you think of a trick where this extension could reliably detect these strings? Nothing I've considered seems like good (or even possible) options:

  1. Extending this extension to allow configurable regex so users could define CreateCommand< as a match for SQL.
  2. Figuring a way to define an identity function named sql that can be used inside const().
@alfonsogarciacaro
Copy link
Owner

alfonsogarciacaro commented Dec 16, 2021

Probably with a comment, I was trying to avoid it because I found the function approach to be terser and because inline comments are not common in F#, but we'll likely need them for cases like this.

use cmd = DvdRental.CreateCommand<(* sql *) "SELECT title FROM public.film WHERE length > @longer_than">(dvdRental)

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