diff options
author | James Moger <james.moger@gmail.com> | 2011-08-11 14:04:01 -0400 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2011-08-11 14:04:01 -0400 |
commit | 0333ed4cf0b5db3f9ffcb0da31787f6e44139af5 (patch) | |
tree | a0c0c57e38dd5e8e48e03b2aa4ad8a2c39bff189 /src/com/iciql/SQLDialectMySQL.java | |
parent | f3faeb5d1ea631b0074441f97080e1f2a9145f4b (diff) | |
download | iciql-0333ed4cf0b5db3f9ffcb0da31787f6e44139af5.tar.gz iciql-0333ed4cf0b5db3f9ffcb0da31787f6e44139af5.zip |
Added support for HSQL database. Revised dialects some more.
Moved CREATE TABLE and CREATE INDEX statement generation to the dialect.
Added DECIMAL(length, scale) support.
Improved automatic dialect detection.
Unspecified length string is now CLOB instead of TEXT.
Boolean now maps to BOOLEAN instead of BIT.
Expressions on unmapped fields will throw an IciqlException.
Improved exception reporting.
Diffstat (limited to 'src/com/iciql/SQLDialectMySQL.java')
-rw-r--r-- | src/com/iciql/SQLDialectMySQL.java | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/src/com/iciql/SQLDialectMySQL.java b/src/com/iciql/SQLDialectMySQL.java index 837d77b..2593e0a 100644 --- a/src/com/iciql/SQLDialectMySQL.java +++ b/src/com/iciql/SQLDialectMySQL.java @@ -16,7 +16,6 @@ package com.iciql;
-import com.iciql.TableDefinition.FieldDefinition;
import com.iciql.TableDefinition.IndexDefinition;
import com.iciql.util.StatementBuilder;
@@ -26,13 +25,16 @@ import com.iciql.util.StatementBuilder; public class SQLDialectMySQL extends SQLDialectDefault {
@Override
- public boolean supportsMemoryTables() {
- return false;
+ protected String convertSqlType(String sqlType) {
+ if (sqlType.equals("CLOB")) {
+ return "TEXT";
+ }
+ return sqlType;
}
-
+
@Override
- public boolean supportsMerge() {
- return true;
+ public boolean supportsMemoryTables() {
+ return false;
}
@Override
@@ -41,7 +43,15 @@ public class SQLDialectMySQL extends SQLDialectDefault { }
@Override
- public String prepareCreateIndex(String schema, String table, IndexDefinition index) {
+ protected boolean prepareColumnDefinition(StatementBuilder buff, boolean isAutoIncrement, boolean isPrimaryKey) {
+ if (isAutoIncrement) {
+ buff.append(" AUTO_INCREMENT");
+ }
+ return false;
+ }
+
+ @Override
+ public void prepareCreateIndex(SQLStatement stat, String schema, String table, IndexDefinition index) {
StatementBuilder buff = new StatementBuilder();
buff.append("CREATE ");
switch (index.type) {
@@ -74,26 +84,6 @@ public class SQLDialectMySQL extends SQLDialectDefault { buff.append("USING HASH");
break;
}
- return buff.toString().trim();
- }
-
- @Override
- public <T> void prepareMerge(SQLStatement stat, String schemaName, String tableName, TableDefinition<T> def, Object obj) {
- StatementBuilder buff = new StatementBuilder("REPLACE INTO ");
- buff.append(prepareTableName(schemaName, tableName)).append('(');
- for (FieldDefinition field : def.fields) {
- buff.appendExceptFirst(", ");
- buff.append(prepareColumnName(field.columnName));
- }
- buff.append(") VALUES(");
- buff.resetCount();
- for (FieldDefinition field : def.fields) {
- buff.appendExceptFirst(", ");
- buff.append('?');
- Object value = def.getValue(obj, field);
- stat.addParameter(value);
- }
- buff.append(')');
- stat.setSQL(buff.toString());
+ stat.setSQL(buff.toString().trim());
}
}
\ No newline at end of file |