1
0
Fork 0
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:
epriestley 2011-12-16 15:39:00 -08:00
parent 0386ac9aa2
commit 8a6e919496
2 changed files with 10 additions and 5 deletions

View file

@ -74,14 +74,14 @@ class AphrontIsolatedDatabaseConnection extends AphrontDatabaseConnection {
public function executeRawQuery($raw_query) { public function executeRawQuery($raw_query) {
// NOTE: "[\s<>K]*" allows any number of (properly escaped) comments to // NOTE: "[\s<>K]*" allows any number of (properly escaped) comments to
// appear prior to the INSERT/UPDATE, since this connection escapes them // appear prior to the INSERT/UPDATE/DELETE, since this connection escapes
// as "<K>" (above). // them as "<K>" (above).
if (!preg_match('/^[\s<>K]*(INSERT|UPDATE)\s*/i', $raw_query)) { if (!preg_match('/^[\s<>K]*(INSERT|UPDATE|DELETE)\s*/i', $raw_query)) {
$doc_uri = PhabricatorEnv::getDoclink('article/Writing_Unit_Tests.html'); $doc_uri = PhabricatorEnv::getDoclink('article/Writing_Unit_Tests.html');
throw new Exception( 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 ". "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."'"); "'".$raw_query."'");
} }

View file

@ -70,6 +70,11 @@ class AphrontIsolatedDatabaseConnectionTestCase
"IDs '{$id1}' and '{$id2}' are distinct."); "IDs '{$id1}' and '{$id2}' are distinct.");
} }
public function testDeletePermitted() {
$conn = $this->newIsolatedConnection();
queryfx($conn, 'DELETE');
}
private function newIsolatedConnection() { private function newIsolatedConnection() {
$config = array(); $config = array();
return new AphrontIsolatedDatabaseConnection($config); return new AphrontIsolatedDatabaseConnection($config);