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: make query value substitution template more permissive #21

Open
mgmeier opened this issue Sep 22, 2015 · 3 comments
Open

Comments

@mgmeier
Copy link

mgmeier commented Sep 22, 2015

Currently, the template INSERT INTO table (a, b) VALUES (?, UNIX_TIMESTAMP(?)) fails in formatError with the message "foo". Obviously, the regex used in formatError can't match the the '?' characters in templates like the one given above.

My suggestion is to perform substition more closely oriented to '?'-characters, und thus make the template more permissive by allowing SQL expressions inside.

Maybe, #12 could be addressed simultaneously, if a method other than regex matching is chosen for checking the template's well- or ill-formedness / splitting the query into template and non-template parts.

NB. buildQuery, which performs the actual substitution of the '?' characters, seems permissive enough at first glance...

@mgmeier
Copy link
Author

mgmeier commented Sep 23, 2015

I'd be willing to implement and send you a PR; I'd just need to know if this feature is desired at all, the way I proposed it, or if it doesn't fit the concept somehow.

mgmeier referenced this issue in mgmeier/mysql-simple Sep 29, 2015
@mgmeier
Copy link
Author

mgmeier commented Sep 29, 2015

I just submitted PR #23, please review.

  • Tested: formatMany extracts substition group form template correctly
  • Untested: buildQuery correctly fills substitution group
  • Untouched: version nr. bump, formatMany comment

Thanks for considering.

@mgmeier
Copy link
Author

mgmeier commented Jan 19, 2016

Bump.
Since I'm using mysql-simple in an active project... did you give changing the syntax of the query value substitution template any thoughts?

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

1 participant