File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * Test: bug 187
5+ * @dataProvider? ../../databases.ini mysql
6+ */
7+
8+ declare (strict_types=1 );
9+
10+ use Nette \Database \Table \ActiveRow ;
11+ use Tester \Assert ;
12+
13+ require __DIR__ . '/../../connect.inc.php ' ;
14+
15+ Nette \Database \Helpers::loadFromFile ($ connection , __DIR__ . "/../../files/ {$ driverName }-nette_test5.sql " );
16+
17+ foreach ([true , false ] as $ published ) {
18+ if ($ published ) {
19+ $ where = '(:PhotoNonPublic.number IS NULL) ' ;
20+ } else {
21+ $ where = '(:PhotoNonPublic.number IS NOT NULL) ' ;
22+ }
23+
24+ $ result = $ context ->table ('Photo ' )->where ($ where );
25+
26+ foreach ($ result as $ photoRow ) {
27+ /** @var ActiveRow $photoRow */
28+ $ related = $ photoRow ->related ('PhotoNonPublic ' );
29+
30+ if ($ related ->count () != 0 ) {
31+ $ related ->fetch ()->toArray ();
32+ }
33+ }
34+
35+ // destructing -> saveCacheState
36+ $ result ->__destruct ();
37+ $ related ->__destruct ();
38+ }
39+
40+ Assert::true (true );
Original file line number Diff line number Diff line change 1+ DROP DATABASE IF EXISTS nette_test;
2+ CREATE DATABASE nette_test ;
3+ USE nette_test;
4+
5+ CREATE TABLE `Photo ` (
6+ ` number` int (4 ) unsigned NOT NULL AUTO_INCREMENT,
7+ PRIMARY KEY (` number` )
8+ ) ENGINE= InnoDB DEFAULT CHARSET= utf8mb4 COLLATE= utf8mb4_czech_ci;
9+
10+ INSERT INTO ` Photo` (` number` ) VALUES (1 ), (2 ), (3 );
11+
12+ CREATE TABLE `PhotoNonPublic ` (
13+ ` number` int (4 ) unsigned NOT NULL AUTO_INCREMENT,
14+ PRIMARY KEY (` number` ),
15+ CONSTRAINT ` PhotoNonPublic_ibfk_1` FOREIGN KEY (` number` ) REFERENCES ` Photo` (` number` ) ON DELETE CASCADE ON UPDATE CASCADE
16+ ) ENGINE= InnoDB DEFAULT CHARSET= utf8mb4 COLLATE= utf8mb4_czech_ci;
17+
18+ INSERT INTO ` PhotoNonPublic` (` number` ) VALUES (2 ), (3 );
You can’t perform that action at this time.
0 commit comments