From a2bb8e5f90c3d0f4b698aacc173a1f6e9195c2da Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 12 May 2023 16:22:50 -0600 Subject: [PATCH] Limit subquery to one result This prevent a cardinality error. --- resources/classes/schema.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/classes/schema.php b/resources/classes/schema.php index 07ed109044..f43e7e2eee 100644 --- a/resources/classes/schema.php +++ b/resources/classes/schema.php @@ -164,7 +164,7 @@ if (!class_exists('schema')) { } } if ($this->db_type == "pgsql") { - $sql = "SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '$table_name') AND attname = '$column_name'; "; + $sql = "SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '$table_name' limit 1) AND attname = '$column_name'; "; } if ($this->db_type == "mysql") { //$sql .= "SELECT * FROM information_schema.COLUMNS where TABLE_SCHEMA = '$db_name' and TABLE_NAME = '$table_name' and COLUMN_NAME = '$column_name' "; @@ -325,7 +325,7 @@ if (!class_exists('schema')) { } } if ($db_type == "pgsql") { - $sql = "SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '$table_name') AND attname = '$column_name'; "; + $sql = "SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '$table_name' limit 1) AND attname = '$column_name'; "; } if ($db_type == "mysql") { //$sql .= "SELECT * FROM information_schema.COLUMNS where TABLE_SCHEMA = '$db_name' and TABLE_NAME = '$table_name' and COLUMN_NAME = '$column_name' ";