SettableByName and SettableById should set all occurrences of each variable

Description

In driver 3.x, SettableByNameData used to set all occurrences of each variable:

1 2 3 4 5 6 public T setInt(String name, int v) { for (int i : getAllIndexesOf(name)) { setInt(i, v); } return wrapped; }

This has changed in driver 4.x. SettableByName and SettableById implementations only set the first occurrence of each variable:

1 2 3 default SelfT setInt(@NonNull String name, int v) { return setInt(firstIndexOf(name), v); }

First off, this behavioral change is not mentioned in the upgrade guide.

Secondly, this change is concerning because there is no way to set the next occurrences of a given variable, apart from the very first one. If you don't know their indices, then you are stuck.

Thirdly, I don't really understand why we changed this behavior. Granted, it's not recommended to use the same bound variable name more than once, but this is perfectly valid CQL and supported by Cassandra. Moreover, ETL tools that generate queries can rely on this feature, e.g. to load one external value into two or more columns in a table, using a single query: INSERT INTO t1 (col1, col2) VALUES (:value, :value). This was perfectly possible with driver 3, but not possible with driver 4 anymore.

I would advocate to reinstate the original behavior. If this is not possible/desired, we need at least a way to access all the indices of a given variable name, i.e. implement an allIndicesOf(String) method in AccessibleByName and ColumnDefinitions, etc. (which of course is a breaking change).

Environment

None

Pull Requests

None

Status

Assignee

Unassigned

Reporter

Alexandre Dutra

Labels

None

PM Priority

None

Reproduced in

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

Doc Impact

None

Reviewer

None

Size

None

Fix versions

Affects versions

4.2.0

Priority

Major