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

Return friendly errors when bind variables are not set #92

Open
rkarthik007 opened this issue Mar 9, 2018 · 0 comments
Open

Return friendly errors when bind variables are not set #92

rkarthik007 opened this issue Mar 9, 2018 · 0 comments
Assignees
Labels
kind/bug This issue is a bug
Projects

Comments

@rkarthik007
Copy link
Collaborator

rkarthik007 commented Mar 9, 2018

Running into an issue with the nodejs driver where one of the bind params was undefined.

Nodejs insert code:

    const insert = "INSERT INTO yb_ecommerce.products " +
                 "  (id, name, description, price, author, type, img, category)" +
                 " VALUES" +
                 "  (?, ?, ?, ?, ?, ?, ?, ?);"

    var insert_batch = [];
    // for loop here
    insert_batch.push({
      query: insert,
      params: params
    });

  client.batch(insert_batch, { prepare: true }, function(err) {
    ...
  });

The error I got back was:

E0308 21:28:51.414309 78086144 process_context.cc:180] SQL Error: Invalid Arguments. Runtime error (yb/yql/cql/cqlserver/cql_message.cc:131): Invalid bind variable kind -2
INSERT INTO yb_ecommerce.products   (id, name, description, price, author, type, img, category) VALUES  (?, ?, ?, ?, ?, ?, ?, ?);

@kmuthukk pointed out that in the code we do:

case Value::Kind::NOT_SET:
      break;
  }
  return STATUS_SUBSTITUTE(
      RuntimeError, "Invalid bind variable kind $0", static_cast<int>(v->kind));

where v->kind (an enum)'s value for NOT_SET is -2.

Rather than report the cryptic "-2", we should instead return a clear error and also indicate the bind position.

For example, for the NOT_SET case, we should instead return an error along the lines of:

   "No bind specified for bind position %d"
@rkarthik007 rkarthik007 added the kind/bug This issue is a bug label Mar 9, 2018
@rkarthik007 rkarthik007 added this to To Do in YCQL via automation Mar 9, 2018
@robertpang robertpang assigned robertpang and unassigned nocaway Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This issue is a bug
Projects
YCQL
  
To Do
Status: No status
Development

No branches or pull requests

3 participants