diff options
author | James Moger <james.moger@gmail.com> | 2011-08-08 09:40:16 -0400 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2011-08-08 09:40:16 -0400 |
commit | f7485f5f18e49cef057782c0c3137e64a5af542c (patch) | |
tree | 79de8f5bd850724328aa42eadfe87dfa9dd0ecc5 /src | |
parent | 083e5031c24efd8cdb08140b9f982604a431ec26 (diff) | |
download | iciql-f7485f5f18e49cef057782c0c3137e64a5af542c.tar.gz iciql-f7485f5f18e49cef057782c0c3137e64a5af542c.zip |
Simplified dialect lookup.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/iciql/Db.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/com/iciql/Db.java b/src/com/iciql/Db.java index f70a37e..7873313 100644 --- a/src/com/iciql/Db.java +++ b/src/com/iciql/Db.java @@ -89,15 +89,16 @@ public class Db { SQLDialect getDialect(String clazz) {
// try dialect by connection class name
Class<? extends SQLDialect> dialectClass = DIALECTS.get(clazz);
- int lastDot = 0;
while (dialectClass == null) {
- // try dialect by package name
- int nextDot = clazz.indexOf('.', lastDot);
- if (nextDot > -1) {
- String pkg = clazz.substring(0, nextDot);
- lastDot = nextDot + 1;
- dialectClass = DIALECTS.get(pkg);
- } else {
+ // try dialect by registered name
+ for (String registeredName : DIALECTS.keySet()) {
+ if (clazz.indexOf(registeredName) > -1) {
+ dialectClass = DIALECTS.get(registeredName);
+ break;
+ }
+ }
+ if (dialectClass == null) {
+ // did not find a match, use default
dialectClass = DefaultSQLDialect.class;
}
}
@@ -246,8 +247,7 @@ public class Db { // check to see if upgrade is required.
if ((model.value() > dbVersion.version) && (dbUpgrader != null)) {
// database is an older version than the model
- boolean success = dbUpgrader
- .upgradeDatabase(this, dbVersion.version, model.value());
+ boolean success = dbUpgrader.upgradeDatabase(this, dbVersion.version, model.value());
if (success) {
dbVersion.version = model.value();
update(dbVersion);
|