diff --git a/src/Drivers/PdbMysql.php b/src/Drivers/PdbMysql.php index e8a012a..9ff09cf 100644 --- a/src/Drivers/PdbMysql.php +++ b/src/Drivers/PdbMysql.php @@ -178,6 +178,8 @@ public function fieldList(string $table): array ]; $res = $this->query($q, $params, 'pdo'); + + /** @var array $rows */ $rows = []; while ($row = $res->fetch(PDO::FETCH_ASSOC)) { @@ -222,6 +224,23 @@ public function fieldList(string $table): array } $res->closeCursor(); + + $q = "SELECT CONSTRAINT_NAME, CHECK_CLAUSE + FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS + WHERE CONSTRAINT_SCHEMA = ? + AND TABLE_NAME = ?"; + $res = $this->query($q, $params, 'pdo'); + + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $col = $row['CONSTRAINT_NAME']; + if (!isset($rows[$col]) || !preg_match('/^json_valid\(/i', $row['CHECK_CLAUSE'])) { + continue; + } + $rows[$col]->type = 'json'; + } + + $res->closeCursor(); + return $rows; }