@Override
  public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean useAutoinc,
                                    boolean addFieldName, boolean addCr ) {
    String retval = "";

    String fieldname = v.getName();
    int length = v.getLength();
    int precision = v.getPrecision();

    if ( addFieldName ) {
      retval += fieldname + " ";
    }

    int type = v.getType();
    switch ( type ) {
      case ValueMetaInterface.TYPE_TIMESTAMP:
      case ValueMetaInterface.TYPE_DATE:
        retval += "DATETIME";
        break;
      // Move back to Y/N for bug - [# 1538] Repository on MS ACCESS: error creating repository
      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 ) || // Technical key
          fieldname.equalsIgnoreCase( pk ) // Primary key
        ) {
          if ( useAutoinc ) {
            retval += "COUNTER PRIMARY KEY";
          } else {
            retval += "LONG PRIMARY KEY";
          }
        } else {
          if ( precision == 0 ) {
            if ( length > 9 ) {
              retval += "DOUBLE";
            } else {
              if ( length > 5 ) {
                retval += "LONG";
              } else {
                retval += "INTEGER";
              }
            }
          } else {
            retval += "DOUBLE";
          }
        }
        break;
      case ValueMetaInterface.TYPE_STRING:
        if ( length > 0 ) {
          if ( length < 256 ) {
            retval += "TEXT(" + length + ")";
          } else {
            retval += "MEMO";
          }
        } else {
          retval += "TEXT";
        }
        break;
      case ValueMetaInterface.TYPE_BINARY:
        retval += " LONGBINARY";
        break;
      default:
        retval += " UNKNOWN";
        break;
    }

    if ( addCr ) {
      retval += Const.CR;
    }

    return retval;
  }
@Test
  public void testGetFieldDefinition() {
    assertEquals( "FOO DATETIME",
        odbcMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) );
    assertEquals( "DATETIME",
        odbcMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, false, false ) );

    assertFalse( odbcMeta.supportsBooleanDataType() );
    assertEquals( "CHAR(1)",
        odbcMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) );
    odbcMeta.setSupportsBooleanDataType( true );
    assertEquals( "BIT",
        odbcMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) );
    odbcMeta.setSupportsBooleanDataType( false );

    // Key field Stuff
    assertEquals( "COUNTER PRIMARY KEY",
        odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", true, false, false ) );
    assertEquals( "LONG PRIMARY KEY",
        odbcMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) );
    assertEquals( "LONG PRIMARY KEY",
        odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", false, false, false ) );

    // Integer types
    assertEquals( "INTEGER",
        odbcMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 4, 0 ), "", "", false, false, false ) );
    assertEquals( "LONG",
        odbcMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 6, 0 ), "", "", false, false, false ) );
    assertEquals( "LONG",
        odbcMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 9, 0 ), "", "", false, false, false ) );
    assertEquals( "DOUBLE",
        odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 10, 0 ), "", "", false, false, false ) );

    // Number Types ( as written, precision != 0 )

    assertEquals( "DOUBLE",
        odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 10, 1 ), "", "", false, false, false ) );
    assertEquals( "DOUBLE",
        odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 3, 1 ), "", "", false, false, false ) );
    assertEquals( "DOUBLE",
        odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 3, -5 ), "", "", false, false, false ) );
    assertEquals( "DOUBLE",
        odbcMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -3, -5 ), "", "", false, false, false ) );

    // String Types
    assertEquals( "TEXT(255)",
        odbcMeta.getFieldDefinition( new ValueMetaString( "FOO", 255, 0 ), "", "", false, false, false ) ); // Likely a bug - the maxTextFieldLength is set to 65536 - so this limitation is likely wrong
    assertEquals( "TEXT(1)",
        odbcMeta.getFieldDefinition( new ValueMetaString( "FOO", 1, 0 ), "", "", false, false, false ) );
    assertEquals( "MEMO",
        odbcMeta.getFieldDefinition( new ValueMetaString( "FOO", 256, 0 ), "", "", false, false, false ) );
    assertEquals( "TEXT",
        odbcMeta.getFieldDefinition( new ValueMetaString( "FOO", 0, 0 ), "", "", false, false, false ) );
    assertEquals( "TEXT",
        odbcMeta.getFieldDefinition( new ValueMetaString( "FOO" ), "", "", false, false, false ) );

    // Other Types
    assertEquals( " LONGBINARY",
        odbcMeta.getFieldDefinition( new ValueMetaBinary( "FOO", 200, 1 ), "", "", false, false, false ) );

    // Unknowns
    assertEquals( " UNKNOWN",
        odbcMeta.getFieldDefinition( new ValueMetaInternetAddress( "FOO" ), "", "", false, false, false ) );
    assertEquals( " UNKNOWN" + System.getProperty( "line.separator" ),
        odbcMeta.getFieldDefinition( new ValueMetaInternetAddress( "FOO" ), "", "", false, false, true ) );

  }