nette/database

ActiveRow: __isset 2.4.6 update masive increase DB information_schema queries count

spagr opened this issue · 2 comments

spagr commented

Version: 2.4.6

Bug Description

ActiveRow: __isset generate many queries from db information_schema if checked row doesn´t exist.
Attached screenshot shows the difference, left side browser with NDB 2.4.5, right side NDB 2.4.6, same code.

Use case in component with two data source handling :

// Cart Items handler
/** @var ActiveRow $product */
if (isset($product->sessid)) { // Cart table structure
  $quantity = $product->quantity;
  $product = $product->ref('product');
}

Expected Behavior

In version 2.4.5 (left browser) is expected behavior

image

dg commented

related to #196 and @miranovy

EdaCZ commented

@spagr Could you please provide full working example?

I tried to simulate it, but everything seems to be working fine.

For example, when I run test tests/Database/Table/bugs/ActiveRow.__isset.phpt and add another two assertions like this:

test(function () use ($context) {
	$row = $context->table('book')->get(2);
	Assert::same('Jakub Vrana', $row->author->name);
	Assert::true(isset($row->author->name));
	Assert::false(isset($row->author->test));
	Assert::false(isset($row->test));
});

For example function MySqlDriver.getForeignKeys and others are called only once for each table. And the whole structure is not reloaded.

There must be something special in your use case...