@Test public void testGetFieldDefinition() { assertEquals( "FOO date", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), null, null, false, true, false ) ); assertEquals( "boolean", nativeMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), null, null, false, false, false ) ); assertEquals( "", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 0, 0 ), null, null, false, false, false ) ); assertEquals( "byteint", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 1, 0 ), null, null, false, false, false ) ); assertEquals( "byteint", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 2, 0 ), null, null, false, false, false ) ); assertEquals( "smallint", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 3, 0 ), null, null, false, false, false ) ); assertEquals( "smallint", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 4, 0 ), null, null, false, false, false ) ); for ( int i = 5; i < 10; i++ ) { assertEquals( "integer", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", i, 0 ), null, null, false, false, false ) ); } assertEquals( "bigint", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 10, 0 ), null, null, false, false, false ) ); assertEquals( "", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", -22, 3 ), null, null, false, false, false ) ); assertEquals( "", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 0, 3 ), null, null, false, false, false ) ); assertEquals( "real", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 1, 3 ), null, null, false, false, false ) ); assertEquals( "real", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 2, 3 ), null, null, false, false, false ) ); for ( int i = 3; i < 9; i++ ) { assertEquals( "real", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", i, 3 ), null, null, false, false, false ) ); } for ( int i = 10; i < 18; i++ ) { assertEquals( "double", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", i, 3 ), null, null, false, false, false ) ); } assertEquals( "numeric(18, 3)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 18, 3 ), null, null, false, false, false ) ); assertEquals( "numeric(19)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 19, -12 ), null, null, false, false, false ) ); assertEquals( "varchar(32767)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", ( NetezzaDatabaseMeta.MAX_CHAR_LEN + 2 ), 0 ), null, null, false, false, false ) ); assertEquals( "varchar(10)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 10, 0 ), null, null, false, false, false ) ); assertEquals( " UNKNOWN", nativeMeta.getFieldDefinition( new ValueMetaBinary( "FOO", 10, 0 ), null, null, false, false, false ) ); String lineSep = System.getProperty( "line.separator" ); assertEquals( " UNKNOWN" + lineSep, nativeMeta.getFieldDefinition( new ValueMetaBinary( "FOO", 10, 0 ), null, null, 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_DATE: retval += "date"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "boolean"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( length > 0 ) { if ( precision == 0 ) { if ( length <= 2 ) { retval += "byteint"; } else if ( length <= 4 ) { retval += "smallint"; } else if ( length <= 9 ) { retval += "integer"; } else { retval += "bigint"; } } else { if ( length < 9 ) { retval += "real"; } else if ( length < 18 ) { retval += "double"; } else { retval += "numeric(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > MAX_CHAR_LEN ) { retval += "varchar(" + MAX_CHAR_LEN + ")"; } else { retval += "varchar(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
NetezzaDatabaseMeta 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_DATE: retval += "date"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "boolean"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( length > 0 ) { if ( precision == 0 ) { if ( length <= 2 ) { retval += "byteint"; } else if ( length <= 4 ) { retval += "smallint"; } else if ( length <= 9 ) { retval += "integer"; } else { retval += "bigint"; } } else { if ( length < 9 ) { retval += "real"; } else if ( length < 18 ) { retval += "double"; } else { retval += "numeric(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > MAX_CHAR_LEN ) { retval += "varchar(" + MAX_CHAR_LEN + ")"; } else { retval += "varchar(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
NetezzaDatabaseMeta 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_DATE: retval += "date"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "boolean"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( length > 0 ) { if ( precision == 0 ) { if ( length <= 2 ) { retval += "byteint"; } else if ( length <= 4 ) { retval += "smallint"; } else if ( length <= 9 ) { retval += "integer"; } else { retval += "bigint"; } } else { if ( length < 9 ) { retval += "real"; } else if ( length < 18 ) { retval += "double"; } else { retval += "numeric(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > MAX_CHAR_LEN ) { retval += "varchar(" + MAX_CHAR_LEN + ")"; } else { retval += "varchar(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
NetezzaDatabaseMeta 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_DATE: retval += "date"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "boolean"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( length > 0 ) { if ( precision == 0 ) { if ( length <= 2 ) { retval += "byteint"; } else if ( length <= 4 ) { retval += "smallint"; } else if ( length <= 9 ) { retval += "integer"; } else { retval += "bigint"; } } else { if ( length < 9 ) { retval += "real"; } else if ( length < 18 ) { retval += "double"; } else { retval += "numeric(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > MAX_CHAR_LEN ) { retval += "varchar(" + MAX_CHAR_LEN + ")"; } 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 getSQLQueryFields( String tableName ); @Override String getSQLTableExists( String tablename ); @Override String getSQLColumnExists( String columnname, String tablename ); String getSQLQueryColumnFields( String columnname, String tableName ); @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 boolean supportsTimeStampToDateConversion(); @Override String[] getUsedLibraries(); }
NetezzaDatabaseMeta 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_DATE: retval += "date"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "boolean"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( length > 0 ) { if ( precision == 0 ) { if ( length <= 2 ) { retval += "byteint"; } else if ( length <= 4 ) { retval += "smallint"; } else if ( length <= 9 ) { retval += "integer"; } else { retval += "bigint"; } } else { if ( length < 9 ) { retval += "real"; } else if ( length < 18 ) { retval += "double"; } else { retval += "numeric(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > MAX_CHAR_LEN ) { retval += "varchar(" + MAX_CHAR_LEN + ")"; } 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 getSQLQueryFields( String tableName ); @Override String getSQLTableExists( String tablename ); @Override String getSQLColumnExists( String columnname, String tablename ); String getSQLQueryColumnFields( String columnname, String tableName ); @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 boolean supportsTimeStampToDateConversion(); @Override String[] getUsedLibraries(); static final int MAX_CHAR_LEN; }