@Test public void testGetFieldDefinition() { assertEquals( "FOO DATETIME NULL", nativeMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, true, false ) ); assertEquals( "DATETIME NULL", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, false, false ) ); assertEquals( "CHAR(1)", nativeMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); odbcMeta.setSupportsBooleanDataType( true ); assertEquals( "BOOLEAN", odbcMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); odbcMeta.setSupportsBooleanDataType( false ); assertEquals( "INTEGER NOT NULL PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO" ), "FOO", "", false, false, false ) ); assertEquals( "INTEGER NOT NULL PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO" ), "", "FOO", false, false, false ) ); assertEquals( "DOUBLE PRECISION NULL", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO" ), "", "", false, false, false ) ); assertEquals( "DECIMAL(11, 3) NULL", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 11, 3 ), "", "", false, false, false ) ); assertEquals( "TINYINT NULL", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 2, 0 ), "", "", false, false, false ) ); assertEquals( "SMALLINT NULL", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 3, 0 ), "", "", false, false, false ) ); assertEquals( "SMALLINT NULL", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 4, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER NULL", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 5, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(15) NULL", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 15, 0 ), "", "", false, false, false ) ); assertEquals( "TEXT NULL", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 2050, 0 ), "", "", false, false, false ) ); assertEquals( " UNKNOWN", nativeMeta.getFieldDefinition( new ValueMetaInternetAddress( "FOO" ), "", "", false, false, false ) ); assertEquals( " UNKNOWN", nativeMeta.getFieldDefinition( new ValueMetaBinary( "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 += "DATETIME NULL"; 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 += "INTEGER IDENTITY NOT NULL"; } else { retval += "INTEGER NOT NULL PRIMARY KEY"; } } else { if ( precision != 0 || ( precision == 0 && length > 9 ) ) { if ( precision > 0 && length > 0 ) { retval += "DECIMAL(" + length + ", " + precision + ") NULL"; } else { retval += "DOUBLE PRECISION NULL"; } } else { if ( length < 3 ) { retval += "TINYINT NULL"; } else if ( length < 5 ) { retval += "SMALLINT NULL"; } else { retval += "INTEGER NULL"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= 2048 ) { retval += "TEXT NULL"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } retval += " NULL"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
SybaseIQDatabaseMeta 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 NULL"; 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 += "INTEGER IDENTITY NOT NULL"; } else { retval += "INTEGER NOT NULL PRIMARY KEY"; } } else { if ( precision != 0 || ( precision == 0 && length > 9 ) ) { if ( precision > 0 && length > 0 ) { retval += "DECIMAL(" + length + ", " + precision + ") NULL"; } else { retval += "DOUBLE PRECISION NULL"; } } else { if ( length < 3 ) { retval += "TINYINT NULL"; } else if ( length < 5 ) { retval += "SMALLINT NULL"; } else { retval += "INTEGER NULL"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= 2048 ) { retval += "TEXT NULL"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } retval += " NULL"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
SybaseIQDatabaseMeta 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 NULL"; 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 += "INTEGER IDENTITY NOT NULL"; } else { retval += "INTEGER NOT NULL PRIMARY KEY"; } } else { if ( precision != 0 || ( precision == 0 && length > 9 ) ) { if ( precision > 0 && length > 0 ) { retval += "DECIMAL(" + length + ", " + precision + ") NULL"; } else { retval += "DOUBLE PRECISION NULL"; } } else { if ( length < 3 ) { retval += "TINYINT NULL"; } else if ( length < 5 ) { retval += "SMALLINT NULL"; } else { retval += "INTEGER NULL"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= 2048 ) { retval += "TEXT NULL"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } retval += " NULL"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
SybaseIQDatabaseMeta 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 NULL"; 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 += "INTEGER IDENTITY NOT NULL"; } else { retval += "INTEGER NOT NULL PRIMARY KEY"; } } else { if ( precision != 0 || ( precision == 0 && length > 9 ) ) { if ( precision > 0 && length > 0 ) { retval += "DECIMAL(" + length + ", " + precision + ") NULL"; } else { retval += "DOUBLE PRECISION NULL"; } } else { if ( length < 3 ) { retval += "TINYINT NULL"; } else if ( length < 5 ) { retval += "SMALLINT NULL"; } else { retval += "INTEGER NULL"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= 2048 ) { retval += "TEXT NULL"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } retval += " NULL"; } 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 String getSchemaTableCombination( String schema_name, String table_part ); @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 getExtraOptionsHelpText(); @Override String[] getUsedLibraries(); @Override boolean useSchemaNameForTableList(); @Override String getSQLQueryFields( String tableName ); @Override boolean supportsPreparedStatementMetadataRetrieval(); }
SybaseIQDatabaseMeta 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 NULL"; 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 += "INTEGER IDENTITY NOT NULL"; } else { retval += "INTEGER NOT NULL PRIMARY KEY"; } } else { if ( precision != 0 || ( precision == 0 && length > 9 ) ) { if ( precision > 0 && length > 0 ) { retval += "DECIMAL(" + length + ", " + precision + ") NULL"; } else { retval += "DOUBLE PRECISION NULL"; } } else { if ( length < 3 ) { retval += "TINYINT NULL"; } else if ( length < 5 ) { retval += "SMALLINT NULL"; } else { retval += "INTEGER NULL"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= 2048 ) { retval += "TEXT NULL"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length + ")"; } retval += " NULL"; } 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 String getSchemaTableCombination( String schema_name, String table_part ); @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 getExtraOptionsHelpText(); @Override String[] getUsedLibraries(); @Override boolean useSchemaNameForTableList(); @Override String getSQLQueryFields( String tableName ); @Override boolean supportsPreparedStatementMetadataRetrieval();  }