Skip to content

Named parameters validation #84

Description

@sukolenvo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions