Page MenuHomePhabricator

D19765.diff
No OneTemporary

D19765.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -7131,7 +7131,10 @@
'LegalpadTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'LegalpadTransactionView' => 'PhabricatorApplicationTransactionView',
'LiskChunkTestCase' => 'PhabricatorTestCase',
- 'LiskDAO' => 'Phobject',
+ 'LiskDAO' => array(
+ 'Phobject',
+ 'AphrontDatabaseTableRefInterface',
+ ),
'LiskDAOSet' => 'Phobject',
'LiskDAOTestCase' => 'PhabricatorTestCase',
'LiskEphemeralObjectException' => 'Exception',
diff --git a/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php b/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php
--- a/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php
+++ b/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php
@@ -3,23 +3,23 @@
final class QueryFormattingTestCase extends PhabricatorTestCase {
public function testQueryFormatting() {
- $conn_r = id(new PhabricatorUser())->establishConnection('r');
+ $conn = id(new PhabricatorUser())->establishConnection('r');
$this->assertEqual(
'NULL',
- qsprintf($conn_r, '%nd', null));
+ qsprintf($conn, '%nd', null));
$this->assertEqual(
'0',
- qsprintf($conn_r, '%nd', 0));
+ qsprintf($conn, '%nd', 0));
$this->assertEqual(
'0',
- qsprintf($conn_r, '%d', 0));
+ qsprintf($conn, '%d', 0));
$raised = null;
try {
- qsprintf($conn_r, '%d', 'derp');
+ qsprintf($conn, '%d', 'derp');
} catch (Exception $ex) {
$raised = $ex;
}
@@ -29,27 +29,40 @@
$this->assertEqual(
"'<S>'",
- qsprintf($conn_r, '%s', null));
+ qsprintf($conn, '%s', null));
$this->assertEqual(
'NULL',
- qsprintf($conn_r, '%ns', null));
+ qsprintf($conn, '%ns', null));
$this->assertEqual(
"'<S>', '<S>'",
- qsprintf($conn_r, '%Ls', array('x', 'y')));
+ qsprintf($conn, '%Ls', array('x', 'y')));
$this->assertEqual(
"'<B>'",
- qsprintf($conn_r, '%B', null));
+ qsprintf($conn, '%B', null));
$this->assertEqual(
'NULL',
- qsprintf($conn_r, '%nB', null));
+ qsprintf($conn, '%nB', null));
$this->assertEqual(
"'<B>', '<B>'",
- qsprintf($conn_r, '%LB', array('x', 'y')));
+ qsprintf($conn, '%LB', array('x', 'y')));
+
+ $this->assertEqual(
+ '<C>',
+ qsprintf($conn, '%T', 'x'));
+
+ $this->assertEqual(
+ '<C>',
+ qsprintf($conn, '%C', 'y'));
+
+ $this->assertEqual(
+ '<C>.<C>',
+ qsprintf($conn, '%R', new AphrontDatabaseTableRef('x', 'y')));
+
}
diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php
--- a/src/infrastructure/storage/lisk/LiskDAO.php
+++ b/src/infrastructure/storage/lisk/LiskDAO.php
@@ -162,7 +162,8 @@
* @task xaction Managing Transactions
* @task isolate Isolation for Unit Testing
*/
-abstract class LiskDAO extends Phobject {
+abstract class LiskDAO extends Phobject
+ implements AphrontDatabaseTableRefInterface {
const CONFIG_IDS = 'id-mechanism';
const CONFIG_TIMESTAMPS = 'timestamps';
@@ -235,8 +236,11 @@
* @return string Connection namespace for cache
* @task conn
*/
- abstract protected function getConnectionNamespace();
+ protected function getConnectionNamespace() {
+ return $this->getDatabaseName();
+ }
+ abstract protected function getDatabaseName();
/**
* Get an existing, cached connection for this object.
@@ -525,8 +529,8 @@
$args = func_get_args();
$args = array_slice($args, 1);
- $pattern = 'SELECT * FROM %T WHERE '.$pattern.' %Q';
- array_unshift($args, $this->getTableName());
+ $pattern = 'SELECT * FROM %R WHERE '.$pattern.' %Q';
+ array_unshift($args, $this);
array_push($args, $lock_clause);
array_unshift($args, $pattern);
@@ -1150,8 +1154,8 @@
$id = $this->getID();
$conn->query(
- 'UPDATE %T SET %Q WHERE %C = '.(is_int($id) ? '%d' : '%s'),
- $this->getTableName(),
+ 'UPDATE %R SET %Q WHERE %C = '.(is_int($id) ? '%d' : '%s'),
+ $this,
$map,
$this->getIDKeyForUse(),
$id);
@@ -1178,8 +1182,8 @@
$conn = $this->establishConnection('w');
$conn->query(
- 'DELETE FROM %T WHERE %C = %d',
- $this->getTableName(),
+ 'DELETE FROM %R WHERE %C = %d',
+ $this,
$this->getIDKeyForUse(),
$this->getID());
@@ -1255,9 +1259,9 @@
$data = implode(', ', $data);
$conn->query(
- '%Q INTO %T (%LC) VALUES (%Q)',
+ '%Q INTO %R (%LC) VALUES (%Q)',
$mode,
- $this->getTableName(),
+ $this,
$columns,
$data);
@@ -2019,4 +2023,17 @@
->getMaximumByteLengthForDataType($data_type);
}
+
+/* -( AphrontDatabaseTableRefInterface )----------------------------------- */
+
+
+ public function getAphrontRefDatabaseName() {
+ return $this->getDatabaseName();
+ }
+
+ public function getAphrontRefTableName() {
+ return $this->getTableName();
+ }
+
+
}
diff --git a/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php b/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
--- a/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
+++ b/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
@@ -187,11 +187,10 @@
*/
abstract public function getApplicationName();
- protected function getConnectionNamespace() {
+ protected function getDatabaseName() {
return self::getStorageNamespace().'_'.$this->getApplicationName();
}
-
/**
* Break a list of escaped SQL statement fragments (e.g., VALUES lists for
* INSERT, previously built with @{function:qsprintf}) into chunks which will
diff --git a/src/infrastructure/storage/lisk/__tests__/LiskIsolationTestDAO.php b/src/infrastructure/storage/lisk/__tests__/LiskIsolationTestDAO.php
--- a/src/infrastructure/storage/lisk/__tests__/LiskIsolationTestDAO.php
+++ b/src/infrastructure/storage/lisk/__tests__/LiskIsolationTestDAO.php
@@ -22,7 +22,7 @@
'resource!'));
}
- protected function getConnectionNamespace() {
+ protected function getDatabaseName() {
return 'test';
}

File Metadata

Mime Type
text/plain
Expires
May 13 2024, 11:36 PM (4 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6291270
Default Alt Text
D19765.diff (6 KB)

Event Timeline