summaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2008-03-13 04:03:29 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2008-03-13 04:03:29 +0000
commit4885e4e69fda95d74a7e50e5a0636b4696066650 (patch)
tree505b2116d106c5e9515202c708aeaba6f4298304 /src/java
parentd4113e1b68d70f20ab1ef56669d28554213e5e22 (diff)
downloadjackcess-4885e4e69fda95d74a7e50e5a0636b4696066650.tar.gz
jackcess-4885e4e69fda95d74a7e50e5a0636b4696066650.zip
always return relationships in same order regardless of table parameter order; add some simple relationship unit tests
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@269 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/java')
-rw-r--r--src/java/com/healthmarketscience/jackcess/Database.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java
index be2587b..6d510df 100644
--- a/src/java/com/healthmarketscience/jackcess/Database.java
+++ b/src/java/com/healthmarketscience/jackcess/Database.java
@@ -488,10 +488,20 @@ public class Database
_relationships = readTable(TABLE_SYSTEM_RELATIONSHIPS,
_relationshipsPageNumber);
}
-
- if(ObjectUtils.equals(table1.getName(), table2.getName())) {
+
+ int nameCmp = table1.getName().compareTo(table2.getName());
+ if(nameCmp == 0) {
throw new IllegalArgumentException("Must provide two different tables");
}
+ if(nameCmp > 0) {
+ // we "order" the two tables given so that we will return a collection
+ // of relationships in the same order regardless of whether we are given
+ // (TableFoo, TableBar) or (TableBar, TableFoo).
+ Table tmp = table1;
+ table1 = table2;
+ table2 = tmp;
+ }
+
List<Relationship> relationships = new ArrayList<Relationship>();
Cursor cursor = createCursorWithOptionalIndex(