Cassandra Bind Marker Substitution - #1805
Open
gonzalotguerrero wants to merge 4 commits into
Open
gonzalotguerrero wants to merge 4 commits into
gonzalotguerrero wants to merge 4 commits into
Conversation
gonzalotguerrero
added this pull request to stack #1804
September 29, 2026 06:35
jgaleotti
requested changes
Sep 29, 2026
| * @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) { |
Collaborator
There was a problem hiding this comment.
rename cql to parameterizedQuery
Collaborator
There was a problem hiding this comment.
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) { |
Collaborator
There was a problem hiding this comment.
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); |
Collaborator
There was a problem hiding this comment.
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)); |
| @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); |
jgaleotti
requested changes
Sep 29, 2026
| @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) { |
Collaborator
There was a problem hiding this comment.
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); |
Collaborator
There was a problem hiding this comment.
rename vales as parameterValues
jgaleotti
approved these changes
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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