schemacrawler / SchemaCrawler

Free database schema discovery and comprehension tool
http://www.schemacrawler.com/
Other
1.62k stars 200 forks source link

Linting on 15.01.01 > Interfaces have changed for plugins since 14.17.03 #197

Closed adriens closed 6 years ago

adriens commented 6 years ago

Context

We plan to upgrade the latest debian package, including additional lints? Still the 15.x has seen a lot of code refactoring causing compile failure. Any guidelines would be greatly apprciated.

Environment

Specify the

  • version of SchemaCrawler that you are using 15.01.01
  • version of Java that you are using 1.8
  • operating system and version that you are using Not depending on it
  • relational datavase and version that you are using Not depending on it
  • JDBC driver and version that you are using Not depending on it

Issue

We are trying to upgrade additional-lints (see https://github.com/mbarre/schemacrawler-additional-lints/issues/131) but some interfaces and methods have changed a lot, causing compilation to fail.

getJavSqlType()

First, schemacrawler.​schema.​JavaSqlType has lost its getJavaSqlType() method. Can you tell us what we should put instead ? We were using it to test its kind of type (text vs. numeric vs. binary, see sample below :

public static final boolean isSqlTypeLargeTextBased(ColumnDataType dataType) {
        return dataType.getJavaSqlType().getJavaSqlType() == Types.CLOB
                        || dataType.getJavaSqlType().getJavaSqlType() == Types.LONGVARCHAR
                        || "text".equalsIgnoreCase(dataType.getDatabaseSpecificTypeName());
    }

SchemaCrawlerOptions refactoring

SchemaCrawlerOptions also had a big refactoring, the following code cannot run anymore, could you please provide us some guidelines ?

final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
            // Set what details are required in the schema - this affects the
            // time taken to crawl the schema
            options.setSchemaInfoLevel(SchemaInfoLevelBuilder.standard());
            options.setTableNamePattern("test_json");
sualeh commented 6 years ago

For SchemaCrawlerOptions see ApiExample.java

sualeh commented 6 years ago

For schemacrawler.​schema.​JavaSqlType, use something like:

  public static final boolean isSqlTypeLargeTextBased(ColumnDataType dataType)
  {
    return EnumSet.of(JavaSqlTypeGroup.binary, JavaSqlTypeGroup.large_object)
      .contains(dataType.getJavaSqlType().getJavaSqlTypeGroup())
           || "text".equalsIgnoreCase(dataType.getDatabaseSpecificTypeName());
  }
sualeh commented 6 years ago

The reason that schemacrawler.​schema.​JavaSqlType has lost its getJavaSqlType() method is that Java 8 has made the java.sql.Types type number vendor specific. Java 8 adds java.sql.SQLType with a getVendorTypeNumber(), and the JDBC implementation is just one of the possible implementations. The default implementation is java.sql.JDBCType, which wraps the java.sql.Types type number in getVendorTypeNumber(). However, each database driver is free to provide it's own implementation.

SchemaCrawler's schemacrawler.schema.JavaSqlType is now an enhanced version of Java's java.sql.JDBCType.

adriens commented 6 years ago

WOW, I did not pay attention to this...this is not a little change for this part of the code. It means we depend on jdbc drivers implementation/database vendor...in a way, ...it sucks :smile:

adriens commented 6 years ago

We have to :thinking: about it on our side...