Navigation Menu

Skip to content

Commit

Permalink
0001272: Add support for the MySQL POINT data type.
Browse files Browse the repository at this point in the history
  • Loading branch information
abrougher committed Jun 11, 2013
1 parent 12f0b30 commit af50b14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -98,6 +98,7 @@ public abstract class TypeMap

public static final String SQLXML = "SQLXML";
public static final String GEOMETRY = "GEOMETRY";
public static final String POINT = "POINT";
public static final String UUID = "UUID";
public static final String VARBIT = "VARBIT";
public static final String INTERVAL = "INTERVAL";
Expand Down
Expand Up @@ -33,6 +33,7 @@
import org.jumpmind.db.model.IIndex;
import org.jumpmind.db.model.Reference;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.model.TypeMap;
import org.jumpmind.db.platform.AbstractJdbcDdlReader;
import org.jumpmind.db.platform.DatabaseMetaDataWrapper;
import org.jumpmind.db.platform.IDatabasePlatform;
Expand All @@ -41,7 +42,7 @@
* Reads a database model from a MySql database.
*/
public class MySqlDdlReader extends AbstractJdbcDdlReader {

private Boolean mariaDbDriver = null;

public MySqlDdlReader(IDatabasePlatform platform) {
Expand All @@ -50,7 +51,7 @@ public MySqlDdlReader(IDatabasePlatform platform) {
setDefaultSchemaPattern(null);
setDefaultTablePattern(null);
}

@Override
protected String getResultSetCatalogName() {
if (isMariaDbDriver()) {
Expand Down Expand Up @@ -109,6 +110,10 @@ protected Column readColumn(DatabaseMetaDataWrapper metaData, Map<String, Object
if ("".equals(column.getDefaultValue())) {
column.setDefaultValue(null);
}

if (column.getJdbcTypeName().equalsIgnoreCase(TypeMap.POINT)) {
column.setJdbcTypeName(TypeMap.GEOMETRY);
}
return column;
}

Expand All @@ -125,14 +130,14 @@ protected boolean isInternalForeignKeyIndex(Connection connection,
// MySql defines a non-unique index of the same name as the fk
return getPlatform().getDdlBuilder().getForeignKeyName(table, fk).equals(index.getName());
}

protected boolean isMariaDbDriver() {
if (mariaDbDriver == null) {
if (mariaDbDriver == null) {
mariaDbDriver = "mariadb-jdbc".equals(getPlatform().getSqlTemplate().getDriverName());
}
return mariaDbDriver;
}

@Override
protected Collection<ForeignKey> readForeignKeys(Connection connection,
DatabaseMetaDataWrapper metaData, String tableName) throws SQLException {
Expand Down

0 comments on commit af50b14

Please sign in to comment.