Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions core/src/main/java/com/scalar/db/api/ConditionBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ public static ConditionalExpression buildConditionalExpression(
return new ConditionalExpression(column, operator);
}

/**
* Builds a like expression with the specified column, operator, and escape character.
*
* <p>This method is primarily for internal use. Breaking changes can and will be introduced to
* this method. Users should not depend on it.
*
* @param column a target text column used to compare
* @param operator an operator used to compare the target column. The operator must be either LIKE
* or NOT_LIKE.
* @param escape an escape character for the like operator
* @return a conditional expression
*/
public static ConditionalExpression buildLikeExpression(
TextColumn column, Operator operator, String escape) {
return new LikeExpression(column, operator, escape);
}

/**
* Returns a builder object for a condition expression for PutIf/DeleteIf
*
Expand Down Expand Up @@ -352,6 +369,7 @@ public ConditionalExpression isNotEqualToBlob(byte[] value) {
public ConditionalExpression isNotEqualToBlob(ByteBuffer value) {
return new ConditionalExpression(columnName, value, Operator.NE);
}

/**
* Creates a 'not equal' conditional expression for a DATE value.
*
Expand Down Expand Up @@ -391,6 +409,7 @@ public ConditionalExpression isNotEqualToTimestamp(LocalDateTime value) {
public ConditionalExpression isNotEqualToTimestampTZ(Instant value) {
return new ConditionalExpression(TimestampTZColumn.of(columnName, value), Operator.NE);
}

/**
* Creates a 'greater than' conditional expression for a BOOLEAN value.
*
Expand Down Expand Up @@ -590,6 +609,7 @@ public ConditionalExpression isGreaterThanOrEqualToBlob(byte[] value) {
public ConditionalExpression isGreaterThanOrEqualToBlob(ByteBuffer value) {
return new ConditionalExpression(columnName, value, Operator.GTE);
}

/**
* Creates a 'greater than or equal' conditional expression for a DATE value.
*
Expand Down Expand Up @@ -709,6 +729,7 @@ public ConditionalExpression isLessThanBlob(byte[] value) {
public ConditionalExpression isLessThanBlob(ByteBuffer value) {
return new ConditionalExpression(columnName, value, Operator.LT);
}

/**
* Creates a 'less than' conditional expression for a DATE value.
*
Expand Down Expand Up @@ -748,6 +769,7 @@ public ConditionalExpression isLessThanTimestamp(LocalDateTime value) {
public ConditionalExpression isLessThanTimestampTZ(Instant value) {
return new ConditionalExpression(TimestampTZColumn.of(columnName, value), Operator.LT);
}

/**
* Creates a 'less than or equal' conditional expression for a BOOLEAN value.
*
Expand Down Expand Up @@ -1029,6 +1051,7 @@ public ConditionalExpression isNotNullText() {
public ConditionalExpression isNotNullBlob() {
return new ConditionalExpression(BlobColumn.ofNull(columnName), Operator.IS_NOT_NULL);
}

/**
* Creates an 'is not null' conditional expression for a DATE value.
*
Expand Down
15 changes: 11 additions & 4 deletions core/src/main/java/com/scalar/db/api/LikeExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public class LikeExpression extends ConditionalExpression {
* Constructs a {@code LikeExpression} with the specified column and operator. For the escape
* character, the default one ("\", i.e., backslash) is used.
*
* @param column a target column used to compare
* @param operator an operator used to compare the target column
* @param column a target text column used to compare
* @param operator an operator used to compare the target text column. The operator must be either
* LIKE or NOT_LIKE.
*/
LikeExpression(TextColumn column, Operator operator) {
this(column, operator, DEFAULT_ESCAPE_CHAR);
Expand All @@ -28,8 +29,9 @@ public class LikeExpression extends ConditionalExpression {
* The escape character must be a string of a single character or an empty string. If an empty
* string is specified, the escape character is disabled.
*
* @param column a target column used to compare
* @param operator an operator used to compare the target column
* @param column a target text column used to compare
* @param operator an operator used to compare the target text column. The operator must be either
* LIKE or NOT_LIKE.
* @param escape an escape character for the like operator
*/
LikeExpression(TextColumn column, Operator operator, String escape) {
Expand Down Expand Up @@ -75,6 +77,11 @@ private void check(String pattern, Operator operator, String escape) {
}
}

@Override
public TextColumn getColumn() {
return (TextColumn) super.getColumn();
}

/**
* Returns the escape character for LIKE operator.
*
Expand Down
Loading