Skip to content

Commit 3cc2757

Browse files
github-actionsroxblnfk
authored andcommitted
feat: add public Driver::clearCache() method
(cherry picked from commit a43105e)
1 parent d55b36f commit 3cc2757

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

src/Driver/Driver.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public function withoutCache(): static
110110
return $driver;
111111
}
112112

113+
public function clearCache(): void
114+
{
115+
$this->queryCache = [];
116+
}
117+
113118
/**
114119
* Get driver source database or file name.
115120
*
@@ -132,7 +137,7 @@ public function getTimezone(): \DateTimeZone
132137
public function getSchemaHandler(): HandlerInterface
133138
{
134139
// do not allow to carry prepared statements between schema changes
135-
$this->queryCache = [];
140+
$this->clearCache();
136141

137142
return $this->schemaHandler;
138143
}
@@ -171,7 +176,7 @@ public function isConnected(): bool
171176
public function disconnect(): void
172177
{
173178
try {
174-
$this->queryCache = [];
179+
$this->clearCache();
175180
$this->pdo = null;
176181
} catch (\Throwable $e) {
177182
// disconnect error

src/Driver/Jsoner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function toJson(mixed $value, bool $encode = true, bool $validate
3232

3333
$result = (string) $value;
3434

35-
if ($validate && !json_validate($result)) {
35+
if ($validate && !\json_validate($result)) {
3636
throw new BuilderException('Invalid JSON value.');
3737
}
3838

src/Schema/AbstractColumn.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,15 @@ public function isReadonlySchema(): bool
623623
return $this->getAttributes()['readonlySchema'] ?? false;
624624
}
625625

626+
/**
627+
* Get column comment.
628+
* An empty string will be returned if the feature is not supported by the driver.
629+
*/
630+
public function getComment(): string
631+
{
632+
return '';
633+
}
634+
626635
/**
627636
* Shortcut for AbstractColumn->type() method.
628637
*
@@ -785,13 +794,4 @@ protected function formatDatetime(
785794
default => $value,
786795
};
787796
}
788-
789-
/**
790-
* Get column comment.
791-
* An empty string will be returned if the feature is not supported by the driver.
792-
*/
793-
public function getComment(): string
794-
{
795-
return '';
796-
}
797797
}

tests/Database/Functional/Driver/Common/Schema/CommentTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Cycle\Database\Tests\Functional\Driver\Common\Schema;
66

77
// phpcs:ignore
8-
use Cycle\Database\ColumnInterface;
98
use Cycle\Database\Tests\Functional\Driver\Common\BaseTest;
109
use Cycle\Database\Tests\Utils\DontGenerateAttribute;
1110

tests/generate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use Cycle\Database\Tests\Utils\DontGenerateAttribute;
66
use Spiral\Tokenizer;
77

8-
error_reporting(E_ALL | E_STRICT);
9-
ini_set('display_errors', '1');
8+
\error_reporting(E_ALL | E_STRICT);
9+
\ini_set('display_errors', '1');
1010

1111
//Composer
12-
require_once dirname(__DIR__) . '/vendor/autoload.php';
12+
require_once \dirname(__DIR__) . '/vendor/autoload.php';
1313

1414
$tokenizer = new Tokenizer\Tokenizer(new Tokenizer\Config\TokenizerConfig([
1515
'directories' => [__DIR__ . '/Database/Functional/Driver/Common'],
@@ -67,7 +67,7 @@
6767
\str_replace('\\', '/', $class->getFileName()),
6868
);
6969

70-
$path = ltrim($path, '/');
70+
$path = \ltrim($path, '/');
7171

7272
foreach ($databases as $driver => $details) {
7373
$filename = $details['directory'] . $path;

0 commit comments

Comments
 (0)