From bcce9d342d9b3c923e0d319cf4fd2bf057462419 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Mon, 1 Sep 2025 10:57:13 +0300 Subject: [PATCH] Fix database command warnings --- app/src/Lib/Util/SchemaManager.php | 74 ++++++++++++++++-------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/app/src/Lib/Util/SchemaManager.php b/app/src/Lib/Util/SchemaManager.php index e9ae0dd83..6c091b442 100644 --- a/app/src/Lib/Util/SchemaManager.php +++ b/app/src/Lib/Util/SchemaManager.php @@ -46,40 +46,6 @@ class SchemaManager { use \App\Lib\Traits\LabeledLogTrait; - /** - * Resolve a PostgreSQL constraint's owning table (schema-qualified) by constraint name. - * Returns null if the given name is not found as a constraint. - */ - protected function resolvePgConstraintTable(string $constraintName): ?string { - if($this->conn->driver !== 'Cake\\Database\\Driver\\Postgres') { - return null; - } - - // Query pg catalogs to find the table for this constraint name - // We return schema-qualified name: schema.table - $sql = <<conn->executeQuery($sql, ['name' => $constraintName]); - $row = $stmt->fetchAssociative(); - if(!$row || empty($row['schema']) || empty($row['table'])) { - return null; - } - // Quote/qualify as schema.table (matching how other statements look) - return $row['schema'] . '.' . $row['table']; - } catch(\Throwable $e) { - // On any error, fail open by returning null so caller uses original SQL - return null; - } - } - // Console for output protected $io = null; @@ -449,4 +415,42 @@ protected function processSchema( // but so far we don't have an example indicating it's needed. } -} \ No newline at end of file + /** + * Resolve a PostgreSQL constraint's owning table (schema-qualified) by constraint name. + * Returns null if the given name is not found as a constraint. + * + * @param string $constraintName + * @return ?string Schema-qualified table name or null if constraint not found + * @since COmanage Registry v5.2.0 + */ + + protected function resolvePgConstraintTable(string $constraintName): ?string { + if($this->conn->driver !== 'Cake\\Database\\Driver\\Postgres') { + return null; + } + + // Query pg catalogs to find the table for this constraint name + // We return schema-qualified name: schema.table + $sql = <<conn->executeQuery($sql, ['name' => $constraintName]); + $row = $stmt->fetchAssociative(); + if(!$row || empty($row['schema']) || empty($row['table'])) { + return null; + } + // Quote/qualify as schema.table (matching how other statements look) + return $row['schema'] . '.' . $row['table']; + } catch(\Throwable $e) { + // On any error, fail open by returning null so caller uses original SQL + return null; + } + } +}