Skip to content

Commit 5d3ae78

Browse files
committed
Update TableScheme.php
Added exception to the nonexistent primary key of the table
1 parent 8aca0c7 commit 5d3ae78

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Scheme/TableScheme.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Evas\Orm\Scheme;
66

77
use Evas\Orm\Base\Database;
8+
use Evas\Orm\OrmException;
89
use Evas\Orm\Scheme\ColumnScheme;
910
use Evas\Orm\Scheme\Exception\NotFoundColumnException;
1011

@@ -61,6 +62,9 @@ public function primaryKey(): string
6162
$row = $this->database->query("SHOW KEYS FROM `$this->table` WHERE Key_name = 'PRIMARY'")->assocArray();
6263
$this->primaryKey = $row['Column_name'];
6364
}
65+
if (empty($this->primaryKey)) {
66+
throw new OrmException("Primary key does not exist in table \"$this->table\"");
67+
}
6468
return $this->primaryKey;
6569
}
6670

0 commit comments

Comments
 (0)