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

Add support for named parameters #49

Closed
chshersh opened this issue Oct 23, 2018 · 1 comment
Closed

Add support for named parameters #49

chshersh opened this issue Oct 23, 2018 · 1 comment
Assignees
Labels
enhancement New feature or request interface Everything related to the exposed interface

Comments

@chshersh
Copy link
Contributor

MySQL doesn't support named parameters on the protocol level. So the only possible way to implement named parameters in our library is the following:

  1. Introduce data type data NamedParam = NamedParam Text Param (where Text is the name of the parameter).
  2. Implement functions executeNamed and queryNamed with types:
queryNamed :: FromRow row => MySQLConn -> Query -> [NamedParam] -> IO [row]

These function will parse Query and replace all occurrences of :nameOfTheParameter with ? and rearrange arguments in [NamedParam] list according to their occurrence in the Query. And then these functions just delegate their arguments to query and execute functions.

Regarding parsing of Query: I propose that after : only alphanumeric characters and underscores are allowed. I hope that : is not used anywhere in MySQL...

Any thoughts on this?

@chshersh
Copy link
Contributor Author

This issue is done 🎉 🎆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request interface Everything related to the exposed interface
Projects
None yet
Development

No branches or pull requests

2 participants