Skip to content

Commit

Permalink
Must double quote the schema name in query
Browse files Browse the repository at this point in the history
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 ^
  • Loading branch information
cuppett committed Dec 30, 2013
1 parent b728bce commit ed749fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Postgres.php
Expand Up @@ -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) {
Expand Down

0 comments on commit ed749fd

Please sign in to comment.