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

Named parameters validation #84

Open
sukolenvo opened this issue Nov 14, 2020 · 0 comments
Open

Named parameters validation #84

sukolenvo opened this issue Nov 14, 2020 · 0 comments

Comments

@sukolenvo
Copy link

Typo in parameter names caused us several bugs in production that could be picked up earlier. For example we have table:

CREATE TABLE users (id SERIAL, email TEXT, name TEXT, country TEXT, state TEXT address TEXT);

Insert code might look like:

fluentJdbc.query().update(
        "INSERT INTO user(email, name, country, state, address)" +
        " VALUES (:email, :fullName, :county, :state, :address)")
    .namedParam("email", request.getEmail())
    .namedParam("name", request.getFullName())
    .namedParam("country", request.getCountry())
    .namedParam("state", request.getState())
    .namedParam("address", request.getAddress())
    .run();

No exception thrown in tests, although code has two bugs:

  • name doesn't match :fullName
  • :county is typo for :country

I can see that there was this check in previous version, and then it was removed. I wonder what problems it caused, maybe there is another solution that will allow to keep this validation? daf8343#diff-e0612eba839ffc6fa7d0ea686ebbe5133199025df224686564a13da7045c14a9L280

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 a pull request may close this issue.

1 participant