Skip to content

Commit

Permalink
Adapt to recent Protobuf message changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Mar 19, 2024
1 parent ff10fa3 commit 541f49d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public static ResultSet buildFromPrimaryKeys( List<PrimaryKey> primaryKeys ) thr
private static List<GenericMetaContainer> expandPrimaryKey( PrimaryKey primaryKey ) {
AtomicInteger sequenceIndex = new AtomicInteger();
return primaryKey.getColumnsList().stream().map( c -> new GenericMetaContainer(
c.getDatabaseName(),
c.getNamespaceName(),
c.getTableName(),
c.getColumnName(),
Expand Down Expand Up @@ -187,11 +186,8 @@ private static List<GenericMetaContainer> expandForeignKey( ForeignKey foreignKe
AtomicInteger sequenceIndex = new AtomicInteger();
List<Column> referencedKeyColumns = foreignKey.getReferencedColumnsList();
return foreignKey.getForeignColumnsList().stream().map( c -> new GenericMetaContainer(
foreignKey.getReferencedDatabaseName(),
foreignKey.getReferencedNamespaceName(),
foreignKey.getReferencedTableName(),
referencedKeyColumns.get( sequenceIndex.get() ).getDatabaseName(),
c.getDatabaseName(),
c.getNamespaceName(),
c.getTableName(),
c.getColumnName(),
Expand Down Expand Up @@ -232,7 +228,6 @@ public static ResultSet buildFromIndexes( List<Index> indexes ) throws SQLExcept
private static List<GenericMetaContainer> expandIndex( Index index ) {
AtomicInteger ordinalPosition = new AtomicInteger( 1 );
return index.getColumnsList().stream().map( c -> new GenericMetaContainer(
index.getDatabaseName(),
index.getNamespaceName(),
index.getTableName(),
!index.getUnique(), // jdbc lists non uniqueness
Expand Down Expand Up @@ -281,7 +276,6 @@ private static List<GenericMetaContainer> createDummyColumnPrivileges( Column co
// This method is used to create a dummy full rights result set for a column because the requested information does not exist on the server side.
List<String> accessRights = Arrays.asList( "INSERT", "REFERENCE", "SELECT", "UPDATE" );
return accessRights.stream().map( a -> new GenericMetaContainer(
colum.getDatabaseName(),
colum.getNamespaceName(),
colum.getTableName(),
colum.getColumnName(),
Expand Down Expand Up @@ -312,7 +306,6 @@ private static List<GenericMetaContainer> createDummyTablePrivileges( Table tabl
// This method is used to create a dummy full rights result set for a table because the requested information does not exist on the server side.
List<String> accessRights = Arrays.asList( "SELECT", "INSERT", "UPDATE", "DELETE", "REFERENCE" );
return accessRights.stream().map( a -> new GenericMetaContainer(
table.getSourceDatabaseName(),
table.getNamespaceName(),
table.getTableName(),
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ public class MetaResultSetComparators {
public static final Comparator<Type> TYPE_INFO_COMPARATOR = Comparator
.comparing( t -> TypedValueUtils.getJdbcTypeFromPolyTypeName( t.getTypeName() ) );
public static final Comparator<Namespace> NAMESPACE_COMPARATOR = Comparator
.comparing( Namespace::getDatabaseName )
.thenComparing( Namespace::getNamespaceName );
.comparing( Namespace::getNamespaceName );
public static final Comparator<GenericMetaContainer> PRIMARY_KEY_COMPARATOR = Comparator
.comparing( g -> (String) (g.getValue( 3 )) );
public static final Comparator<GenericMetaContainer> INDEX_COMPARATOR = Comparator
Expand All @@ -33,18 +32,15 @@ public class MetaResultSetComparators {
public static final Comparator<Function> FUNCTION_COMPARATOR = Comparator
.comparing( Function::getName );
public static final Comparator<Column> COLUMN_COMPARATOR = Comparator
.comparing( Column::getDatabaseName )
.thenComparing( Column::getNamespaceName )
.comparing( Column::getNamespaceName )
.thenComparing( Column::getTableName )
.thenComparing( Column::getColumnIndex );
public static final Comparator<Table> TABLE_COMPARATOR = Comparator
.comparing( Table::getTableType )
.thenComparing( Table::getSourceDatabaseName )
.thenComparing( Table::getNamespaceName )
.thenComparing( Table::getTableName );
public static final Comparator<Column> PSEUDO_COLUMN_COMPARATOR = Comparator
.comparing( Column::getDatabaseName )
.thenComparing( Column::getNamespaceName )
.comparing( Column::getNamespaceName )
.thenComparing( Column::getTableName )
.thenComparing( Column::getColumnName );
public static final Comparator<ClientInfoPropertyMeta> CLIENT_INFO_PROPERTY_COMPARATOR = Comparator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MetaResultSetSignatures {


public static final List<MetaResultSetParameter<Table>> TABLE_SIGNATURE = Arrays.asList(
new MetaResultSetParameter<>( "TABLE_CAT", Types.VARCHAR, Table::getSourceDatabaseName ),
//new MetaResultSetParameter<>( "TABLE_CAT", Types.VARCHAR, Table::getSourceDatabaseName ),
new MetaResultSetParameter<>( "TABLE_SCHEM", Types.VARCHAR, Table::getNamespaceName ),
new MetaResultSetParameter<>( "TABLE_NAME", Types.VARCHAR, Table::getTableName ),
new MetaResultSetParameter<>( "TABLE_TYPE", Types.VARCHAR, Table::getTableType ),
Expand All @@ -34,8 +34,8 @@ public class MetaResultSetSignatures {
new MetaResultSetParameter<>( "TYPE_SCHEM", Types.VARCHAR, p -> null ),
new MetaResultSetParameter<>( "TYPE_NAME", Types.VARCHAR, p -> null ),
new MetaResultSetParameter<>( "SELF_REFERENCING_COL_NAME", Types.VARCHAR, p -> null ),
new MetaResultSetParameter<>( "REF_GENERATION", Types.VARCHAR, p -> null ),
new MetaResultSetParameter<>( "OWNER", Types.VARCHAR, Table::getOwnerName )
new MetaResultSetParameter<>( "REF_GENERATION", Types.VARCHAR, p -> null )
//new MetaResultSetParameter<>( "OWNER", Types.VARCHAR, Table::getOwnerName )
);

public static final List<MetaResultSetParameter<TableType>> TABLE_TYPE_SIGNATURE = Collections.singletonList(
Expand All @@ -44,13 +44,13 @@ public class MetaResultSetSignatures {

public static final List<MetaResultSetParameter<Namespace>> NAMESPACE_SIGNATURE = Arrays.asList(
new MetaResultSetParameter<>( "TABLE_SCHEM", Types.VARCHAR, Namespace::getNamespaceName ),
new MetaResultSetParameter<>( "TABLE_CATALOG", Types.VARCHAR, Namespace::getDatabaseName ),
new MetaResultSetParameter<>( "OWNER", Types.VARCHAR, Namespace::getOwnerName ),
//new MetaResultSetParameter<>( "TABLE_CATALOG", Types.VARCHAR, Namespace::getDatabaseName ),
//new MetaResultSetParameter<>( "OWNER", Types.VARCHAR, Namespace::getOwnerName ),
new MetaResultSetParameter<>( "SCHEMA_TYPE", Types.VARCHAR, nullIfFalse( Namespace::getNamespaceName, Namespace::hasNamespaceType ) )
);

public static final List<MetaResultSetParameter<Column>> COLUMN_SIGNATURE = Arrays.asList(
new MetaResultSetParameter<>( "TABLE_CAT", Types.VARCHAR, Column::getDatabaseName ),
//new MetaResultSetParameter<>( "TABLE_CAT", Types.VARCHAR, Column::getDatabaseName ),
new MetaResultSetParameter<>( "TABLE_SCHEM", Types.VARCHAR, Column::getNamespaceName ),
new MetaResultSetParameter<>( "TABLE_NAME", Types.VARCHAR, Column::getTableName ),
new MetaResultSetParameter<>( "COLUMN_NAME", Types.VARCHAR, Column::getColumnName ),
Expand Down Expand Up @@ -269,7 +269,7 @@ public class MetaResultSetSignatures {
);

public static final List<MetaResultSetParameter<Column>> PSEUDO_COLUMN_SIGNATURE = Arrays.asList(
new MetaResultSetParameter<>( "TABLE_CAT", Types.VARCHAR, Column::getDatabaseName ),
//new MetaResultSetParameter<>( "TABLE_CAT", Types.VARCHAR, Column::getDatabaseName ),
new MetaResultSetParameter<>( "TABLE_SCHEM", Types.VARCHAR, Column::getNamespaceName ),
new MetaResultSetParameter<>( "TABLE_NAME", Types.VARCHAR, Column::getTableName ),
new MetaResultSetParameter<>( "COLUMN_NAME", Types.VARCHAR, Column::getColumnName ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,9 +1045,6 @@ private boolean referencesTable( ForeignKey foreignKey, Table table ) {
if ( !foreignKey.getReferencedNamespaceName().equals( table.getNamespaceName() ) ) {
return false;
}
if ( !foreignKey.getReferencedDatabaseName().equals( table.getSourceDatabaseName() ) ) {
return false;
}
return true;
}

Expand Down

0 comments on commit 541f49d

Please sign in to comment.