Skip to content

Commit

Permalink
MDL-67394 dml: improve thrown exception when Oracle can't parse query.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jul 30, 2020
1 parent 07238ca commit 42fcf7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lang/en/error.php
Expand Up @@ -221,6 +221,7 @@
$string['destinationcmnotexit'] = 'The destination course module does not exist';
$string['detectedbrokenplugin'] = 'Plugin "{$a}" is defective or outdated, can not continue, sorry.';
$string['dmlexceptiononinstall'] = '<p>A database error has occurred [{$a->errorcode}].<br />{$a->debuginfo}</p>';
$string['dmlparseexception'] = 'Error parsing SQL query';
$string['dmlreadexception'] = 'Error reading from database';
$string['dmltransactionexception'] = 'Database transaction error';
$string['dmlwriteexception'] = 'Error writing to database';
Expand Down
6 changes: 4 additions & 2 deletions lib/dml/oci_native_moodle_database.php
Expand Up @@ -345,14 +345,16 @@ public function get_last_error() {

/**
* Prepare the statement for execution
* @throws dml_connection_exception
*
* @param string $sql
* @return resource
*
* @throws dml_exception
*/
protected function parse_query($sql) {
$stmt = oci_parse($this->oci, $sql);
if ($stmt == false) {
throw new dml_connection_exception('Can not parse sql query'); //TODO: maybe add better info
throw new dml_exception('dmlparseexception', null, $this->get_last_error());
}
return $stmt;
}
Expand Down

0 comments on commit 42fcf7d

Please sign in to comment.