Skip to content

Commit 6424e2a

Browse files
committed
Fix for Doctrine enum exception
1 parent d7fb186 commit 6424e2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Config/ModelConfig.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Voice\JsonQueryBuilder\Config;
44

5+
use Doctrine\DBAL\DBALException;
56
use Illuminate\Database\Eloquent\Model;
67
use Illuminate\Support\Facades\Cache;
78
use Illuminate\Support\Facades\Config;
@@ -119,8 +120,12 @@ public function getModelColumns(): array
119120
$columns = Schema::getColumnListing($table);
120121
$modelColumns = [];
121122

122-
foreach ($columns as $column) {
123-
$modelColumns[$column] = DB::getSchemaBuilder()->getColumnType($table, $column);
123+
try { // having 'enum' in table definition will throw Doctrine error because it is not defined in their types.
124+
foreach ($columns as $column) {
125+
$modelColumns[$column] = DB::getSchemaBuilder()->getColumnType($table, $column);
126+
}
127+
} catch (DBALException $e) {
128+
// leave model columns as an empty array and cache it.
124129
}
125130

126131
Cache::put(self::CACHE_PREFIX . $table, $modelColumns, self::CACHE_TTL);

0 commit comments

Comments
 (0)