/
NikolayIvkin
/
sqlancer2
Обзор
Документация
Войти
/
NikolayIvkin
/
sqlancer2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/sqlancer/postgres/ast/PostgresInOperation.java
65 строк
2 KB
Manuel Rigger
[Postgres] Let getExpectedValue() return null when no PQS implementation is available
25 авг 2020, 14:08
25 авг 2020, 14:08
205b394
Код
Авторство
О чём код?
package sqlancer.postgres.ast; import java.util.List; import sqlancer.postgres.PostgresSchema.PostgresDataType; public class PostgresInOperation implements PostgresExpression { private final PostgresExpression expr; private final List<PostgresExpression> listElements; private final boolean isTrue; public PostgresInOperation(PostgresExpression expr, List<PostgresExpression> listElements, boolean isTrue) { this.expr = expr; this.listElements = listElements; this.isTrue = isTrue; } public PostgresExpression getExpr() { return expr; } public List<PostgresExpression> getListElements() { return listElements; } @Override public PostgresConstant getExpectedValue() { PostgresConstant leftValue = expr.getExpectedValue(); if (leftValue == null) { return null; } if (leftValue.isNull()) { return PostgresConstant.createNullConstant(); } boolean isNull = false; for (PostgresExpression expr : getListElements()) { PostgresConstant rightExpectedValue = expr.getExpectedValue(); if (rightExpectedValue == null) { return null; } if (rightExpectedValue.isNull()) { isNull = true; } else if (rightExpectedValue.isEquals(this.expr.getExpectedValue()).isBoolean() && rightExpectedValue.isEquals(this.expr.getExpectedValue()).asBoolean()) { return PostgresConstant.createBooleanConstant(isTrue); } } if (isNull) { return PostgresConstant.createNullConstant(); } else { return PostgresConstant.createBooleanConstant(!isTrue); } } public boolean isTrue() { return isTrue; } @Override public PostgresDataType getExpressionType() { return PostgresDataType.BOOLEAN; } }