From f7485f5f18e49cef057782c0c3137e64a5af542c Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 8 Aug 2011 09:40:16 -0400 Subject: Simplified dialect lookup. --- src/com/iciql/Db.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') 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 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); -- cgit v1.2.3