Skip to content

Commit

Permalink
Database: SelectionFactory renamed to Context (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 20, 2013
1 parent c6d5415 commit ffa9efe
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 34 deletions.
24 changes: 12 additions & 12 deletions src/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Connection extends Nette\Object
/** @var SqlPreprocessor */
private $preprocessor;

/** @var SelectionFactory */
private $selectionFactory;
/** @var Context */
private $context;

/** @var PDO */
private $pdo;
Expand Down Expand Up @@ -256,41 +256,41 @@ public static function literal($value)
/** @deprecated */
public function table($table)
{
trigger_error(__METHOD__ . '() is deprecated; use SelectionFactory::table() instead.', E_USER_DEPRECATED);
if (!$this->selectionFactory) {
$this->selectionFactory = new SelectionFactory($this);
trigger_error(__METHOD__ . '() is deprecated; use Context::table() instead.', E_USER_DEPRECATED);
if (!$this->context) {
$this->context = new Context($this);
}
return $this->selectionFactory->table($table);
return $this->context->table($table);
}


/** @deprecated */
public function setSelectionFactory(SelectionFactory $selectionFactory)
public function setContext(Context $context)
{
$this->selectionFactory = $selectionFactory;
$this->context = $context;
return $this;
}


/** @deprecated */
public function getSelectionFactory()
public function getContext()
{
return $this->selectionFactory;
return $this->context;
}


/** @deprecated */
function setDatabaseReflection()
{
trigger_error(__METHOD__ . '() is deprecated; use setSelectionFactory() instead.', E_USER_DEPRECATED);
trigger_error(__METHOD__ . '() is deprecated; use setContext() instead.', E_USER_DEPRECATED);
return $this;
}


/** @deprecated */
function setCacheStorage()
{
trigger_error(__METHOD__ . '() is deprecated; use setSelectionFactory() instead.', E_USER_DEPRECATED);
trigger_error(__METHOD__ . '() is deprecated; use setContext() instead.', E_USER_DEPRECATED);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@


/**
* Table\Selection factory.
* Database context.
*
* @author David Grudl
*/
class SelectionFactory extends Nette\Object
class Context extends Nette\Object
{
/** @var Connection */
private $connection;
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/GroupedSelection.insert().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require __DIR__ . '/connect.inc.php'; // create $connection

Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName}-nette_test1.sql");

$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Selection.insert().multi.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
require __DIR__ . '/connect.inc.php'; // create $connection

Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName}-nette_test1.sql");
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Selection.insert().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Assert::equal(4, $dao->table('book')->where('title LIKE', "Biography%")->count('


// Insert into table without primary key
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
4 changes: 2 additions & 2 deletions tests/Database/SqlBuilder.addWhere().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use Nette\Database\Table\SqlBuilder;


$reflection = new DiscoveredReflection($connection);
$dao = new Nette\Database\SelectionFactory($connection, $reflection);
$dao = new Nette\Database\Context($connection, $reflection);


test(function() use ($connection, $reflection) { // test paramateres with NULL
Expand Down Expand Up @@ -214,7 +214,7 @@ test(function() use ($driverName, $connection, $reflection) {
}

$reflection = new DiscoveredReflection($connection);
$dao = new Nette\Database\SelectionFactory($connection, $reflection);
$dao = new Nette\Database\Context($connection, $reflection);

$e = Assert::exception(function() use ($dao) {
$books = $dao->table('book')->where('id',
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.basic.camelCase.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
require __DIR__ . '/connect.inc.php'; // create $connection

Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName}-nette_test2.sql");
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test(function() use ($dao) {


test(function() use ($connection, $dao) {
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.cache.observer.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CacheMock implements Nette\Caching\IStorage
}

$cacheStorage = new CacheMock;
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection, new Nette\Caching\Storages\MemoryStorage),
$cacheStorage
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.cache.observer2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CacheMock extends MemoryStorage
}
}

$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection, new Nette\Caching\Storages\MemoryStorage),
($cacheStorage = new CacheMock)
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.cache.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName


$cacheStorage = new Nette\Caching\Storages\MemoryStorage;
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection, $cacheStorage),
$cacheStorage
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.cache.rows.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require __DIR__ . '/connect.inc.php'; // create $connection
Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName}-nette_test1.sql");

$cacheStorage = new Nette\Caching\Storages\MemoryStorage;
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection, $cacheStorage),
$cacheStorage
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.cache2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName


$cacheStorage = new Nette\Caching\Storages\MemoryStorage;
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection, $cacheStorage),
$cacheStorage
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.columnRefetch.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName


$cacheStorage = new Nette\Caching\Storages\MemoryStorage;
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection, $cacheStorage),
$cacheStorage
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.discoveredReflection.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
require __DIR__ . '/connect.inc.php'; // create $connection

Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName}-nette_test1.sql");
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.join.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ test(function() use ($dao) {


test(function() use ($connection) {
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.multi-primary-key.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require __DIR__ . '/connect.inc.php'; // create $connection

Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName}-nette_test1.sql");
$cacheStorage = new Nette\Caching\Storages\MemoryStorage;
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection, $cacheStorage),
$cacheStorage
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.placeholders.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use Nette\Database\Table\SqlBuilder;


$reflection = new DiscoveredReflection($connection);
$dao = new Nette\Database\SelectionFactory($connection, $reflection);
$dao = new Nette\Database\Context($connection, $reflection);


test(function() use ($dao, $driverName) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.self-reference.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use Nette\Database;
require __DIR__ . '/connect.inc.php'; // create $connection

Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName}-nette_test1.sql");
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Table.update().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
require __DIR__ . '/connect.inc.php'; // create $connection

Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/files/{$driverName}-nette_test1.sql");
$dao = new Nette\Database\SelectionFactory(
$dao = new Nette\Database\Context(
$connection,
new Nette\Database\Reflection\DiscoveredReflection($connection)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/connect.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Tester\Environment::lock($options['dsn'], dirname(TEMP_DIR));
}
$driverName = $connection->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
$dao = new Nette\Database\SelectionFactory($connection);
$dao = new Nette\Database\Context($connection);


/** Replaces [] with driver-specific quotes */
Expand Down

0 comments on commit ffa9efe

Please sign in to comment.