@Test public void testGetFieldDefinition() { assertEquals( "FOO TIMESTAMP", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "TIMESTAMP", nativeMeta.getFieldDefinition( new ValueMetaDate( "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 ) ); jndiMeta.setSupportsBooleanDataType( !( jndiMeta.supportsBooleanDataType() ) ); assertEquals( typeCk[ i + 1 ], jndiMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); jndiMeta.setSupportsBooleanDataType( !( jndiMeta.supportsBooleanDataType() ) ); assertEquals( "BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", true, false, false ) ); assertEquals( "BIGINT PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) ); assertEquals( "BIGINT PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", false, false, false ) ); assertEquals( "INT", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 8, 0 ), "", "", false, false, false ) ); assertEquals( "BIGINT", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 9, 0 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(19,0)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 19, 0 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(10,5)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 10, 5 ), "", "", false, false, false ) ); assertEquals( "DOUBLE", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -10, -5 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(15)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 15, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(100)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO" ), "", "", 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 ) ) { if ( use_autoinc ) { retval += "BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY"; } else { retval += "BIGINT PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 18 ) { retval += "DECIMAL(" + length + ",0)"; } else { if ( length >= 9 ) { retval += "BIGINT"; } else { retval += "INT"; } } } else { if ( precision > 0 ) { if ( length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } } else { retval += "DOUBLE"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
LucidDBDatabaseMeta 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 ) ) { if ( use_autoinc ) { retval += "BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY"; } else { retval += "BIGINT PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 18 ) { retval += "DECIMAL(" + length + ",0)"; } else { if ( length >= 9 ) { retval += "BIGINT"; } else { retval += "INT"; } } } else { if ( precision > 0 ) { if ( length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } } else { retval += "DOUBLE"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
LucidDBDatabaseMeta 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 ) ) { if ( use_autoinc ) { retval += "BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY"; } else { retval += "BIGINT PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 18 ) { retval += "DECIMAL(" + length + ",0)"; } else { if ( length >= 9 ) { retval += "BIGINT"; } else { retval += "INT"; } } } else { if ( precision > 0 ) { if ( length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } } else { retval += "DOUBLE"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
LucidDBDatabaseMeta 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 ) ) { if ( use_autoinc ) { retval += "BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY"; } else { retval += "BIGINT PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 18 ) { retval += "DECIMAL(" + length + ",0)"; } else { if ( length >= 9 ) { retval += "BIGINT"; } else { retval += "INT"; } } } else { if ( precision > 0 ) { if ( length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } } else { retval += "DOUBLE"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } 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 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 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[] getReservedWords(); @Override String[] getUsedLibraries(); @Override String getExtraOptionsHelpText(); @Override boolean useSchemaNameForTableList(); @Override boolean requiresCastToVariousForIsNull(); }
LucidDBDatabaseMeta 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 ) ) { if ( use_autoinc ) { retval += "BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY"; } else { retval += "BIGINT PRIMARY KEY"; } } else { if ( precision == 0 ) { if ( length > 18 ) { retval += "DECIMAL(" + length + ",0)"; } else { if ( length >= 9 ) { retval += "BIGINT"; } else { retval += "INT"; } } } else { if ( precision > 0 ) { if ( length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } } else { retval += "DOUBLE"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } 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 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 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[] getReservedWords(); @Override String[] getUsedLibraries(); @Override String getExtraOptionsHelpText(); @Override boolean useSchemaNameForTableList(); @Override boolean requiresCastToVariousForIsNull();  }