|
22 | 22 | namespace TheCodingMachine\TDBM;
|
23 | 23 |
|
24 | 24 | use Doctrine\Common\Cache\ArrayCache;
|
| 25 | +use Doctrine\DBAL\Driver\Mysqli\MysqliConnection; |
25 | 26 | use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
26 | 27 | use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
27 | 28 | use Doctrine\DBAL\Platforms\MySQL57Platform;
|
@@ -2208,4 +2209,40 @@ public function testFindFromRawSQLOnInheritance(): void
|
2208 | 2209 | $this->assertNotNull($objects->first());
|
2209 | 2210 | $this->assertEquals(6, $objects->count());
|
2210 | 2211 | }
|
| 2212 | + |
| 2213 | + public function testMysqlStatementCount(): void |
| 2214 | + { |
| 2215 | + if (! $this->tdbmService->getConnection() instanceof MysqliConnection) { |
| 2216 | + $this->markTestSkipped('This test only applies for MySQLi driver.'); |
| 2217 | + } |
| 2218 | + try { |
| 2219 | + $this->tdbmService->getConnection()->exec('set global max_prepared_stmt_count = 2;'); |
| 2220 | + |
| 2221 | + $objectBaseDao = new BaseObjectDao($this->tdbmService); |
| 2222 | + $objectInheritedDao = new InheritedObjectDao($this->tdbmService); |
| 2223 | + |
| 2224 | + $objectBase = new BaseObjectBean('label-1'); |
| 2225 | + $objectBaseDao->save($objectBase); |
| 2226 | + $objectInherited = new InheritedObjectBean($objectBase); |
| 2227 | + $objectInheritedDao->save($objectInherited); |
| 2228 | + |
| 2229 | + $objectBase = new BaseObjectBean('label-2'); |
| 2230 | + $objectBaseDao->save($objectBase); |
| 2231 | + $objectInherited = new InheritedObjectBean($objectBase); |
| 2232 | + $objectInheritedDao->save($objectInherited); |
| 2233 | + |
| 2234 | + $objectBase = new BaseObjectBean('label-3'); |
| 2235 | + $objectBaseDao->save($objectBase); |
| 2236 | + $objectInherited = new InheritedObjectBean($objectBase); |
| 2237 | + $objectInheritedDao->save($objectInherited); |
| 2238 | + |
| 2239 | + $objects = $objectBaseDao->findAll(); |
| 2240 | + $this->assertGreaterThanOrEqual(3, $objects->count()); |
| 2241 | + foreach ($objects->take(0, 1) as $objectBean) { $objectBean->getInheritedObject()->getId(); } |
| 2242 | + foreach ($objects->take(1, 2) as $objectBean) { $objectBean->getInheritedObject()->getId(); } |
| 2243 | + foreach ($objects->take(2, 3) as $objectBean) { $objectBean->getInheritedObject()->getId(); } |
| 2244 | + } finally { |
| 2245 | + $this->tdbmService->getConnection()->exec('set global max_prepared_stmt_count = 16382;'); |
| 2246 | + } |
| 2247 | + } |
2211 | 2248 | }
|
0 commit comments