@Test public void testGetFieldDefinition() { assertEquals( "FOO DATETIME YEAR to FRACTION", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "DATETIME", nativeMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, false, false ) ); String[] typeCk = new String[] { "CHAR(1)", "BOOLEAN", "CHAR(1)" }; int i = ( nativeMeta.supportsBooleanDataType() ? 1 : 0 ); assertEquals( typeCk[i], nativeMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); odbcMeta.setSupportsBooleanDataType( !( odbcMeta.supportsBooleanDataType() ) ); assertEquals( typeCk[ i + 1 ], odbcMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); odbcMeta.setSupportsBooleanDataType( !( odbcMeta.supportsBooleanDataType() ) ); assertEquals( "SERIAL8", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", true, false, false ) ); assertEquals( "INTEGER PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) ); assertEquals( "INTEGER PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", -8, -3 ), "", "", false, false, false ) ); assertEquals( "FLOAT", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -8, -3 ), "", "", false, false, false ) ); assertEquals( "FLOAT", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 10, 3 ), "", "", false, false, false ) ); assertEquals( "FLOAT", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 10, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 9, 0 ), "", "", false, false, false ) ); assertEquals( "CLOB", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", DatabaseMeta.CLOB_LENGTH + 1, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(10)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 10, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(255)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 255, 0 ), "", "", false, false, false ) ); assertEquals( "LVARCHAR", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 256, 0 ), "", "", false, false, false ) ); assertEquals( "LVARCHAR", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 32767, 0 ), "", "", false, false, false ) ); assertEquals( "TEXT", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 32768, 0 ), "", "", false, false, false ) ); assertEquals( " UNKNOWN", nativeMeta.getFieldDefinition( new ValueMetaInternetAddress( "FOO" ), "", "", false, false, false ) ); assertEquals( " UNKNOWN" + System.getProperty( "line.separator" ), nativeMeta.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: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATETIME YEAR to FRACTION"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BOOLEAN"; } 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 += "SERIAL8"; } else { retval += "INTEGER PRIMARY KEY"; } } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "FLOAT"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { if ( length < 256 ) { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } } else { if ( length < 32768 ) { retval += "LVARCHAR"; } else { retval += "TEXT"; } } } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
InformixDatabaseMeta 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: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATETIME YEAR to FRACTION"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BOOLEAN"; } 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 += "SERIAL8"; } else { retval += "INTEGER PRIMARY KEY"; } } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "FLOAT"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { if ( length < 256 ) { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } } else { if ( length < 32768 ) { retval += "LVARCHAR"; } else { retval += "TEXT"; } } } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
InformixDatabaseMeta 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: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATETIME YEAR to FRACTION"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BOOLEAN"; } 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 += "SERIAL8"; } else { retval += "INTEGER PRIMARY KEY"; } } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "FLOAT"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { if ( length < 256 ) { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } } else { if ( length < 32768 ) { retval += "LVARCHAR"; } else { retval += "TEXT"; } } } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
InformixDatabaseMeta 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: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATETIME YEAR to FRACTION"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BOOLEAN"; } 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 += "SERIAL8"; } else { retval += "INTEGER PRIMARY KEY"; } } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "FLOAT"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { if ( length < 256 ) { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } } else { if ( length < 32768 ) { retval += "LVARCHAR"; } else { retval += "TEXT"; } } } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override int getNotFoundTK( boolean use_autoinc ); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean needsPlaceHolder(); @Override boolean needsToLockAllTables(); @Override String getSQLQueryFields( String tableName ); @Override String getSQLTableExists( String tablename ); @Override String getSQLColumnExists( String columnname, String tablename ); String getSQLQueryColumnFields( String columnname, String tableName ); @Override String getAddColumnStatement( 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 getSQLLockTables( String[] tableNames ); @Override String getSQLUnlockTables( String[] tableNames ); @Override String[] getUsedLibraries(); @Override String getSQLInsertAutoIncUnknownDimensionRow( String schemaTable, String keyField, String versionField ); }
InformixDatabaseMeta 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: retval += "DATETIME"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATETIME YEAR to FRACTION"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BOOLEAN"; } 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 += "SERIAL8"; } else { retval += "INTEGER PRIMARY KEY"; } } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "FLOAT"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { if ( length < 256 ) { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } } else { if ( length < 32768 ) { retval += "LVARCHAR"; } else { retval += "TEXT"; } } } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override int getNotFoundTK( boolean use_autoinc ); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean needsPlaceHolder(); @Override boolean needsToLockAllTables(); @Override String getSQLQueryFields( String tableName ); @Override String getSQLTableExists( String tablename ); @Override String getSQLColumnExists( String columnname, String tablename ); String getSQLQueryColumnFields( String columnname, String tableName ); @Override String getAddColumnStatement( 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 getSQLLockTables( String[] tableNames ); @Override String getSQLUnlockTables( String[] tableNames ); @Override String[] getUsedLibraries(); @Override String getSQLInsertAutoIncUnknownDimensionRow( String schemaTable, String keyField, String versionField );  }