aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/changes/changes.xml6
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/Database.java10
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java4
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/IndexTest.java62
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java6
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/FKEnforcerTest.java5
6 files changed, 52 insertions, 41 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b7dc79d..c2f9668 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -9,6 +9,12 @@
Add support for Access 97 general collation order, enabling indexes to
be used with Access 97 dbs.
</action>
+ <action dev="jahlborn" type="add">
+ Add Stream support to all interfaces which are Iterable.
+ </action>
+ <action dev="jahlborn" type="update">
+ Enabled expression evaluation by default.
+ </action>
</release>
<release version="3.0.1" date="2019-04-13">
<action dev="jahlborn" type="update">
diff --git a/src/main/java/com/healthmarketscience/jackcess/Database.java b/src/main/java/com/healthmarketscience/jackcess/Database.java
index 7a27f69..7e9dd85 100644
--- a/src/main/java/com/healthmarketscience/jackcess/Database.java
+++ b/src/main/java/com/healthmarketscience/jackcess/Database.java
@@ -129,8 +129,8 @@ public interface Database extends Iterable<Table>, Closeable, Flushable
public static final String ALLOW_AUTONUM_INSERT_PROPERTY =
"com.healthmarketscience.jackcess.allowAutoNumberInsert";
- /** system property which can be used to enable expression evaluation
- * (currently experimental). Defaults to {@code false}.
+ /** system property which can be used to disable expression evaluation
+ * if necessary. Defaults to {@code true}.
* @usage _general_field_
*/
public static final String ENABLE_EXPRESSION_EVALUATION_PROPERTY =
@@ -514,14 +514,14 @@ public interface Database extends Iterable<Table>, Closeable, Flushable
/**
* Gets the current expression evaluation policy. Expression evaluation is
- * currently an experimental feature, and is therefore disabled by default.
+ * enabled by default but can be disabled if necessary.
*/
public boolean isEvaluateExpressions();
/**
* Sets the current expression evaluation policy. Expression evaluation is
- * currently an experimental feature, and is therefore disabled by default.
- * If {@code null}, resets to the default value.
+ * enabled by default but can be disabled if necessary. If {@code null},
+ * resets to the default value.
* @usage _intermediate_method_
*/
public void setEvaluateExpressions(Boolean evaluateExpressions);
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
index 3a63818..71b4c5e 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
@@ -2100,7 +2100,7 @@ public class DatabaseImpl implements Database, DateTimeContext
/**
* Returns the default enable expression evaluation policy. This defaults to
- * {@code false}, but can be overridden using the system
+ * {@code true}, but can be overridden using the system
* property {@value com.healthmarketscience.jackcess.Database#ENABLE_EXPRESSION_EVALUATION_PROPERTY}.
* @usage _advanced_method_
*/
@@ -2110,7 +2110,7 @@ public class DatabaseImpl implements Database, DateTimeContext
if(prop != null) {
return Boolean.TRUE.toString().equalsIgnoreCase(prop);
}
- return false;
+ return true;
}
/**
diff --git a/src/test/java/com/healthmarketscience/jackcess/IndexTest.java b/src/test/java/com/healthmarketscience/jackcess/IndexTest.java
index 47f7b89..8633dea 100644
--- a/src/test/java/com/healthmarketscience/jackcess/IndexTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/IndexTest.java
@@ -67,7 +67,7 @@ public class IndexTest extends TestCase {
assertTrue(ByteUtil.asUnsignedByte(b3) < ByteUtil.asUnsignedByte(b4));
assertTrue(ByteUtil.asUnsignedByte(b4) < ByteUtil.asUnsignedByte(b5));
}
-
+
public void testByteCodeComparator() {
byte[] b0 = null;
byte[] b1 = new byte[]{(byte)0x00};
@@ -85,7 +85,7 @@ public class IndexTest extends TestCase {
IndexData.BYTE_CODE_COMPARATOR);
sortedSet.addAll(expectedList);
assertEquals(expectedList, new ArrayList<byte[]>(sortedSet));
-
+
}
public void testPrimaryKey() throws Exception {
@@ -98,7 +98,7 @@ public class IndexTest extends TestCase {
index.isPrimaryKey());
if(index.isPrimaryKey()) {
pkIndex= index;
-
+
}
}
Map<String, Boolean> expectedPKs = new HashMap<String, Boolean>();
@@ -108,7 +108,7 @@ public class IndexTest extends TestCase {
assertSame(pkIndex, table.getPrimaryKeyIndex());
}
}
-
+
public void testLogicalIndexes() throws Exception
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX, true)) {
@@ -234,6 +234,8 @@ public class IndexTest extends TestCase {
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX_PROPERTIES)) {
Database db = openCopy(testDB);
+ db.setEvaluateExpressions(false);
+
doTestIgnoreNulls(db, "TableIgnoreNulls1");
doTestIgnoreNulls(db, "TableIgnoreNulls2");
@@ -254,7 +256,7 @@ public class IndexTest extends TestCase {
temp.addRow(orig.asRow(row));
}
- assertEquals(origI.getIndexData().getEntryCount(),
+ assertEquals(origI.getIndexData().getEntryCount(),
tempI.getIndexData().getEntryCount());
Cursor origC = origI.newCursor().toCursor();
@@ -272,7 +274,7 @@ public class IndexTest extends TestCase {
Cursor.Position origCurPos = origC.getSavepoint().getCurrentPosition();
Map<String,Object> tempRow = tempC.getCurrentRow();
Cursor.Position tempCurPos = tempC.getSavepoint().getCurrentPosition();
-
+
assertEquals(origRow, tempRow);
assertEquals(IndexCodesTest.entryToString(origCurPos),
IndexCodesTest.entryToString(tempCurPos));
@@ -388,7 +390,7 @@ public class IndexTest extends TestCase {
final Row row = c.getCurrentRow();
// Row order is arbitrary, so v2007 row order difference is valid
- if (testDB.getExpectedFileFormat().ordinal() >=
+ if (testDB.getExpectedFileFormat().ordinal() >=
Database.FileFormat.V2007.ordinal()) {
TestUtil.checkTestDBTable1RowA(testDB, table, row);
} else {
@@ -405,7 +407,7 @@ public class IndexTest extends TestCase {
db.close();
}
}
-
+
public void testReplId() throws Exception
{
for (final TestDB testDB : SUPPORTED_DBS_TEST) {
@@ -436,8 +438,8 @@ public class IndexTest extends TestCase {
assertEquals(1, t.getIndexes().size());
IndexImpl idx = (IndexImpl)t.getIndexes().get(0);
-
- assertEquals(IndexBuilder.PRIMARY_KEY_NAME, idx.getName());
+
+ assertEquals(IndexBuilder.PRIMARY_KEY_NAME, idx.getName());
assertEquals(1, idx.getColumns().size());
assertEquals("id", idx.getColumns().get(0).getName());
assertTrue(idx.getColumns().get(0).isAscending());
@@ -459,9 +461,9 @@ public class IndexTest extends TestCase {
assertEquals("row" + i, row.get("data"));
}
assertFalse(c.moveToNextRow());
- }
+ }
}
-
+
public void testIndexCreationSharedData() throws Exception
{
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
@@ -479,8 +481,8 @@ public class IndexTest extends TestCase {
assertEquals(4, t.getIndexes().size());
IndexImpl idx = (IndexImpl)t.getIndexes().get(0);
-
- assertEquals(IndexBuilder.PRIMARY_KEY_NAME, idx.getName());
+
+ assertEquals(IndexBuilder.PRIMARY_KEY_NAME, idx.getName());
assertEquals(1, idx.getColumns().size());
assertEquals("id", idx.getColumns().get(0).getName());
assertTrue(idx.getColumns().get(0).isAscending());
@@ -512,7 +514,7 @@ public class IndexTest extends TestCase {
assertFalse(c.moveToNextRow());
}
}
-
+
public void testGetForeignKeyIndex() throws Exception
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX, true)) {
@@ -538,12 +540,12 @@ public class IndexTest extends TestCase {
assertTrue(t3t1.getReference().isCascadeUpdates());
assertFalse(t3t1.getReference().isCascadeDeletes());
doCheckForeignKeyIndex(t1, t3t1, t3);
-
+
Index t1pk = t1.getIndex(IndexBuilder.PRIMARY_KEY_NAME);
assertNotNull(t1pk);
assertNull(((IndexImpl)t1pk).getReference());
assertNull(t1pk.getReferencedIndex());
- }
+ }
}
public void testConstraintViolation() throws Exception
@@ -591,7 +593,7 @@ public class IndexTest extends TestCase {
IndexCursor pkCursor = CursorBuilder.createPrimaryKeyCursor(t);
assertCursor(expectedRows, pkCursor);
- assertCursor(expectedRows,
+ assertCursor(expectedRows,
CursorBuilder.createCursor(t.getIndex("data_ind")));
List<Object[]> batch = new ArrayList<Object[]>();
@@ -614,10 +616,10 @@ public class IndexTest extends TestCase {
expectedRows.add(createExpectedRow("id", 6, "data", "row6"));
assertTable(expectedRows, t);
-
+
assertCursor(expectedRows, pkCursor);
- assertCursor(expectedRows,
+ assertCursor(expectedRows,
CursorBuilder.createCursor(t.getIndex("data_ind")));
pkCursor.findFirstRowByEntry(4);
@@ -631,16 +633,16 @@ public class IndexTest extends TestCase {
} catch(ConstraintViolationException ce) {
// success
}
-
+
assertTable(expectedRows, t);
-
+
assertCursor(expectedRows, pkCursor);
- assertCursor(expectedRows,
+ assertCursor(expectedRows,
CursorBuilder.createCursor(t.getIndex("data_ind")));
db.close();
- }
+ }
}
public void testAutoNumberRecover() throws Exception
@@ -667,7 +669,7 @@ public class IndexTest extends TestCase {
} catch(ConstraintViolationException ce) {
// success
}
-
+
t.addRow(null, "row3");
assertEquals(3, t.getRowCount());
@@ -686,7 +688,7 @@ public class IndexTest extends TestCase {
IndexCursor pkCursor = CursorBuilder.createPrimaryKeyCursor(t);
assertCursor(expectedRows, pkCursor);
- assertCursor(expectedRows,
+ assertCursor(expectedRows,
CursorBuilder.createCursor(t.getIndex("data_ind")));
List<Object[]> batch = new ArrayList<Object[]>();
@@ -708,16 +710,16 @@ public class IndexTest extends TestCase {
expectedRows.add(createExpectedRow("id", 5, "data", "row5"));
assertTable(expectedRows, t);
-
+
assertCursor(expectedRows, pkCursor);
- assertCursor(expectedRows,
+ assertCursor(expectedRows,
CursorBuilder.createCursor(t.getIndex("data_ind")));
db.close();
}
}
-
+
public void testBinaryIndex() throws Exception
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.BINARY_INDEX)) {
@@ -746,7 +748,7 @@ public class IndexTest extends TestCase {
boolean found = false;
for(Row idxRow : ic.newEntryIterable(data)) {
-
+
assertTrue(Arrays.equals(data, idxRow.getBytes(colName)));
if(id == idxRow.getInt("ID")) {
found = true;
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java
index b5afcd3..29ea9ac 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java
@@ -68,6 +68,8 @@ public class CalcFieldTest extends TestCase
Database db = create(fileFormat);
+ db.setEvaluateExpressions(false);
+
Table t = new TableBuilder("Test")
.putProperty("awesome_table", true)
.addColumn(new ColumnBuilder("id", DataType.LONG)
@@ -89,7 +91,7 @@ public class CalcFieldTest extends TestCase
assertTrue(col.isCalculated());
assertEquals("[id] & \"_\" & [data]", col.getProperties().getValue(
PropertyMap.EXPRESSION_PROP));
- assertEquals(DataType.TEXT.getValue(),
+ assertEquals(DataType.TEXT.getValue(),
col.getProperties().getValue(
PropertyMap.RESULT_TYPE_PROP));
@@ -163,7 +165,7 @@ public class CalcFieldTest extends TestCase
assertEquals(expectedRows, rows);
db.close();
- }
+ }
}
}
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/FKEnforcerTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/FKEnforcerTest.java
index 2567f12..9f02481 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/FKEnforcerTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/FKEnforcerTest.java
@@ -63,13 +63,14 @@ public class FKEnforcerTest extends TestCase
db.close();
}
-
+
}
public void testEnforceForeignKeys() throws Exception {
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX)) {
Database db = openCopy(testDB);
+ db.setEvaluateExpressions(false);
Table t1 = db.getTable("Table1");
Table t2 = db.getTable("Table2");
Table t3 = db.getTable("Table3");
@@ -132,7 +133,7 @@ public class FKEnforcerTest extends TestCase
db.close();
}
-
+
}
private static Row createT1Row(