From 471cfa1eee7a11f25372490d803da0ba87342852 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 13 Feb 2023 14:37:56 +0800 Subject: [PATCH] fix joinas quoting identifiers --- DB/DataObject.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DB/DataObject.php b/DB/DataObject.php index ac5b86b9..28aaac2e 100644 --- a/DB/DataObject.php +++ b/DB/DataObject.php @@ -2963,7 +2963,7 @@ class DB_DataObject extends DB_DataObject_Overload ? ( $DB->quoteIdentifier($this->tableName()) . '.' . $DB->quoteIdentifier($k) ) : "{$this->tableName()}.{$k}"; - + if (is_object($this->$k) && is_a($this->$k,'DB_DataObject_Cast')) { $dbtype = $DB->dsn["phptype"]; @@ -3838,12 +3838,14 @@ class DB_DataObject extends DB_DataObject_Overload $joinType = strtoupper($joinType); // we default to joining as the same name (this is remvoed later..) + $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']); + if ($joinAs === false) { $joinAs = $obj->tableName(); } + $joinAs = $quoteIdentifiers ? $DB->quoteIdentifier($joinAs) : $joinAs; - $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']); $options = $_DB_DATAOBJECT['CONFIG']; // not sure how portable adding database prefixes is.. @@ -3985,7 +3987,7 @@ class DB_DataObject extends DB_DataObject_Overload $table = $this->tableName(); if ($quoteIdentifiers) { - $joinAs = $DB->quoteIdentifier($joinAs); + $table = $DB->quoteIdentifier($table); $ofield = (is_array($ofield)) ? array_map(array($DB, 'quoteIdentifier'), $ofield) : $DB->quoteIdentifier($ofield); $tfield = (is_array($tfield)) ? array_map(array($DB, 'quoteIdentifier'), $tfield) : $DB->quoteIdentifier($tfield); -- 2.39.2