@Test public void testGetFieldDefinition() { assertEquals( "FOO DATE", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "TIMESTAMP", nativeMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, false, false ) ); assertEquals( "CHAR(1)", nativeMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); assertEquals( "BIGINT PRIMARY KEY IDENTITY(0,1)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", true, false, false ) ); assertEquals( "BIGINT PRIMARY KEY IDENTITY(0,1)", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 10, 0 ), "", "FOO", true, false, false ) ); assertEquals( "BIGINT PRIMARY KEY NOT NULL", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "FOO", "", false, false, false ) ); assertEquals( "BIGINT PRIMARY KEY NOT NULL", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", false, false, false ) ); assertEquals( "BIGINT", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 10, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 6, 0 ), "", "", false, false, false ) ); assertEquals( "SMALLINT", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 3, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER1", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 2, 0 ), "", "", false, false, false ) ); assertEquals( "FLOAT", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 6, 3 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(15)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 15, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(2000)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO" ), "", "", true, false, false ) ); assertEquals( "VARCHAR(2000)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 0, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(2000)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", -34, 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 += "TIMESTAMP"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATE"; break; case ValueMetaInterface.TYPE_BOOLEAN: 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 += "BIGINT PRIMARY KEY IDENTITY(0,1)"; } else { retval += "BIGINT PRIMARY KEY NOT NULL"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length > 4 ) { retval += "INTEGER"; } else { if ( length > 2 ) { retval += "SMALLINT"; } else { retval += "INTEGER1"; } } } } else { retval += "FLOAT"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(2000)"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
IngresDatabaseMeta 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 += "TIMESTAMP"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATE"; break; case ValueMetaInterface.TYPE_BOOLEAN: 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 += "BIGINT PRIMARY KEY IDENTITY(0,1)"; } else { retval += "BIGINT PRIMARY KEY NOT NULL"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length > 4 ) { retval += "INTEGER"; } else { if ( length > 2 ) { retval += "SMALLINT"; } else { retval += "INTEGER1"; } } } } else { retval += "FLOAT"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(2000)"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
IngresDatabaseMeta 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 += "TIMESTAMP"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATE"; break; case ValueMetaInterface.TYPE_BOOLEAN: 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 += "BIGINT PRIMARY KEY IDENTITY(0,1)"; } else { retval += "BIGINT PRIMARY KEY NOT NULL"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length > 4 ) { retval += "INTEGER"; } else { if ( length > 2 ) { retval += "SMALLINT"; } else { retval += "INTEGER1"; } } } } else { retval += "FLOAT"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(2000)"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
IngresDatabaseMeta 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 += "TIMESTAMP"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATE"; break; case ValueMetaInterface.TYPE_BOOLEAN: 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 += "BIGINT PRIMARY KEY IDENTITY(0,1)"; } else { retval += "BIGINT PRIMARY KEY NOT NULL"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length > 4 ) { retval += "INTEGER"; } else { if ( length > 2 ) { retval += "SMALLINT"; } else { retval += "INTEGER1"; } } } } else { retval += "FLOAT"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(2000)"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean supportsBitmapIndex(); @Override boolean supportsSynonyms(); @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 getDropColumnStatement( 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 getTruncateTableStatement( String tableName ); @Override String[] getUsedLibraries(); @Override boolean supportsGetBlob(); }
IngresDatabaseMeta 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 += "TIMESTAMP"; break; case ValueMetaInterface.TYPE_DATE: retval += "DATE"; break; case ValueMetaInterface.TYPE_BOOLEAN: 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 += "BIGINT PRIMARY KEY IDENTITY(0,1)"; } else { retval += "BIGINT PRIMARY KEY NOT NULL"; } } else { if ( precision == 0 ) { if ( length > 9 ) { retval += "BIGINT"; } else { if ( length > 4 ) { retval += "INTEGER"; } else { if ( length > 2 ) { retval += "SMALLINT"; } else { retval += "INTEGER1"; } } } } else { retval += "FLOAT"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(2000)"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean supportsBitmapIndex(); @Override boolean supportsSynonyms(); @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 getDropColumnStatement( 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 getTruncateTableStatement( String tableName ); @Override String[] getUsedLibraries(); @Override boolean supportsGetBlob();  }