@Test public void testGetFieldDefinition() { assertEquals( "FOO DATETIME", odbcMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "DATETIME", odbcMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, false, false ) ); assertFalse( odbcMeta.supportsBooleanDataType() ); assertEquals( "CHAR(1)", odbcMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); odbcMeta.setSupportsBooleanDataType( true ); assertEquals( "BIT", odbcMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); odbcMeta.setSupportsBooleanDataType( false ); assertEquals( "COUNTER PRIMARY KEY", odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", true, false, false ) ); assertEquals( "LONG PRIMARY KEY", odbcMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) ); assertEquals( "LONG PRIMARY KEY", odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", false, false, false ) ); assertEquals( "INTEGER", odbcMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 4, 0 ), "", "", false, false, false ) ); assertEquals( "LONG", odbcMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 6, 0 ), "", "", false, false, false ) ); assertEquals( "LONG", odbcMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 9, 0 ), "", "", false, false, false ) ); assertEquals( "DOUBLE", odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 10, 0 ), "", "", false, false, false ) ); assertEquals( "DOUBLE", odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 10, 1 ), "", "", false, false, false ) ); assertEquals( "DOUBLE", odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 3, 1 ), "", "", false, false, false ) ); assertEquals( "DOUBLE", odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 3, -5 ), "", "", false, false, false ) ); assertEquals( "DOUBLE", odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -3, -5 ), "", "", false, false, false ) ); assertEquals( "TEXT(255)", odbcMeta.getFieldDefinition( new ValueMetaString( "FOO", 255, 0 ), "", "", false, false, false ) ); assertEquals( "TEXT(1)", odbcMeta.getFieldDefinition( new ValueMetaString( "FOO", 1, 0 ), "", "", false, false, false ) ); assertEquals( "MEMO", odbcMeta.getFieldDefinition( new ValueMetaString( "FOO", 256, 0 ), "", "", false, false, false ) ); assertEquals( "TEXT", odbcMeta.getFieldDefinition( new ValueMetaString( "FOO", 0, 0 ), "", "", false, false, false ) ); assertEquals( "TEXT", odbcMeta.getFieldDefinition( new ValueMetaString( "FOO" ), "", "", false, false, false ) ); assertEquals( " LONGBINARY", odbcMeta.getFieldDefinition( new ValueMetaBinary( "FOO", 200, 1 ), "", "", false, false, false ) ); assertEquals( " UNKNOWN", odbcMeta.getFieldDefinition( new ValueMetaInternetAddress( "FOO" ), "", "", false, false, false ) ); assertEquals( " UNKNOWN" + System.getProperty( "line.separator" ), odbcMeta.getFieldDefinition( new ValueMetaInternetAddress( "FOO" ), "", "", false, false, true ) ); }
@Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { if ( use_autoinc ) { retval += "COUNTER PRIMARY KEY"; } else { retval += "LONG PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "DOUBLE"; } else { if ( length > 5 ) { retval += "LONG"; } else { retval += "INTEGER"; } } } else { retval += "DOUBLE"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length < 256 ) { retval += "TEXT(" + length + ")"; } else { retval += "MEMO"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += " LONGBINARY"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
MSAccessDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { if ( use_autoinc ) { retval += "COUNTER PRIMARY KEY"; } else { retval += "LONG PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "DOUBLE"; } else { if ( length > 5 ) { retval += "LONG"; } else { retval += "INTEGER"; } } } else { retval += "DOUBLE"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length < 256 ) { retval += "TEXT(" + length + ")"; } else { retval += "MEMO"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += " LONGBINARY"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
MSAccessDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { if ( use_autoinc ) { retval += "COUNTER PRIMARY KEY"; } else { retval += "LONG PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "DOUBLE"; } else { if ( length > 5 ) { retval += "LONG"; } else { retval += "INTEGER"; } } } else { retval += "DOUBLE"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length < 256 ) { retval += "TEXT(" + length + ")"; } else { retval += "MEMO"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += " LONGBINARY"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
MSAccessDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { if ( use_autoinc ) { retval += "COUNTER PRIMARY KEY"; } else { retval += "LONG PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "DOUBLE"; } else { if ( length > 5 ) { retval += "LONG"; } else { retval += "INTEGER"; } } } else { retval += "DOUBLE"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length < 256 ) { retval += "TEXT(" + length + ")"; } else { retval += "MEMO"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += " LONGBINARY"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override boolean supportsSetCharacterStream(); @Override int getNotFoundTK( boolean use_autoinc ); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean isFetchSizeSupported(); @Override @SuppressWarnings( "deprecation" ) String getSchemaTableCombination( String schema_name, String table_part ); @Override int getMaxTextFieldLength(); @Override boolean supportsTransactions(); @Override boolean supportsBitmapIndex(); @Override boolean supportsSetLong(); @Override boolean supportsViews(); @Override boolean supportsSynonyms(); @Override String getTruncateTableStatement( String tableName ); @Override String getAddColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getDropColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getModifyColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc,
    boolean add_fieldname, boolean add_cr ); @Override String[] getReservedWords(); @Override String getStartQuote(); @Override String getEndQuote(); @Override String[] getUsedLibraries(); @Override boolean supportsGetBlob(); @Override boolean checkIndexExists( Database database, String schemaName, String tableName, String[] idx_fields ); @Override String getSQLInsertAutoIncUnknownDimensionRow( String schemaTable, String keyField, String versionField ); }
MSAccessDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { if ( use_autoinc ) { retval += "COUNTER PRIMARY KEY"; } else { retval += "LONG PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "DOUBLE"; } else { if ( length > 5 ) { retval += "LONG"; } else { retval += "INTEGER"; } } } else { retval += "DOUBLE"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length < 256 ) { retval += "TEXT(" + length + ")"; } else { retval += "MEMO"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += " LONGBINARY"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override boolean supportsSetCharacterStream(); @Override int getNotFoundTK( boolean use_autoinc ); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean isFetchSizeSupported(); @Override @SuppressWarnings( "deprecation" ) String getSchemaTableCombination( String schema_name, String table_part ); @Override int getMaxTextFieldLength(); @Override boolean supportsTransactions(); @Override boolean supportsBitmapIndex(); @Override boolean supportsSetLong(); @Override boolean supportsViews(); @Override boolean supportsSynonyms(); @Override String getTruncateTableStatement( String tableName ); @Override String getAddColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getDropColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getModifyColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc,
    boolean add_fieldname, boolean add_cr ); @Override String[] getReservedWords(); @Override String getStartQuote(); @Override String getEndQuote(); @Override String[] getUsedLibraries(); @Override boolean supportsGetBlob(); @Override boolean checkIndexExists( Database database, String schemaName, String tableName, String[] idx_fields ); @Override String getSQLInsertAutoIncUnknownDimensionRow( String schemaTable, String keyField, String versionField );  }