@Test public void testGetFieldDefinition() throws Exception { ValueMetaInterface vm = new ValueMetaString(); String sql = hypersonicDatabaseMeta.getFieldDefinition( vm, null, null, false, false, false ); String expectedSql = "VARCHAR()"; assertEquals( "Check PDI-11461 without length", expectedSql, sql ); vm.setLength( DatabaseMeta.CLOB_LENGTH - 1 ); sql = hypersonicDatabaseMeta.getFieldDefinition( vm, null, null, false, false, false ); expectedSql = "VARCHAR(" + ( DatabaseMeta.CLOB_LENGTH - 1 ) + ")"; assertEquals( "Check PDI-11461 with length", expectedSql, sql ); vm.setLength( DatabaseMeta.CLOB_LENGTH ); sql = hypersonicDatabaseMeta.getFieldDefinition( vm, null, null, false, false, false ); expectedSql = "LONGVARCHAR"; assertEquals( "Check PDI-11461 with clob/text length", expectedSql, sql ); }
@Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval.append( "TIMESTAMP" ); break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval.append( "BOOLEAN" ); } else { retval.append( "CHAR(1)" ); } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval.append( "BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY" ); } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval.append( "NUMERIC(" ).append( length ).append( ", " ).append( precision ).append( ')' ); } else { if ( length > 9 ) { retval.append( "BIGINT" ); } else { if ( length < 5 ) { retval.append( "SMALLINT" ); } else { retval.append( "INTEGER" ); } } } } else { retval.append( "DOUBLE PRECISION" ); } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "LONGVARCHAR" ); } else { retval.append( "VARCHAR" ); if ( length > 0 ) { retval.append( '(' ).append( length ); } else { retval.append( '(' ); } retval.append( ')' ); } break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); }
HypersonicDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval.append( "TIMESTAMP" ); break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval.append( "BOOLEAN" ); } else { retval.append( "CHAR(1)" ); } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval.append( "BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY" ); } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval.append( "NUMERIC(" ).append( length ).append( ", " ).append( precision ).append( ')' ); } else { if ( length > 9 ) { retval.append( "BIGINT" ); } else { if ( length < 5 ) { retval.append( "SMALLINT" ); } else { retval.append( "INTEGER" ); } } } } else { retval.append( "DOUBLE PRECISION" ); } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "LONGVARCHAR" ); } else { retval.append( "VARCHAR" ); if ( length > 0 ) { retval.append( '(' ).append( length ); } else { retval.append( '(' ); } retval.append( ')' ); } break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); } }
HypersonicDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval.append( "TIMESTAMP" ); break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval.append( "BOOLEAN" ); } else { retval.append( "CHAR(1)" ); } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval.append( "BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY" ); } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval.append( "NUMERIC(" ).append( length ).append( ", " ).append( precision ).append( ')' ); } else { if ( length > 9 ) { retval.append( "BIGINT" ); } else { if ( length < 5 ) { retval.append( "SMALLINT" ); } else { retval.append( "INTEGER" ); } } } } else { retval.append( "DOUBLE PRECISION" ); } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "LONGVARCHAR" ); } else { retval.append( "VARCHAR" ); if ( length > 0 ) { retval.append( '(' ).append( length ); } else { retval.append( '(' ); } retval.append( ')' ); } break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); }  }
HypersonicDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval.append( "TIMESTAMP" ); break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval.append( "BOOLEAN" ); } else { retval.append( "CHAR(1)" ); } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval.append( "BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY" ); } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval.append( "NUMERIC(" ).append( length ).append( ", " ).append( precision ).append( ')' ); } else { if ( length > 9 ) { retval.append( "BIGINT" ); } else { if ( length < 5 ) { retval.append( "SMALLINT" ); } else { retval.append( "INTEGER" ); } } } } else { retval.append( "DOUBLE PRECISION" ); } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "LONGVARCHAR" ); } else { retval.append( "VARCHAR" ); if ( length > 0 ) { retval.append( '(' ).append( length ); } else { retval.append( '(' ); } retval.append( ')' ); } break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean supportsBitmapIndex(); @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[] getUsedLibraries(); @Override String getExtraOptionsHelpText(); @Override String[] getReservedWords(); @Override boolean supportsSequences(); @Override String getSQLSequenceExists( String sequenceName ); @Override String getSQLListOfSequences(); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLNextSequenceValue( String sequenceName ); }
HypersonicDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval.append( "TIMESTAMP" ); break; case ValueMetaInterface.TYPE_BOOLEAN: if ( supportsBooleanDataType() ) { retval.append( "BOOLEAN" ); } else { retval.append( "CHAR(1)" ); } break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval.append( "BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY" ); } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval.append( "NUMERIC(" ).append( length ).append( ", " ).append( precision ).append( ')' ); } else { if ( length > 9 ) { retval.append( "BIGINT" ); } else { if ( length < 5 ) { retval.append( "SMALLINT" ); } else { retval.append( "INTEGER" ); } } } } else { retval.append( "DOUBLE PRECISION" ); } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "LONGVARCHAR" ); } else { retval.append( "VARCHAR" ); if ( length > 0 ) { retval.append( '(' ).append( length ); } else { retval.append( '(' ); } retval.append( ')' ); } break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean supportsBitmapIndex(); @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[] getUsedLibraries(); @Override String getExtraOptionsHelpText(); @Override String[] getReservedWords(); @Override boolean supportsSequences(); @Override String getSQLSequenceExists( String sequenceName ); @Override String getSQLListOfSequences(); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLNextSequenceValue( String sequenceName );  }