From ed749fdc97788d4f0b7e8b6b457a61d8ef495cae Mon Sep 17 00:00:00 2001 From: Stephen Cuppett Date: Sun, 29 Dec 2013 21:43:56 -0500 Subject: [PATCH] Must double quote the schema name in query Schema names with reserved words such as "create" will fail this query without double quotes. Attempted prepared statement with ? placeholder. This failed with the following CakePHP error: Error: A Database connection using "Postgres" was missing or unable to connect. The database server returned this error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "$1" LINE 1: SET search_path TO $1 ^ --- lib/Cake/Model/Datasource/Database/Postgres.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index a71eeba28d4..9d299a133f5 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -127,7 +127,7 @@ public function connect() { $this->setEncoding($config['encoding']); } if (!empty($config['schema'])) { - $this->_execute('SET search_path TO ' . $config['schema']); + $this->_execute('SET search_path TO "' . $config['schema'] . '"'); } if (!empty($config['settings'])) { foreach ($config['settings'] as $key => $value) {