forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgresConcatOperation.java
More file actions
32 lines (25 loc) · 1.07 KB
/
PostgresConcatOperation.java
File metadata and controls
32 lines (25 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package sqlancer.postgres.ast;
import sqlancer.ast.BinaryNode;
import sqlancer.postgres.PostgresSchema.PostgresDataType;
public class PostgresConcatOperation extends BinaryNode<PostgresExpression> implements PostgresExpression {
public PostgresConcatOperation(PostgresExpression left, PostgresExpression right) {
super(left, right);
}
@Override
public PostgresDataType getExpressionType() {
return PostgresDataType.TEXT;
}
@Override
public PostgresConstant getExpectedValue() {
if (getLeft().getExpectedValue().isNull() || getRight().getExpectedValue().isNull()) {
return PostgresConstant.createNullConstant();
}
String leftStr = getLeft().getExpectedValue().cast(PostgresDataType.TEXT).getUnquotedTextRepresentation();
String rightStr = getRight().getExpectedValue().cast(PostgresDataType.TEXT).getUnquotedTextRepresentation();
return PostgresConstant.createTextConstant(leftStr + rightStr);
}
@Override
public String getOperatorRepresentation() {
return "||";
}
}