public Type getType()

in src/main/user-impl/java/com/mysql/cj/xdevapi/ColumnImpl.java [67:137]


    public Type getType() {
        switch (this.field.getMysqlType()) {
            case BIT:
                return Type.BIT;
            case BIGINT:
                int len = (int) this.field.getLength();
                if (len < 5) {
                    return Type.TINYINT;
                } else if (len < 7) {
                    return Type.SMALLINT;
                } else if (len < 10) {
                    return Type.MEDIUMINT;
                } else if (len < 12) {
                    return Type.INT;
                } else if (len < 21) {
                    return Type.BIGINT;
                }
                throw new IllegalArgumentException("Unknown field length `" + this.field.getLength() + "` for signed int");
            case BIGINT_UNSIGNED:
                len = (int) this.field.getLength();
                if (len < 4) {
                    return Type.TINYINT;
                } else if (len < 6) {
                    return Type.SMALLINT;
                } else if (len < 9) {
                    return Type.MEDIUMINT;
                } else if (len < 11) {
                    return Type.INT;
                } else if (len < 21) {
                    return Type.BIGINT;
                }
                throw new IllegalArgumentException("Unknown field length `" + this.field.getLength() + "` for unsigned int");
            case FLOAT:
            case FLOAT_UNSIGNED:
                return Type.FLOAT;
            case DECIMAL:
            case DECIMAL_UNSIGNED:
                return Type.DECIMAL;
            case DOUBLE:
            case DOUBLE_UNSIGNED:
                return Type.DOUBLE;
            case CHAR:
            case VARCHAR:
                return Type.STRING;
            case JSON:
                return Type.JSON;
            case VARBINARY:
                return Type.BYTES;
            case TIME:
                return Type.TIME;
            case DATETIME:
                len = (int) this.field.getLength();
                if (len == 10) {
                    return Type.DATE;
                } else if (len > 18 && len < 27) {
                    return Type.DATETIME;
                }
                throw new IllegalArgumentException("Unknown field length `" + this.field.getLength() + "` for datetime");
            case TIMESTAMP:
                return Type.TIMESTAMP;
            case SET:
                return Type.SET;
            case ENUM:
                return Type.ENUM;
            case GEOMETRY:
                return Type.GEOMETRY;
            default:
                break;
        }
        throw new IllegalArgumentException("Unknown type in metadata: " + this.field.getMysqlType());
    }