jbochi / lua-resty-cassandra

Pure Lua Cassandra client using CQL binary protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bind variadic parameters list

thibaultcha opened this issue · comments

According to this feature, and given this prepared statement:

UPDATE some_table SET counter = counter + 1 WHERE col1 = ? AND period IN (?);

Does lua-resty-cassandra support the binding of such a parameter (the second one)? I cannot find any information cassandra's documentation or the definition of the binary protocol about how such a parameter should be binded to the statement.

I also noticed that the prepared statement returns this for the column:

{
  keyspace = "some_keyspace",
  name = "period",
  table = "some_table",
  type = {
    id = 13
  }
}

It seems that id = 13 (0x0D) is of type varchar. So it seems like the statement is expecting a string for this parameter.

I tried using some of the types (cassandra.list for example) with no success. Any help about wether or not this feature is supported, or how to support it (where to find documentation about it, as it would be my pleasure to contribute to the driver) would be greatly appreciated.

Thanks!

I was not aware of this feature, thanks for letting me know.

It actually worked without any code modification. See 49ce1d8 for an example.

As in the nodejs driver, you should not use parenthesis in the CQL string and the argument should be a list (annotated with cassandra.list)

Let me know if this works for you.

Damn! I did try without the parenthesis, but I missed to combine this with cassandra.list!

It works very well, thank you!

you're welcome!