@Test public void testGetFieldDefinition() { assertEquals( "FOO TIMESTAMP", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "TIMESTAMP", 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( "BIGSERIAL", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) ); assertEquals( "BIGSERIAL", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 8, 0 ), "", "FOO", false, false, false ) ); assertEquals( "NUMERIC(10, 5)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 10, 5 ), "", "", false, false, false ) ); assertEquals( "NUMERIC(19, 0)", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 19, 0 ), "", "", false, false, false ) ); assertEquals( "BIGINT", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 9, 0 ), "", "", false, false, false ) ); assertEquals( "SMALLINT", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 4, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 5, 0 ), "", "", false, false, false ) ); assertEquals( "DOUBLE PRECISION", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -7, -3 ), "", "", false, false, false ) ); assertEquals( "TEXT", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", DatabaseMeta.CLOB_LENGTH + 1, 0 ), "", "", false, false, false ) ); assertEquals( "TEXT", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 0, 0 ), "", "", false, false, false ) ); assertEquals( "TEXT", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO" ), "", "", false, false, false ) ); assertEquals( "VARCHAR(15)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 15, 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: case ValueMetaInterface.TYPE_DATE: retval += "TIMESTAMP"; 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 ) ) { retval += "BIGSERIAL"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "NUMERIC(" + length + ", " + precision + ")"; } else { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length < 5 ) { retval += "SMALLINT"; } else { retval += "INTEGER"; } } } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length < 1 || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "TEXT"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
KingbaseESDatabaseMeta 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 += "TIMESTAMP"; 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 ) ) { retval += "BIGSERIAL"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "NUMERIC(" + length + ", " + precision + ")"; } else { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length < 5 ) { retval += "SMALLINT"; } else { retval += "INTEGER"; } } } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length < 1 || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "TEXT"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
KingbaseESDatabaseMeta 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 += "TIMESTAMP"; 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 ) ) { retval += "BIGSERIAL"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "NUMERIC(" + length + ", " + precision + ")"; } else { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length < 5 ) { retval += "SMALLINT"; } else { retval += "INTEGER"; } } } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length < 1 || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "TEXT"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
KingbaseESDatabaseMeta 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 += "TIMESTAMP"; 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 ) ) { retval += "BIGSERIAL"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "NUMERIC(" + length + ", " + precision + ")"; } else { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length < 5 ) { retval += "SMALLINT"; } else { retval += "INTEGER"; } } } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length < 1 || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "TEXT"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override String getExtraOptionSeparator(); @Override String getExtraOptionIndicator(); @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean isFetchSizeSupported(); @Override boolean supportsBitmapIndex(); @Override boolean supportsSynonyms(); @Override boolean supportsSequences(); @Override boolean supportsAutoInc(); @Override String getLimitClause( int nrRows ); @Override String getSQLNextSequenceValue( String sequenceName ); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLSequenceExists( String sequenceName ); @Override String getSQLListOfSequences(); @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 ); String getSQLListOfProcedures( String schemaName ); @Override String[] getReservedWords(); @Override String getSQLLockTables( String[] tableNames ); @Override String getSQLUnlockTables( String[] tableName ); @Override boolean isDefaultingToUppercase(); @Override String[] getUsedLibraries(); @Override boolean supportsTimeStampToDateConversion(); }
KingbaseESDatabaseMeta 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 += "TIMESTAMP"; 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 ) ) { retval += "BIGSERIAL"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "NUMERIC(" + length + ", " + precision + ")"; } else { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length < 5 ) { retval += "SMALLINT"; } else { retval += "INTEGER"; } } } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length < 1 || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "TEXT"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override String getExtraOptionSeparator(); @Override String getExtraOptionIndicator(); @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean isFetchSizeSupported(); @Override boolean supportsBitmapIndex(); @Override boolean supportsSynonyms(); @Override boolean supportsSequences(); @Override boolean supportsAutoInc(); @Override String getLimitClause( int nrRows ); @Override String getSQLNextSequenceValue( String sequenceName ); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLSequenceExists( String sequenceName ); @Override String getSQLListOfSequences(); @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 ); String getSQLListOfProcedures( String schemaName ); @Override String[] getReservedWords(); @Override String getSQLLockTables( String[] tableNames ); @Override String getSQLUnlockTables( String[] tableName ); @Override boolean isDefaultingToUppercase(); @Override String[] getUsedLibraries(); @Override boolean supportsTimeStampToDateConversion();  }