This is an automated email from the ASF dual-hosted git repository.
bbotella pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 527f145df2 CASSANDRA-21852: LENGTH and OCTET_LENGTH constraint fix
from CASSANDRA-21817 is missing on trunk
527f145df2 is described below
commit 527f145df2043f255d3096c041cbdf91e9188293
Author: Bernardo Botella <[email protected]>
AuthorDate: Wed Oct 28 09:17:26 2026 +0100
CASSANDRA-21852: LENGTH and OCTET_LENGTH constraint fix from
CASSANDRA-21817 is missing on trunk
Re-apply 7e9d49d7c3 (CASSANDRA-21817) on trunk. Merge 8df9c97ea1
(cassandra-6.0 into trunk)
dropped its changes to LengthConstraint, OctetLengthConstraint and
ConstraintArgumentsTest;
only the CHANGES.txt entry reached trunk.
patch by Bernardo Botella; reviewed by Stefan Miklosovic for CASSANDRA-21817
(cherry picked from commit 7e9d49d7c385d76d3550664353995e2f7df029b8)
---
.../cassandra/cql3/constraints/LengthConstraint.java | 2 +-
.../cql3/constraints/OctetLengthConstraint.java | 2 +-
.../cassandra/constraints/ConstraintArgumentsTest.java | 16 ++++++++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git
a/src/java/org/apache/cassandra/cql3/constraints/LengthConstraint.java
b/src/java/org/apache/cassandra/cql3/constraints/LengthConstraint.java
index 26e0f08eeb..aaab23d883 100644
--- a/src/java/org/apache/cassandra/cql3/constraints/LengthConstraint.java
+++ b/src/java/org/apache/cassandra/cql3/constraints/LengthConstraint.java
@@ -92,7 +92,7 @@ public class LengthConstraint extends ConstraintFunction
}
catch (Exception e)
{
- throw new InvalidConstraintDefinitionException(format("String '%s'
is not a valid int", Integer.parseInt(term)));
+ throw new InvalidConstraintDefinitionException(format("String '%s'
is not a valid int", term));
}
}
diff --git
a/src/java/org/apache/cassandra/cql3/constraints/OctetLengthConstraint.java
b/src/java/org/apache/cassandra/cql3/constraints/OctetLengthConstraint.java
index 5482a17bcd..865d250083 100644
--- a/src/java/org/apache/cassandra/cql3/constraints/OctetLengthConstraint.java
+++ b/src/java/org/apache/cassandra/cql3/constraints/OctetLengthConstraint.java
@@ -78,7 +78,7 @@ public class OctetLengthConstraint extends ConstraintFunction
}
catch (Exception e)
{
- throw new InvalidConstraintDefinitionException(format("String '%s'
is not a valid int", Integer.parseInt(term)));
+ throw new InvalidConstraintDefinitionException(format("String '%s'
is not a valid int", term));
}
}
diff --git
a/test/unit/org/apache/cassandra/constraints/ConstraintArgumentsTest.java
b/test/unit/org/apache/cassandra/constraints/ConstraintArgumentsTest.java
index 289c8ceb64..26e417c184 100644
--- a/test/unit/org/apache/cassandra/constraints/ConstraintArgumentsTest.java
+++ b/test/unit/org/apache/cassandra/constraints/ConstraintArgumentsTest.java
@@ -30,6 +30,7 @@ import org.apache.cassandra.cql3.Operator;
import org.apache.cassandra.cql3.constraints.ColumnConstraint;
import org.apache.cassandra.cql3.constraints.ColumnConstraints;
import org.apache.cassandra.cql3.constraints.ConstraintFunction;
+import org.apache.cassandra.cql3.constraints.ConstraintResolver;
import org.apache.cassandra.cql3.constraints.ConstraintViolationException;
import
org.apache.cassandra.cql3.constraints.InvalidConstraintDefinitionException;
import org.apache.cassandra.cql3.constraints.UnaryConstraintFunction;
@@ -54,6 +55,21 @@ public class ConstraintArgumentsTest
private static final ColumnIdentifier columnIdentifier = new
ColumnIdentifier("a_column", false);
private static final ColumnMetadata columnMetadata = new
ColumnMetadata("a", "b", columnIdentifier, UTF8Type.instance,
ColumnMetadata.NO_UNIQUE_ID, -1, REGULAR, null);
+ @Test
+ public void testPrepareRejectsMalformedTermWithInvalidDefinition()
+ {
+ // "*abc" is neither a valid int nor a valid regular expression. Every
built-in function must
+ // report that through InvalidConstraintDefinitionException.
+ String term = "*abc";
+ for (ConstraintResolver.Functions function :
ConstraintResolver.Functions.values())
+ {
+ assertThatThrownBy(() ->
function.functionCreator.apply(List.of()).prepare(term))
+ .describedAs("Function %s", function)
+ .isInstanceOf(InvalidConstraintDefinitionException.class)
+ .hasMessageContaining(term);
+ }
+ }
+
@Test
public void testDeserOfContraintsWithArguments() throws Throwable
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]