Skip to content

Cassandra Bind Marker Substitution - #1805

Open
gonzalotguerrero wants to merge 4 commits into
feature/cassandra-e2e-with-data-generationfrom
fix/cassandra-bind-marker-substitution
Open

gonzalotguerrero wants to merge 4 commits into
feature/cassandra-e2e-with-data-generationfrom
fix/cassandra-bind-marker-substitution

Conversation

@gonzalotguerrero

Copy link
Copy Markdown
Collaborator

The aim of this fix is to capture the actual literal values for CQL queries using prepared statements. Currently, such values are being captured as '?'

Also, a minimum length of 1 is set for StringGenes in Cassandra insertions if the text value is meant to belong to a partition key column

@gonzalotguerrero
gonzalotguerrero added this pull request to stack #1804 September 29, 2026 06:35
* @param values the values bound to it, in order
* @return the CQL with its markers replaced by literals, or {@code cql} unchanged on any problem
*/
public static String forPositionalValues(Object cqlSession, String cql, Object[] values) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename cql to parameterizedQuery

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and values to parameterValues

* @param values the values bound to it, by marker name
* @return the CQL with its markers replaced by literals, or {@code cql} unchanged on any problem
*/
public static String forNamedValues(Object cqlSession, String cql, Map<String, Object> values) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename cql to parameterizedQuery and values to parameterValues

@Replacement(type = ReplacementType.TRACKER, id = CASSANDRA_EXECUTE_STRING_POSITIONAL_VALUES_SYNC, usageFilter = UsageFilter.ANY, category = ReplacementCategory.CASSANDRA, castTo = RESULT_SET_CLASS)
public static Object execute(Object cqlSession, String query, Object... values) {
return handleCqlExecute(CASSANDRA_EXECUTE_STRING_POSITIONAL_VALUES_SYNC, cqlSession, query, query, values);
String tracked = CqlBindMarkerInterpolator.forPositionalValues(cqlSession, query, values);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename query to parameterizedQuery and tracked to interpolatedQuery

@Replacement(type = ReplacementType.TRACKER, id = CASSANDRA_EXECUTE_STATEMENT_SYNC, usageFilter = UsageFilter.ANY, category = ReplacementCategory.CASSANDRA, castTo = RESULT_SET_CLASS)
public static Object execute(Object cqlSession, @ThirdPartyCast(actualType = STATEMENT_CLASS) Object statement) {
return handleCqlExecute(CASSANDRA_EXECUTE_STATEMENT_SYNC, cqlSession, extractQueryText(statement), statement);
String tracked = CqlBindMarkerInterpolator.forStatement(cqlSession, statement, extractQueryText(statement));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as before

@Replacement(type = ReplacementType.TRACKER, id = CASSANDRA_EXECUTE_STRING_NAMED_VALUES_SYNC, usageFilter = UsageFilter.ANY, category = ReplacementCategory.CASSANDRA, castTo = RESULT_SET_CLASS)
public static Object execute(Object cqlSession, String query, Map<String, Object> values) {
return handleCqlExecute(CASSANDRA_EXECUTE_STRING_NAMED_VALUES_SYNC, cqlSession, query, query, values);
String tracked = CqlBindMarkerInterpolator.forNamedValues(cqlSession, query, values);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

@Replacement(type = ReplacementType.TRACKER, id = CASSANDRA_EXECUTE_STRING_POSITIONAL_VALUES_SYNC, usageFilter = UsageFilter.ANY, category = ReplacementCategory.CASSANDRA, castTo = RESULT_SET_CLASS)
public static Object execute(Object cqlSession, String query, Object... values) {
return handleCqlExecute(CASSANDRA_EXECUTE_STRING_POSITIONAL_VALUES_SYNC, cqlSession, query, query, values);
public static Object execute(Object cqlSession, String parameterisedQuery, Object... values) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename vales as parameterValues

public static Object execute(Object cqlSession, String query, Map<String, Object> values) {
return handleCqlExecute(CASSANDRA_EXECUTE_STRING_NAMED_VALUES_SYNC, cqlSession, query, query, values);
public static Object execute(Object cqlSession, String parameterisedQuery, Map<String, Object> values) {
String interpolatedQuery = CqlBindMarkerInterpolator.forNamedValues(cqlSession, parameterisedQuery, values);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename vales as parameterValues

@jgaleotti
jgaleotti requested a review from arcuri82 September 29, 2026 20:42
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 this pull request may close these issues.

2 participants