From 585287c1396e2ac54e38ebf4d5cc0a4450dac47c Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 13 Oct 2015 18:59:06 +0200 Subject: [PATCH 1/9] typo --- src/Database/DriverException.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Database/DriverException.php b/src/Database/DriverException.php index 9c0320423..6d8394353 100644 --- a/src/Database/DriverException.php +++ b/src/Database/DriverException.php @@ -18,7 +18,7 @@ class DriverException extends \PDOException /** - * @returns self + * @return self */ public static function from(\PDOException $src) { @@ -36,7 +36,7 @@ public static function from(\PDOException $src) /** - * @returns int|string|NULL Driver-specific error code + * @return int|string|NULL Driver-specific error code */ public function getDriverCode() { @@ -45,7 +45,7 @@ public function getDriverCode() /** - * @returns string|NULL SQLSTATE error code + * @return string|NULL SQLSTATE error code */ public function getSqlState() { @@ -54,7 +54,7 @@ public function getSqlState() /** - * @returns string|NULL SQL command + * @return string|NULL SQL command */ public function getQueryString() { From be31664c170dfbfe4badc5db4cda13cf3d0a4d57 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 22 Oct 2015 16:43:17 +0200 Subject: [PATCH 2/9] ActiveRow: optimization --- src/Database/Table/ActiveRow.php | 11 ++++------- src/Database/Table/Selection.php | 6 ++++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Database/Table/ActiveRow.php b/src/Database/Table/ActiveRow.php index 8e400be35..1e9a711cd 100644 --- a/src/Database/Table/ActiveRow.php +++ b/src/Database/Table/ActiveRow.php @@ -281,8 +281,7 @@ public function __set($key, $value) */ public function &__get($key) { - $this->accessColumn($key); - if (array_key_exists($key, $this->data)) { + if ($this->accessColumn($key)) { return $this->data[$key]; } @@ -300,8 +299,7 @@ public function &__get($key) public function __isset($key) { - $this->accessColumn($key); - if (array_key_exists($key, $this->data)) { + if ($this->accessColumn($key)) { return isset($this->data[$key]); } $this->removeAccessColumn($key); @@ -320,15 +318,14 @@ public function __unset($key) */ public function accessColumn($key, $selectColumn = TRUE) { - $this->table->accessColumn($key, $selectColumn); - if ($this->table->getDataRefreshed() && !$this->dataRefreshed) { + if ($this->table->accessColumn($key, $selectColumn) && !$this->dataRefreshed) { if (!isset($this->table[$this->getSignature()])) { throw new Nette\InvalidStateException('Database refetch failed; row does not exist!'); } $this->data = $this->table[$this->getSignature()]->data; $this->dataRefreshed = TRUE; } - return array_key_exists($key, $this->data); + return isset($this->data[$key]) || array_key_exists($key, $this->data); } diff --git a/src/Database/Table/Selection.php b/src/Database/Table/Selection.php index 3700744e1..0d9452a07 100644 --- a/src/Database/Table/Selection.php +++ b/src/Database/Table/Selection.php @@ -660,11 +660,12 @@ protected function getSpecificCacheKey() * @internal * @param string|NULL column name or NULL to reload all columns * @param bool + * @return bool if selection requeried for more columns. */ public function accessColumn($key, $selectColumn = TRUE) { if (!$this->cache) { - return; + return FALSE; } if ($key === NULL) { @@ -674,7 +675,7 @@ public function accessColumn($key, $selectColumn = TRUE) $this->accessedColumns[$key] = $selectColumn; } - if ($selectColumn && !$this->sqlBuilder->getSelect() && $this->previousAccessedColumns && ($key === NULL || !isset($this->previousAccessedColumns[$key]))) { + if ($selectColumn && $this->previousAccessedColumns && ($key === NULL || !isset($this->previousAccessedColumns[$key])) && !$this->sqlBuilder->getSelect()) { $this->previousAccessedColumns = array(); if ($this->sqlBuilder->getLimit()) { @@ -709,6 +710,7 @@ public function accessColumn($key, $selectColumn = TRUE) } } } + return $this->dataRefreshed; } From b71ce1dbc0c78787847de97ce96de63701c397ea Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 4 Nov 2015 18:25:54 +0100 Subject: [PATCH 3/9] travis: uses own databases.travis.ini --- .travis.yml | 2 +- tests/Database/databases.sample.ini | 8 ++++---- tests/databases.travis.ini | 12 ++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 tests/databases.travis.ini diff --git a/.travis.yml b/.travis.yml index fcc25f4e9..1338b4dd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_script: - travis_retry composer create-project nette/code-checker code-checker ~2.5 --no-interaction # Create databases.ini - - cp ./tests/Database/databases.sample.ini ./tests/Database/databases.ini + - cp ./tests/databases.travis.ini ./tests/Database/databases.ini # Create Postgre database - psql -c 'CREATE DATABASE nette_test' -U postgres diff --git a/tests/Database/databases.sample.ini b/tests/Database/databases.sample.ini index 42748c9d1..c5c4dd9b4 100644 --- a/tests/Database/databases.sample.ini +++ b/tests/Database/databases.sample.ini @@ -13,7 +13,7 @@ password = [sqlite] dsn = "sqlite::memory:" -;[sqlsrv] -;dsn = "sqlsrv:server=127.0.0.1;database=nette_test" -;user = nette -;password = +[sqlsrv] +dsn = "sqlsrv:server=127.0.0.1;database=nette_test" +user = nette +password = diff --git a/tests/databases.travis.ini b/tests/databases.travis.ini new file mode 100644 index 000000000..e253dc27a --- /dev/null +++ b/tests/databases.travis.ini @@ -0,0 +1,12 @@ +[mysql] +dsn = "mysql:host=127.0.0.1" +user = root +password = + +[postgresql] +dsn = "pgsql:host=127.0.0.1;dbname=nette_test" +user = postgres +password = + +[sqlite] +dsn = "sqlite::memory:" From 15e927f37a07ab54e154fb5495524c9fc1faeaee Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 4 Nov 2015 18:37:41 +0100 Subject: [PATCH 4/9] tests: do not skip errors in Tester\Environment::loadData (like "Cannot parse data-provider file") # Conflicts: # tests/Database/connect.inc.php --- tests/Database/connect.inc.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/Database/connect.inc.php b/tests/Database/connect.inc.php index 1e66178f4..da4fe8a6b 100644 --- a/tests/Database/connect.inc.php +++ b/tests/Database/connect.inc.php @@ -7,11 +7,7 @@ require __DIR__ . '/../bootstrap.php'; -try { - $options = Tester\Environment::loadData() + array('user' => NULL, 'password' => NULL); -} catch (Exception $e) { - Tester\Environment::skip($e->getMessage()); -} +$options = Tester\Environment::loadData() + array('user' => NULL, 'password' => NULL); try { $connection = new Nette\Database\Connection($options['dsn'], $options['user'], $options['password']); From e02d3f27445d572973e46630db8b07d80c265674 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 4 Nov 2015 19:49:54 +0100 Subject: [PATCH 5/9] tests: some tests fixed to work with MS SQL Server --- tests/Database/Table/Selection.insert().phpt | 37 +++++++------- tests/Database/Table/Selection.page().phpt | 29 ++++++----- tests/Database/Table/Table.limit.sqlsrv.phpt | 48 +++++++++++++------ tests/Database/Table/Table.placeholders.phpt | 6 ++- .../Table/Table.related().caching.phpt | 4 +- tests/Database/Table/Table.update().phpt | 11 +++-- tests/Database/Table/bugs/bug1356.phpt | 2 +- 7 files changed, 87 insertions(+), 50 deletions(-) diff --git a/tests/Database/Table/Selection.insert().phpt b/tests/Database/Table/Selection.insert().phpt index bcfb674f9..f078199e7 100644 --- a/tests/Database/Table/Selection.insert().phpt +++ b/tests/Database/Table/Selection.insert().phpt @@ -49,24 +49,27 @@ if ($driverName !== 'sqlsrv') { } -switch ($driverName) { - case 'mysql': - $selection = $context->table('author')->select('NULL, id, NULL, CONCAT(?, name), NULL', 'Biography: '); - break; - case 'pgsql': - $selection = $context->table('author')->select('nextval(?), id, NULL, ? || name, NULL', 'book_id_seq', 'Biography: '); - break; - case 'sqlite': - $selection = $context->table('author')->select('NULL, id, NULL, ? || name, NULL', 'Biography: '); - break; - case 'sqlsrv': - $selection = $context->table('author')->select('id, NULL, CONCAT(?, name), NULL', 'Biography: '); - break; - default: - Assert::fail("Unsupported driver $driverName"); +// SQL Server 2008 doesn't know CONCAT() +if ($driverName !== 'sqlsrv') { + switch ($driverName) { + case 'mysql': + $selection = $context->table('author')->select('NULL, id, NULL, CONCAT(?, name), NULL', 'Biography: '); + break; + case 'pgsql': + $selection = $context->table('author')->select('nextval(?), id, NULL, ? || name, NULL', 'book_id_seq', 'Biography: '); + break; + case 'sqlite': + $selection = $context->table('author')->select('NULL, id, NULL, ? || name, NULL', 'Biography: '); + break; + case 'sqlsrv': + $selection = $context->table('author')->select('id, NULL, CONCAT(?, name), NULL', 'Biography: '); + break; + default: + Assert::fail("Unsupported driver $driverName"); + } + $context->table('book')->insert($selection); + Assert::equal(4, $context->table('book')->where('title LIKE', 'Biography%')->count('*')); } -$context->table('book')->insert($selection); -Assert::equal(4, $context->table('book')->where('title LIKE', 'Biography%')->count('*')); // Insert into table without primary key diff --git a/tests/Database/Table/Selection.page().phpt b/tests/Database/Table/Selection.page().phpt index f23f9ec9a..a08d72600 100644 --- a/tests/Database/Table/Selection.page().phpt +++ b/tests/Database/Table/Selection.page().phpt @@ -9,6 +9,10 @@ use Tester\Assert; require __DIR__ . '/../connect.inc.php'; // create $connection +if ($driverName === 'sqlsrv') { + Tester\Environment::skip('Offset is supported since SQL Server 2012'); // and requires to set order +} + Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverName}-nette_test1.sql"); //public function page($page, $itemsPerPage, & $numOfPages = NULL) @@ -16,45 +20,48 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverN test(function () use ($context) { //first page, one item per page $numberOfPages = 0; - $tags = $context->table('tag')->page(1, 1, $numOfPages); + $tags = $context->table('tag')->page(1, 1, $numOfPages)->order('id'); Assert::equal(1, count($tags)); //one item on first page Assert::equal(4, $numOfPages); //four pages total //calling the same without the $numOfPages reference unset($tags); - $tags = $context->table('tag')->page(1, 1); + $tags = $context->table('tag')->page(1, 1)->order('id'); Assert::equal(1, count($tags)); //one item on first page }); test(function () use ($context) { //second page, three items per page $numberOfPages = 0; - $tags = $context->table('tag')->page(2, 3, $numOfPages); + $tags = $context->table('tag')->page(2, 3, $numOfPages)->order('id'); Assert::equal(1, count($tags)); //one item on second page Assert::equal(2, $numOfPages); //two pages total //calling the same without the $numOfPages reference unset($tags); - $tags = $context->table('tag')->page(2, 3); + $tags = $context->table('tag')->page(2, 3)->order('id'); Assert::equal(1, count($tags)); //one item on second page }); test(function () use ($context) { //page with no items - $tags = $context->table('tag')->page(10, 4); + $tags = $context->table('tag')->page(10, 4)->order('id'); Assert::equal(0, count($tags)); //one item on second page }); test(function () use ($context) { //page with no items (page not in range) - $tags = $context->table('tag')->page(100, 4); + $tags = $context->table('tag')->page(100, 4)->order('id'); Assert::equal(0, count($tags)); //one item on second page }); test(function () use ($context) { //less items than $itemsPerPage - $tags = $context->table('tag')->page(1, 100); + $tags = $context->table('tag')->page(1, 100)->order('id'); Assert::equal(4, count($tags)); //all four items from db }); -test(function () use ($context) { //invalid params - $tags = $context->table('tag')->page('foo', 'bar'); - Assert::equal(0, count($tags)); //no items -}); +// SQL Server throw PDOException 'The number of rows provided for a FETCH clause must be greater then zero.' +if ($driverName !== 'sqlsrv') { + test(function () use ($context) { //invalid params + $tags = $context->table('tag')->page('foo', 'bar')->order('id'); + Assert::equal(0, count($tags)); //no items + }); +} diff --git a/tests/Database/Table/Table.limit.sqlsrv.phpt b/tests/Database/Table/Table.limit.sqlsrv.phpt index e94edf78e..b312387b3 100644 --- a/tests/Database/Table/Table.limit.sqlsrv.phpt +++ b/tests/Database/Table/Table.limit.sqlsrv.phpt @@ -11,35 +11,55 @@ require __DIR__ . '/../connect.inc.php'; // create $connection Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverName}-nette_test1.sql"); +$version2008 = $connection->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION) < 11; Assert::same( - 'SELECT TOP 2 * FROM [author]', + $version2008 + ? 'SELECT TOP 2 * FROM [author]' + : 'SELECT * FROM [author] OFFSET 0 ROWS FETCH NEXT 2 ROWS ONLY', $context->table('author')->limit(2)->getSql() ); -Assert::exception(function () use ($context) { - $context->table('author')->limit(2, 10)->getSql(); -}, 'Nette\NotSupportedException', 'Offset is not supported by this database.'); - Assert::same( - 'SELECT TOP 2 * FROM [author] ORDER BY [name]', + $version2008 + ? 'SELECT TOP 2 * FROM [author] ORDER BY [name]' + : 'SELECT * FROM [author] ORDER BY [name] OFFSET 0 ROWS FETCH NEXT 2 ROWS ONLY', $context->table('author')->order('name')->limit(2)->getSql() ); Assert::same( - 'SELECT TOP 10 * FROM [author]', + $version2008 + ? 'SELECT TOP 10 * FROM [author]' + : 'SELECT * FROM [author] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $context->table('author')->page(1, 10)->getSql() ); Assert::same( - 'SELECT TOP 10 * FROM [author]', + $version2008 + ? 'SELECT TOP 10 * FROM [author]' + : 'SELECT * FROM [author] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $context->table('author')->page(0, 10)->getSql() ); -Assert::exception(function () use ($context) { - $context->table('author')->page(2, 10, $count)->getSql(); -}, 'Nette\NotSupportedException', 'Offset is not supported by this database.'); +if ($version2008) { + Assert::exception(function () use ($context) { + $context->table('author')->page(2, 10, $count)->getSql(); + }, 'Nette\NotSupportedException', 'Offset is not supported by this database.'); + + Assert::exception(function () use ($context) { + $context->table('author')->page(2, 2, $count)->getSql(); + }, 'Nette\NotSupportedException', 'Offset is not supported by this database.'); + +} else { + Assert::same( + reformat('SELECT * FROM [author] OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY'), + $context->table('author')->page(2, 10, $count)->getSql() + ); + Assert::same(1, $count); -Assert::exception(function () use ($context) { - $context->table('author')->page(2, 2, $count)->getSql(); -}, 'Nette\NotSupportedException', 'Offset is not supported by this database.'); + Assert::same( + reformat('SELECT * FROM [author] OFFSET 2 ROWS FETCH NEXT 2 ROWS ONLY'), + $context->table('author')->page(2, 2, $count)->getSql() + ); + Assert::same(2, $count); +} diff --git a/tests/Database/Table/Table.placeholders.phpt b/tests/Database/Table/Table.placeholders.phpt index 2905e4bca..d2b7c5fe7 100644 --- a/tests/Database/Table/Table.placeholders.phpt +++ b/tests/Database/Table/Table.placeholders.phpt @@ -76,7 +76,11 @@ test(function () use ($context, $driverName) { }); -test(function () use ($context) { // Test placeholder for GroupedSelection +test(function () use ($context, $driverName) { // Test placeholder for GroupedSelection + if ($driverName === 'sqlsrv') { // This syntax is not supported on SQL Server + return; + } + $books = $context->table('author')->get(11)->related('book')->order('title = ? DESC', 'Test'); foreach ($books as $book) {} diff --git a/tests/Database/Table/Table.related().caching.phpt b/tests/Database/Table/Table.related().caching.phpt index b8a3c9983..1bff81ffd 100644 --- a/tests/Database/Table/Table.related().caching.phpt +++ b/tests/Database/Table/Table.related().caching.phpt @@ -63,12 +63,12 @@ test(function () use ($context) { $context->query('UPDATE book SET translator_id = 12 WHERE id = 2'); $author = $context->table('author')->get(11); - foreach ($author->related('book')->limit(1) as $book) { + foreach ($author->related('book')->limit(1)->order('id') as $book) { // MS SQL Server requires order $book->ref('author', 'translator_id')->name; } $translators = array(); - foreach ($author->related('book')->limit(2) as $book) { + foreach ($author->related('book')->limit(2)->order('id') as $book) { // MS SQL Server requires order $translators[] = $book->ref('author', 'translator_id')->name; } sort($translators); diff --git a/tests/Database/Table/Table.update().phpt b/tests/Database/Table/Table.update().phpt index f505bd26a..879111cc0 100644 --- a/tests/Database/Table/Table.update().phpt +++ b/tests/Database/Table/Table.update().phpt @@ -74,10 +74,13 @@ $tag2 = $context->table('tag')->insert(array( 'name' => 'PS4 Game', )); // INSERT INTO `tag` (`name`) VALUES ('PS4 Game') -$tag2->update(array( - 'id' => 1, -)); // UPDATE `tag` SET `id`=1 WHERE (`id` = (?)) -Assert::same(1, $tag2->id); +// SQL Server throw PDOException because does not allow to update identity column +if ($driverName !== 'sqlsrv') { + $tag2->update(array( + 'id' => 1, + )); // UPDATE `tag` SET `id`=1 WHERE (`id` = (?)) + Assert::same(1, $tag2->id); +} $book_tag = $context->table('book_tag')->get(array( diff --git a/tests/Database/Table/bugs/bug1356.phpt b/tests/Database/Table/bugs/bug1356.phpt index 6d81fbe75..12a6b19b1 100644 --- a/tests/Database/Table/bugs/bug1356.phpt +++ b/tests/Database/Table/bugs/bug1356.phpt @@ -2,7 +2,7 @@ /** * Test: bug 1356 - * @dataProvider? ../../databases.ini + * @dataProvider? ../../databases.ini !=sqlsrv */ use Tester\Assert; From 4b4291b1f06e9ba8b6d641a60e1f80994a04d55c Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 4 Nov 2015 18:23:07 +0100 Subject: [PATCH 6/9] added appveyor.yml --- appveyor.yml | 41 ++++++++++++++++++++++++++++++++++++ readme.md | 1 + tests/databases.appveyor.ini | 23 ++++++++++++++++++++ tests/php-win.ini | 1 + 4 files changed, 66 insertions(+) create mode 100644 appveyor.yml create mode 100644 tests/databases.appveyor.ini diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..2b1c34949 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,41 @@ +build: off +cache: + - c:\php -> appveyor.yml + - '%LOCALAPPDATA%\Composer\files -> appveyor.yml' + +clone_folder: c:\projects\database + +services: + - mssql2008r2sp2 + - mssql2012sp1 + - mssql2014 + - mysql + +init: + - SET PATH=c:\php;%PATH% + - SET PHP=1 + - SET ANSICON=121x90 (121x90) + +install: + # Install PHP + - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) + - IF %PHP%==1 cd c:\php + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.3.29-Win32-VC9-x86.zip + - IF %PHP%==1 7z x php-5.3.29-Win32-VC9-x86.zip >nul + - IF %PHP%==1 echo extension_dir=ext >> php.ini + - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini + - IF %PHP%==1 appveyor DownloadFile https://files.nette.org/misc/php-sqlsrv.zip + - IF %PHP%==1 7z x php-sqlsrv.zip >nul + - IF %PHP%==1 copy SQLSRV\php_pdo_sqlsrv_53_ts.dll ext\php_pdo_sqlsrv_ts.dll + - IF %PHP%==1 del /Q *.zip + - cd c:\projects\database + + # Install Nette Tester + - appveyor DownloadFile https://getcomposer.org/composer.phar + - php composer.phar install --prefer-dist --no-interaction --no-progress + + # Create databases.ini + - copy tests\databases.appveyor.ini tests\Database\databases.ini + +test_script: + - vendor\bin\tester tests -s -p php -c tests\php-win.ini diff --git a/readme.md b/readme.md index 5b07351f6..d7ffecc31 100644 --- a/readme.md +++ b/readme.md @@ -3,6 +3,7 @@ Nette Database [![Downloads this Month](https://img.shields.io/packagist/dm/nette/database.svg)](https://packagist.org/packages/nette/database) [![Build Status](https://travis-ci.org/nette/database.svg?branch=v2.3)](https://travis-ci.org/nette/database) +[![Build Status Windows](https://ci.appveyor.com/api/projects/status/github/nette/database?branch=v2.3&svg=true)](https://ci.appveyor.com/project/dg/database/branch/v2.3) Nette provides a powerful layer for accessing your database easily. diff --git a/tests/databases.appveyor.ini b/tests/databases.appveyor.ini new file mode 100644 index 000000000..6a493ebe6 --- /dev/null +++ b/tests/databases.appveyor.ini @@ -0,0 +1,23 @@ +[mysql] +dsn = "mysql:host=127.0.0.1" +user = root +password = "Password12!" + +[sqlite] +dsn = "sqlite::memory:" + +[sqlsrv 2008] +dsn = "sqlsrv:Server=(local)\SQL2008R2SP2;Database=master" +user = sa +password = "Password12!" + +[sqlsrv 2012] +dsn = "sqlsrv:Server=(local)\SQL2012SP1;Database=master" +user = sa +password = "Password12!" + +; NDB does not differentiate between 2012 and 2014 +;[sqlsrv 2014] +;dsn = "sqlsrv:Server=(local)\SQL2014;Database=master" +;user = sa +;password = "Password12!" diff --git a/tests/php-win.ini b/tests/php-win.ini index bd274e004..7d024ac2e 100644 --- a/tests/php-win.ini +++ b/tests/php-win.ini @@ -3,6 +3,7 @@ extension_dir = "./ext" extension=php_pdo_mysql.dll extension=php_pdo_sqlite.dll extension=php_pdo_pgsql.dll +extension=php_pdo_sqlsrv_ts.dll [Zend] ;zend_extension="./ext/php_xdebug-2.0.5-5.3-vc6.dll" From d2ba8d4465d2ba1fa76673764edafa4d91130dc5 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 7 Nov 2015 00:47:07 +0100 Subject: [PATCH 7/9] composer.json: updated version constraints --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index eb893c56b..153ed1fc4 100644 --- a/composer.json +++ b/composer.json @@ -16,13 +16,13 @@ "require": { "php": ">=5.3.1", "ext-pdo": "*", - "nette/caching": "~2.2", + "nette/caching": "^2.2", "nette/utils": "^2.3.5" }, "require-dev": { - "nette/tester": "~1.3", - "nette/di": "~2.3", - "mockery/mockery": "~0.9.1" + "nette/tester": "^1.3", + "nette/di": "^2.3", + "mockery/mockery": "^0.9.1" }, "conflict": { "nette/nette": "<2.2" From 2a3ad68ba3928008a1841c1f9a0f99d7a184aee7 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 24 Nov 2015 15:21:36 +0100 Subject: [PATCH 8/9] __toString handles Throwable errors --- src/Database/Table/ActiveRow.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Database/Table/ActiveRow.php b/src/Database/Table/ActiveRow.php index 1e9a711cd..2f54bb5e7 100644 --- a/src/Database/Table/ActiveRow.php +++ b/src/Database/Table/ActiveRow.php @@ -55,7 +55,10 @@ public function __toString() { try { return (string) $this->getPrimary(); + } catch (\Throwable $e) { } catch (\Exception $e) { + } + if (isset($e)) { if (func_num_args()) { throw $e; } From 1e12005c73411cade4691ca8e1c3b96c1d09a05e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 3 Dec 2015 03:13:51 +0100 Subject: [PATCH 9/9] Selection::insert() fixed delimiting of FQN sequence name like 'aaa.bbb' [Closes #108] --- src/Database/Table/Selection.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Database/Table/Selection.php b/src/Database/Table/Selection.php index 0d9452a07..01c14cbdf 100644 --- a/src/Database/Table/Selection.php +++ b/src/Database/Table/Selection.php @@ -763,11 +763,10 @@ public function insert($data) return $return->getRowCount(); } - $primarySequenceName = $this->getPrimarySequence(); $primaryKey = $this->context->getInsertId( - !empty($primarySequenceName) - ? $this->context->getConnection()->getSupplementalDriver()->delimite($primarySequenceName) - : $primarySequenceName + ($tmp = $this->getPrimarySequence()) + ? implode('.', array_map(array($this->context->getConnection()->getSupplementalDriver(), 'delimite'), explode('.', $tmp))) + : NULL ); if ($primaryKey === FALSE) { unset($this->refCache['referencing'][$this->getGeneralCacheKey()][$this->getSpecificCacheKey()]);