mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 15:22:41 +01:00
Support DELETE queries in the isolated database connection
Summary: While we eventually need a plan to make this less of a toy black hole, we can support DELETE now -- it's just SELECT that's tricky. Test Plan: Ran unit tests. Reviewers: zeeg, jungejason, btrahan Reviewed By: btrahan CC: aran, btrahan Differential Revision: 1226
This commit is contained in:
parent
0386ac9aa2
commit
8a6e919496
2 changed files with 10 additions and 5 deletions
|
@ -74,14 +74,14 @@ class AphrontIsolatedDatabaseConnection extends AphrontDatabaseConnection {
|
|||
public function executeRawQuery($raw_query) {
|
||||
|
||||
// NOTE: "[\s<>K]*" allows any number of (properly escaped) comments to
|
||||
// appear prior to the INSERT/UPDATE, since this connection escapes them
|
||||
// as "<K>" (above).
|
||||
if (!preg_match('/^[\s<>K]*(INSERT|UPDATE)\s*/i', $raw_query)) {
|
||||
// appear prior to the INSERT/UPDATE/DELETE, since this connection escapes
|
||||
// them as "<K>" (above).
|
||||
if (!preg_match('/^[\s<>K]*(INSERT|UPDATE|DELETE)\s*/i', $raw_query)) {
|
||||
$doc_uri = PhabricatorEnv::getDoclink('article/Writing_Unit_Tests.html');
|
||||
throw new Exception(
|
||||
"Database isolation currently only supports INSERT and UPDATE ".
|
||||
"Database isolation currently only supports INSERT, UPDATE and DELETE ".
|
||||
"queries. For more information, see <{$doc_uri}>. You are trying to ".
|
||||
"issue a query which does not begin with INSERT or UPDATE: ".
|
||||
"issue a query which does not begin with INSERT, UPDATE or DELETE: ".
|
||||
"'".$raw_query."'");
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,11 @@ class AphrontIsolatedDatabaseConnectionTestCase
|
|||
"IDs '{$id1}' and '{$id2}' are distinct.");
|
||||
}
|
||||
|
||||
public function testDeletePermitted() {
|
||||
$conn = $this->newIsolatedConnection();
|
||||
queryfx($conn, 'DELETE');
|
||||
}
|
||||
|
||||
private function newIsolatedConnection() {
|
||||
$config = array();
|
||||
return new AphrontIsolatedDatabaseConnection($config);
|
||||
|
|
Loading…
Reference in a new issue