aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/healthmarketscience
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/healthmarketscience')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/ColValidatorEvalContext.java12
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java6
2 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColValidatorEvalContext.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColValidatorEvalContext.java
index f5b490e..f55aa17 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/ColValidatorEvalContext.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColValidatorEvalContext.java
@@ -20,6 +20,8 @@ import java.io.IOException;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.InvalidValueException;
+import com.healthmarketscience.jackcess.expr.EvalException;
+import com.healthmarketscience.jackcess.expr.Identifier;
import com.healthmarketscience.jackcess.expr.Value;
import com.healthmarketscience.jackcess.impl.expr.Expressionator;
import com.healthmarketscience.jackcess.util.ColumnValidator;
@@ -66,6 +68,16 @@ public class ColValidatorEvalContext extends ColEvalContext
return toValue(_val, getCol().getType());
}
+ @Override
+ public Value getIdentifierValue(Identifier identifier) {
+ // col validators can only get "this" column, but they can refer to it by
+ // name
+ if(!getCol().isThisColumn(identifier)) {
+ throw new EvalException("Cannot access other fields for " + identifier);
+ }
+ return getThisColumnValue();
+ }
+
private Object validate(Column col, Object val) throws IOException {
try {
_val = val;
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
index 3063863..f195b12 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
@@ -50,6 +50,7 @@ import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.complex.ComplexColumnInfo;
import com.healthmarketscience.jackcess.complex.ComplexValue;
import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey;
+import com.healthmarketscience.jackcess.expr.Identifier;
import com.healthmarketscience.jackcess.impl.complex.ComplexValueForeignKeyImpl;
import com.healthmarketscience.jackcess.util.ColumnValidator;
import com.healthmarketscience.jackcess.util.SimpleColumnValidator;
@@ -2014,6 +2015,11 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl> {
return withErrorContext(msg, getDatabase(), getTable().getName(), getName());
}
+ boolean isThisColumn(Identifier identifier) {
+ return(getTable().isThisTable(identifier) &&
+ identifier.getObjectName().equalsIgnoreCase(getName()));
+ }
+
private static String withErrorContext(
String msg, DatabaseImpl db, String tableName, String colName) {
return msg + " (Db=" + db.getName() + ";Table=" + tableName + ";Column=" +