Skip to content

Commit

Permalink
Do not allow nullable to be set for primary keys
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Jan 17, 2025
1 parent 8d0a973 commit 2b41e1d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,11 @@ public void setColumnNullable( LogicalTable table, String columnName, boolean nu
// Check if model permits operation
checkModelLogic( table, columnName );

// Check that column is not part of a primary key
if ( catalog.getLogicalRel( table.namespaceId ).getKeys().values().stream().filter( v -> v instanceof LogicalPrimaryKey ).flatMap( v -> v.fieldIds.stream() ).anyMatch( l -> l == logicalColumn.id ) ) {
throw new GenericRuntimeException( "Primary key cannot be nullable" );
}

catalog.getLogicalRel( table.namespaceId ).setNullable( logicalColumn.id, nullable );

// Reset plan cache implementation cache & routing cache
Expand Down

0 comments on commit 2b41e1d

Please sign in to comment.