File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515use Doctrine \DBAL \Schema \SchemaException as DBALSchemaException ;
1616use Doctrine \DBAL \Schema \Table as DBALTable ;
1717use Doctrine \DBAL \Types \Type as DBALType ;
18+ use OC \DB \Connection ;
1819use OCP \DB \Schema \ColumnType ;
1920use OCP \DB \Schema \IColumn ;
2021use OCP \DB \Schema \IForeignKeyConstraint ;
2728 */
2829class Table implements ITable {
2930 public function __construct (
30- private DBALTable $ table ,
31+ private readonly DBALTable $ table ,
32+ private readonly Connection $ connection ,
3133 ) {
3234 }
3335
@@ -117,7 +119,7 @@ public function getPrimaryKey(): ?IIndex {
117119
118120 #[\Override]
119121 public function hasPrimaryKey (): bool {
120- return $ this ->table ->hasPrimaryKey () ;
122+ return $ this ->table ->getPrimaryKey () !== null ;
121123 }
122124
123125 #[\Override]
@@ -206,7 +208,7 @@ public function addForeignKeyConstraint(
206208 ): self {
207209 try {
208210 $ this ->table ->addForeignKeyConstraint (
209- $ foreignTable instanceof self ? $ foreignTable ->getWrappedTable () : $ foreignTable ,
211+ $ foreignTable instanceof self ? $ foreignTable ->getWrappedTable () : $ this -> connection -> getPrefix () . $ foreignTable ,
210212 $ localColumnNames ,
211213 $ foreignColumnNames ,
212214 $ options ,
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ public function getTableNames(): array {
7575 #[\Override]
7676 public function getTable (string $ tableName ): ITable {
7777 try {
78- return new Table ($ this ->schema ->getTable ($ this ->connection ->getPrefix () . $ tableName ));
78+ return new Table ($ this ->schema ->getTable ($ this ->connection ->getPrefix () . $ tableName ), $ this -> connection );
7979 } catch (DBALSchemaException $ e ) {
8080 throw new SchemaException ($ e ->getMessage (), $ e ->getCode (), $ e );
8181 }
You can’t perform that action at this time.
0 commit comments