@Test public void testGetFieldDefinition( ) throws Exception { assertEquals( "CHAR(1)", nativeMeta.getFieldDefinition( new ValueMetaBoolean( "BAR" ), "", "", false, false, false ) ); assertEquals( "BIGINT", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR", 10, 0 ), "", "", false, false, false ) ); assertEquals( "BIGINT", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "BAR", 10, 0 ), "", "", false, false, false ) ); assertEquals( "BIGINT", nativeMeta.getFieldDefinition( new ValueMetaInteger( "BAR", 10, 0 ), "", "", false, false, false ) ); assertEquals( "INT", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR", 0, 0 ), "", "", false, false, false ) ); assertEquals( "INT", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR", 5, 0 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(10,3)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR", 10, 3 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(10,3)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "BAR", 10, 3 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(21,4)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "BAR", 21, 4 ), "", "", false, false, false ) ); assertEquals( "TEXT", nativeMeta.getFieldDefinition( new ValueMetaString( "BAR", nativeMeta.getMaxVARCHARLength() + 2, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(15)", nativeMeta.getFieldDefinition( new ValueMetaString( "BAR", 15, 0 ), "", "", false, false, false ) ); assertEquals( "FLOAT(53)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR", 10, -7 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(22,7)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "BAR", 22, 7 ), "", "", false, false, false ) ); assertEquals( "FLOAT(53)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR", -10, 7 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(5,7)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR", 5, 7 ), "", "", false, false, false ) ); assertEquals( " UNKNOWN", nativeMeta.getFieldDefinition( new ValueMetaInternetAddress( "BAR" ), "", "", false, false, false ) ); assertEquals( "BIGINT PRIMARY KEY IDENTITY(0,1)", nativeMeta.getFieldDefinition( new ValueMetaInteger( "BAR" ), "BAR", "", true, false, false ) ); assertEquals( "BIGINT PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR" ), "BAR", "", false, false, false ) ); assertEquals( "BIGINT PRIMARY KEY IDENTITY(0,1)", nativeMeta.getFieldDefinition( new ValueMetaInteger( "BAR" ), "", "BAR", true, false, false ) ); assertEquals( "BIGINT PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaNumber( "BAR" ), "", "BAR", false, false, false ) ); assertEquals( "VARBINARY(MAX)", nativeMeta.getFieldDefinition( new ValueMetaBinary( ), "", "BAR", false, false, false ) ); assertEquals( "VARBINARY(MAX)", nativeMeta.getFieldDefinition( new ValueMetaBinary( "BAR" ), "", "BAR", false, false, false ) ); }
@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"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } 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 PRIMARY KEY IDENTITY(0,1)"; } 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 && length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } else { retval += "FLOAT(53)"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length < getMaxVARCHARLength() ) { if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "VARBINARY(MAX)"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
MSSQLServerDatabaseMeta 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"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } 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 PRIMARY KEY IDENTITY(0,1)"; } 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 && length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } else { retval += "FLOAT(53)"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length < getMaxVARCHARLength() ) { if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "VARBINARY(MAX)"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
MSSQLServerDatabaseMeta 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"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } 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 PRIMARY KEY IDENTITY(0,1)"; } 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 && length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } else { retval += "FLOAT(53)"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length < getMaxVARCHARLength() ) { if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "VARBINARY(MAX)"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
MSSQLServerDatabaseMeta 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"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } 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 PRIMARY KEY IDENTITY(0,1)"; } 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 && length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } else { retval += "FLOAT(53)"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length < getMaxVARCHARLength() ) { if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "VARBINARY(MAX)"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override boolean supportsCatalogs(); @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override String getSchemaTableCombination( String schema_name, String table_part ); @Override boolean supportsBitmapIndex(); @Override boolean supportsSynonyms(); @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 getSQLLockTables( String[] tableNames ); @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 ); String getSQLListOfProcedures( String schemaName ); @Override String[] getReservedWords(); @Override String[] getUsedLibraries(); @Override String getExtraOptionsHelpText(); @Override boolean checkIndexExists( Database database, String schemaName, String tableName, String[] idx_fields ); @Override String getSQLListOfSchemas(); @Override boolean supportsSchemas(); @Override String getSQLInsertAutoIncUnknownDimensionRow( String schemaTable, String keyField, String versionField ); @Override String getSQLNextSequenceValue( String sequenceName ); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLSequenceExists( String sequenceName ); @Override boolean supportsSequences(); @Override boolean supportsSequenceNoMaxValueOption(); @Override String getSQLListOfSequences(); @Override String quoteSQLString( String string ); @Override Long getNextBatchIdUsingLockTables( DatabaseMeta dbm, Database ldb, String schemaName, String tableName,
    String fieldName ); @Override boolean useSafePoints(); @Override boolean supportsErrorHandlingOnBatchUpdates(); @Override int getMaxVARCHARLength(); }
MSSQLServerDatabaseMeta 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"; break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval += "BIT"; } 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 PRIMARY KEY IDENTITY(0,1)"; } 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 && length > 0 ) { retval += "DECIMAL(" + length + "," + precision + ")"; } else { retval += "FLOAT(53)"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length < getMaxVARCHARLength() ) { if ( length > 0 ) { retval += "VARCHAR(" + length + ")"; } else { retval += "VARCHAR(100)"; } } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "VARBINARY(MAX)"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override boolean supportsCatalogs(); @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override String getSchemaTableCombination( String schema_name, String table_part ); @Override boolean supportsBitmapIndex(); @Override boolean supportsSynonyms(); @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 getSQLLockTables( String[] tableNames ); @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 ); String getSQLListOfProcedures( String schemaName ); @Override String[] getReservedWords(); @Override String[] getUsedLibraries(); @Override String getExtraOptionsHelpText(); @Override boolean checkIndexExists( Database database, String schemaName, String tableName, String[] idx_fields ); @Override String getSQLListOfSchemas(); @Override boolean supportsSchemas(); @Override String getSQLInsertAutoIncUnknownDimensionRow( String schemaTable, String keyField, String versionField ); @Override String getSQLNextSequenceValue( String sequenceName ); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLSequenceExists( String sequenceName ); @Override boolean supportsSequences(); @Override boolean supportsSequenceNoMaxValueOption(); @Override String getSQLListOfSequences(); @Override String quoteSQLString( String string ); @Override Long getNextBatchIdUsingLockTables( DatabaseMeta dbm, Database ldb, String schemaName, String tableName,
    String fieldName ); @Override boolean useSafePoints(); @Override boolean supportsErrorHandlingOnBatchUpdates(); @Override int getMaxVARCHARLength();  }