/** * Return the {@link Charset} instance with the MySQL-specific character set name used by the given column. * * @param column the column in which the character set is used; never null * @return the Java {@link Charset}, or null if there is no mapping */ protected Charset charsetFor(Column column) { String mySqlCharsetName = column.charsetName(); if (mySqlCharsetName == null) { logger.warn("Column is missing a character set: {}", column); return null; } String encoding = CharsetMapping.getJavaEncodingForMysqlCharset(mySqlCharsetName); if (encoding == null) { logger.warn("Column uses MySQL character set '{}', which has no mapping to a Java character set", mySqlCharsetName); } else { try { return Charset.forName(encoding); } catch (IllegalCharsetNameException e) { logger.error("Unable to load Java charset '{}' for column with MySQL character set '{}'", encoding, mySqlCharsetName); } } return null; }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof Column) { Column that = (Column) obj; return this.name().equalsIgnoreCase(that.name()) && this.typeExpression().equalsIgnoreCase(that.typeExpression()) && this.typeName().equalsIgnoreCase(that.typeName()) && this.jdbcType() == that.jdbcType() && Strings.equalsIgnoreCase(this.charsetName(),that.charsetName()) && this.position() == that.position() && this.length() == that.length() && this.scale().equals(that.scale()) && this.isOptional() == that.isOptional() && this.isAutoIncremented() == that.isAutoIncremented() && this.isGenerated() == that.isGenerated() && Objects.equals(this.defaultValue(), that.defaultValue()) && this.hasDefaultValue() == that.hasDefaultValue(); } return false; }
private Document toDocument(Column column) { Document document = Document.create(); document.setString("name", column.name()); document.setNumber("jdbcType", column.jdbcType()); if (column.nativeType() != Column.UNSET_INT_VALUE) { document.setNumber("nativeType", column.nativeType()); } document.setString("typeName", column.typeName()); document.setString("typeExpression", column.typeExpression()); document.setString("charsetName", column.charsetName()); if (column.length() != Column.UNSET_INT_VALUE) { document.setNumber("length", column.length()); } column.scale().ifPresent(s -> document.setNumber("scale", s)); document.setNumber("position", column.position()); document.setBoolean("optional", column.isOptional()); document.setBoolean("autoIncremented", column.isAutoIncremented()); document.setBoolean("generated", column.isGenerated()); return document; }
protected void assertColumn(Table table, String name, String typeName, int jdbcType, int length, String charsetName, boolean optional) { Column column = table.columnWithName(name); assertThat(column.name()).isEqualTo(name); assertThat(column.typeName()).isEqualTo(typeName); assertThat(column.jdbcType()).isEqualTo(jdbcType); assertThat(column.length()).isEqualTo(length); assertThat(column.charsetName()).isEqualTo(charsetName); assertFalse(column.scale().isPresent()); assertThat(column.isOptional()).isEqualTo(optional); assertThat(column.isGenerated()).isFalse(); assertThat(column.isAutoIncremented()).isFalse(); }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof Column) { Column that = (Column) obj; return this.name().equalsIgnoreCase(that.name()) && this.typeExpression().equalsIgnoreCase(that.typeExpression()) && this.typeName().equalsIgnoreCase(that.typeName()) && this.jdbcType() == that.jdbcType() && Strings.equalsIgnoreCase(this.charsetName(),that.charsetName()) && this.position() == that.position() && this.length() == that.length() && this.scale().equals(that.scale()) && this.isOptional() == that.isOptional() && this.isAutoIncremented() == that.isAutoIncremented() && this.isGenerated() == that.isGenerated() && Objects.equals(this.defaultValue(), that.defaultValue()) && this.hasDefaultValue() == that.hasDefaultValue(); } return false; }
private Document toDocument(Column column) { Document document = Document.create(); document.setString("name", column.name()); document.setNumber("jdbcType", column.jdbcType()); if (column.nativeType() != Column.UNSET_INT_VALUE) { document.setNumber("nativeType", column.nativeType()); } document.setString("typeName", column.typeName()); document.setString("typeExpression", column.typeExpression()); document.setString("charsetName", column.charsetName()); if (column.length() != Column.UNSET_INT_VALUE) { document.setNumber("length", column.length()); } column.scale().ifPresent(s -> document.setNumber("scale", s)); document.setNumber("position", column.position()); document.setBoolean("optional", column.isOptional()); document.setBoolean("autoIncremented", column.isAutoIncremented()); document.setBoolean("generated", column.isGenerated()); return document; }
protected void assertColumn(Table table, String name, String typeName, int jdbcType, int length, String charsetName, boolean optional) { Column column = table.columnWithName(name); assertThat(column.name()).isEqualTo(name); assertThat(column.typeName()).isEqualTo(typeName); assertThat(column.jdbcType()).isEqualTo(jdbcType); assertThat(column.length()).isEqualTo(length); assertThat(column.charsetName()).isEqualTo(charsetName); assertFalse(column.scale().isPresent()); assertThat(column.isOptional()).isEqualTo(optional); assertThat(column.isGenerated()).isFalse(); assertThat(column.isAutoIncremented()).isFalse(); }