Skip to content

Commit 8294231

Browse files
authored
Update packages, just nette/database (#322)
- nette/database updated from v3.2.0 to v3.2.1 patch See changes: nette/database@v3.2.0...v3.2.1 Release notes: https://github.com/nette/database/releases/tag/v3.2.1 Replace #316
2 parents 6ac01b5 + 7629ef9 commit 8294231

File tree

17 files changed

+390
-37
lines changed

17 files changed

+390
-37
lines changed

site/composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/vendor/composer/autoload_classmap.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@
407407
'Nette\\Database\\Conventions\\AmbiguousReferenceKeyException' => $vendorDir . '/nette/database/src/Database/Conventions/AmbiguousReferenceKeyException.php',
408408
'Nette\\Database\\Conventions\\DiscoveredConventions' => $vendorDir . '/nette/database/src/Database/Conventions/DiscoveredConventions.php',
409409
'Nette\\Database\\Conventions\\StaticConventions' => $vendorDir . '/nette/database/src/Database/Conventions/StaticConventions.php',
410+
'Nette\\Database\\DateTime' => $vendorDir . '/nette/database/src/Database/DateTime.php',
410411
'Nette\\Database\\Driver' => $vendorDir . '/nette/database/src/Database/Driver.php',
411412
'Nette\\Database\\DriverException' => $vendorDir . '/nette/database/src/Database/DriverException.php',
412413
'Nette\\Database\\Drivers\\MsSqlDriver' => $vendorDir . '/nette/database/src/Database/Drivers/MsSqlDriver.php',
@@ -425,6 +426,11 @@
425426
'Nette\\Database\\IStructure' => $vendorDir . '/nette/database/src/Database/IStructure.php',
426427
'Nette\\Database\\ISupplementalDriver' => $vendorDir . '/nette/database/src/compatibility-intf.php',
427428
'Nette\\Database\\NotNullConstraintViolationException' => $vendorDir . '/nette/database/src/Database/exceptions.php',
429+
'Nette\\Database\\Reflection' => $vendorDir . '/nette/database/src/Database/Reflection.php',
430+
'Nette\\Database\\Reflection\\Column' => $vendorDir . '/nette/database/src/Database/Reflection/Column.php',
431+
'Nette\\Database\\Reflection\\ForeignKey' => $vendorDir . '/nette/database/src/Database/Reflection/ForeignKey.php',
432+
'Nette\\Database\\Reflection\\Index' => $vendorDir . '/nette/database/src/Database/Reflection/Index.php',
433+
'Nette\\Database\\Reflection\\Table' => $vendorDir . '/nette/database/src/Database/Reflection/Table.php',
428434
'Nette\\Database\\ResultSet' => $vendorDir . '/nette/database/src/Database/ResultSet.php',
429435
'Nette\\Database\\Row' => $vendorDir . '/nette/database/src/Database/Row.php',
430436
'Nette\\Database\\SqlLiteral' => $vendorDir . '/nette/database/src/Database/SqlLiteral.php',

site/vendor/composer/autoload_static.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ class ComposerStaticInit247de957f14f643f393d210a332dd05b
610610
'Nette\\Database\\Conventions\\AmbiguousReferenceKeyException' => __DIR__ . '/..' . '/nette/database/src/Database/Conventions/AmbiguousReferenceKeyException.php',
611611
'Nette\\Database\\Conventions\\DiscoveredConventions' => __DIR__ . '/..' . '/nette/database/src/Database/Conventions/DiscoveredConventions.php',
612612
'Nette\\Database\\Conventions\\StaticConventions' => __DIR__ . '/..' . '/nette/database/src/Database/Conventions/StaticConventions.php',
613+
'Nette\\Database\\DateTime' => __DIR__ . '/..' . '/nette/database/src/Database/DateTime.php',
613614
'Nette\\Database\\Driver' => __DIR__ . '/..' . '/nette/database/src/Database/Driver.php',
614615
'Nette\\Database\\DriverException' => __DIR__ . '/..' . '/nette/database/src/Database/DriverException.php',
615616
'Nette\\Database\\Drivers\\MsSqlDriver' => __DIR__ . '/..' . '/nette/database/src/Database/Drivers/MsSqlDriver.php',
@@ -628,6 +629,11 @@ class ComposerStaticInit247de957f14f643f393d210a332dd05b
628629
'Nette\\Database\\IStructure' => __DIR__ . '/..' . '/nette/database/src/Database/IStructure.php',
629630
'Nette\\Database\\ISupplementalDriver' => __DIR__ . '/..' . '/nette/database/src/compatibility-intf.php',
630631
'Nette\\Database\\NotNullConstraintViolationException' => __DIR__ . '/..' . '/nette/database/src/Database/exceptions.php',
632+
'Nette\\Database\\Reflection' => __DIR__ . '/..' . '/nette/database/src/Database/Reflection.php',
633+
'Nette\\Database\\Reflection\\Column' => __DIR__ . '/..' . '/nette/database/src/Database/Reflection/Column.php',
634+
'Nette\\Database\\Reflection\\ForeignKey' => __DIR__ . '/..' . '/nette/database/src/Database/Reflection/ForeignKey.php',
635+
'Nette\\Database\\Reflection\\Index' => __DIR__ . '/..' . '/nette/database/src/Database/Reflection/Index.php',
636+
'Nette\\Database\\Reflection\\Table' => __DIR__ . '/..' . '/nette/database/src/Database/Reflection/Table.php',
631637
'Nette\\Database\\ResultSet' => __DIR__ . '/..' . '/nette/database/src/Database/ResultSet.php',
632638
'Nette\\Database\\Row' => __DIR__ . '/..' . '/nette/database/src/Database/Row.php',
633639
'Nette\\Database\\SqlLiteral' => __DIR__ . '/..' . '/nette/database/src/Database/SqlLiteral.php',

site/vendor/composer/installed.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/vendor/composer/installed.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@
137137
'dev_requirement' => false,
138138
),
139139
'nette/database' => array(
140-
'pretty_version' => 'v3.2.0',
141-
'version' => '3.2.0.0',
142-
'reference' => '39f98a8c5a0e67d30424ca199e0630b678bcecd5',
140+
'pretty_version' => 'v3.2.1',
141+
'version' => '3.2.1.0',
142+
'reference' => '1d9e2866d711ce16a94bd9c98abaf8378269cef6',
143143
'type' => 'library',
144144
'install_path' => __DIR__ . '/../nette/database',
145145
'aliases' => array(),

site/vendor/nette/database/src/Database/Connection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public function __construct(
4343
private readonly ?string $password = null,
4444
private readonly array $options = [],
4545
) {
46+
if (!empty($options['newDateTime'])) {
47+
$this->rowNormalizer = fn($row, $resultSet) => Helpers::normalizeRow($row, $resultSet, DateTime::class);
48+
}
4649
if (empty($options['lazy'])) {
4750
$this->connect();
4851
}
@@ -113,6 +116,12 @@ public function getSupplementalDriver(): Driver
113116
}
114117

115118

119+
public function getReflection(): Reflection
120+
{
121+
return new Reflection($this->getDriver());
122+
}
123+
124+
116125
public function setRowNormalizer(?callable $normalizer): static
117126
{
118127
$this->rowNormalizer = $normalizer;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Nette Framework (https://nette.org)
5+
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Nette\Database;
11+
12+
13+
/**
14+
* Date Time.
15+
*/
16+
final class DateTime extends \DateTimeImmutable implements \JsonSerializable
17+
{
18+
/**
19+
* Returns JSON representation in ISO 8601 (used by JavaScript).
20+
*/
21+
public function jsonSerialize(): string
22+
{
23+
return $this->format('c');
24+
}
25+
26+
27+
/**
28+
* Returns the date and time in the format 'Y-m-d H:i:s.u'.
29+
*/
30+
public function __toString(): string
31+
{
32+
return $this->format('Y-m-d H:i:s.u');
33+
}
34+
}

site/vendor/nette/database/src/Database/Driver.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,21 @@ function applyLimit(string &$sql, ?int $limit, ?int $offset): void;
6060

6161
/********************* reflection ****************d*g**/
6262

63-
/**
64-
* Returns list of tables as tuples [(string) name, (bool) view, [(string) fullName]]
65-
*/
63+
/** @return list<array{name: string, fullName: string, view: bool}> */
6664
function getTables(): array;
6765

68-
/**
69-
* Returns metadata for all columns in a table.
70-
* As tuples [(string) name, (string) table, (string) nativetype, (int) size, (bool) nullable, (mixed) default, (bool) autoincrement, (bool) primary, (array) vendor]]
71-
*/
66+
/** @return list<array{name: string, table: string, nativetype: string, size: int|null, nullable: bool, default: mixed, autoincrement: bool, primary: bool, vendor: array}> */
7267
function getColumns(string $table): array;
7368

74-
/**
75-
* Returns metadata for all indexes in a table.
76-
* As tuples [(string) name, (string[]) columns, (bool) unique, (bool) primary]
77-
*/
69+
/** @return list<array{name: string, columns: list<string>, unique: bool, primary: bool}> */
7870
function getIndexes(string $table): array;
7971

80-
/**
81-
* Returns metadata for all foreign keys in a table.
82-
* As tuples [(string) name, (string) local, (string) table, (string) foreign]
83-
*/
72+
/** @return list<array{name: string, local: string, table: string, foreign: string}> */
8473
function getForeignKeys(string $table): array;
8574

8675
/**
8776
* Returns associative array of detected types (IStructure::FIELD_*) in result set.
77+
* @return array<string, string>
8878
*/
8979
function getColumnTypes(\PDOStatement $statement): array;
9080

site/vendor/nette/database/src/Database/Drivers/SqliteDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function getColumnTypes(\PDOStatement $statement): array
228228
for ($col = 0; $col < $count; $col++) {
229229
$meta = $statement->getColumnMeta($col);
230230
if (isset($meta['sqlite:decl_type'])) {
231-
$types[$meta['name']] = in_array($meta['sqlite:decl_type'], ['DATE', 'DATETIME'], strict: true)
231+
$types[$meta['name']] = $this->fmtDateTime === 'U' && in_array($meta['sqlite:decl_type'], ['DATE', 'DATETIME'], strict: true)
232232
? Nette\Database\IStructure::FIELD_UNIX_TIMESTAMP
233233
: Nette\Database\Helpers::detectType($meta['sqlite:decl_type']);
234234
} elseif (isset($meta['native_type'])) {

site/vendor/nette/database/src/Database/Drivers/SqlsrvDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function getForeignKeys(string $table): array
198198
fk.name AS name,
199199
cl.name AS local,
200200
tf.name AS [table],
201-
cf.name AS [column]
201+
cf.name AS [foreign]
202202
FROM
203203
sys.foreign_keys fk
204204
JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id

site/vendor/nette/database/src/Database/Helpers.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ public static function detectType(string $type): string
202202

203203

204204
/** @internal */
205-
public static function normalizeRow(array $row, ResultSet $resultSet): array
205+
public static function normalizeRow(
206+
array $row,
207+
ResultSet $resultSet,
208+
$dateTimeClass = Nette\Utils\DateTime::class,
209+
): array
206210
{
207211
foreach ($resultSet->getColumnTypes() as $key => $type) {
208212
$value = $row[$key];
@@ -224,10 +228,10 @@ public static function normalizeRow(array $row, ResultSet $resultSet): array
224228
} elseif ($type === IStructure::FIELD_DATETIME || $type === IStructure::FIELD_DATE) {
225229
$row[$key] = str_starts_with($value, '0000-00')
226230
? null
227-
: new Nette\Utils\DateTime($value);
231+
: new $dateTimeClass($value);
228232

229233
} elseif ($type === IStructure::FIELD_TIME) {
230-
$row[$key] = (new Nette\Utils\DateTime($value))->setDate(1, 1, 1);
234+
$row[$key] = (new $dateTimeClass($value))->setDate(1, 1, 1);
231235

232236
} elseif ($type === IStructure::FIELD_TIME_INTERVAL) {
233237
preg_match('#^(-?)(\d+)\D(\d+)\D(\d+)(\.\d+)?$#D', $value, $m);
@@ -236,7 +240,7 @@ public static function normalizeRow(array $row, ResultSet $resultSet): array
236240
$row[$key]->invert = (int) (bool) $m[1];
237241

238242
} elseif ($type === IStructure::FIELD_UNIX_TIMESTAMP) {
239-
$row[$key] = Nette\Utils\DateTime::from($value);
243+
$row[$key] = (new $dateTimeClass)->setTimestamp($value);
240244
}
241245
}
242246

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Nette Framework (https://nette.org)
5+
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Nette\Database;
11+
12+
use Nette\Database\Reflection\Table;
13+
14+
15+
final class Reflection
16+
{
17+
/** @var array<string, Table> */
18+
public readonly array $tables;
19+
private ?string $schema;
20+
21+
22+
public function __construct(
23+
private readonly Driver $driver,
24+
) {
25+
$this->schema = $this->driver->isSupported(Driver::SUPPORT_SCHEMA) ? 'public' : null;
26+
unset($this->tables);
27+
}
28+
29+
30+
/** @return Table[] */
31+
public function getTables(): array
32+
{
33+
return array_values($this->tables);
34+
}
35+
36+
37+
public function getTable(string $name): Table
38+
{
39+
$name = $this->getFullName($name);
40+
return $this->tables[$name] ?? throw new \InvalidArgumentException("Table '$name' not found.");
41+
}
42+
43+
44+
public function hasTable(string $name): bool
45+
{
46+
$name = $this->getFullName($name);
47+
return isset($this->tables[$name]);
48+
}
49+
50+
51+
private function getFullName(string $name): string
52+
{
53+
return $this->schema !== null && !str_contains($name, '.')
54+
? $this->schema . '.' . $name
55+
: $name;
56+
}
57+
58+
59+
/** @internal */
60+
public function getDriver(): Driver
61+
{
62+
return $this->driver;
63+
}
64+
65+
66+
private function initTables(): void
67+
{
68+
$res = [];
69+
foreach ($this->driver->getTables() as $row) {
70+
$res[$row['fullName'] ?? $row['name']] = new Table($this, $row['name'], $row['view'], $row['fullName'] ?? null);
71+
}
72+
$this->tables = $res;
73+
}
74+
75+
76+
public function __get($name): mixed
77+
{
78+
match ($name) {
79+
'tables' => $this->initTables(),
80+
default => throw new \LogicException("Undefined property '$name'."),
81+
};
82+
return $this->$name;
83+
}
84+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Nette Framework (https://nette.org)
5+
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Nette\Database\Reflection;
11+
12+
13+
/**
14+
* Column reflection.
15+
*/
16+
final class Column
17+
{
18+
/** @internal */
19+
public function __construct(
20+
public readonly string $name,
21+
public readonly ?Table $table = null,
22+
public readonly string $nativeType = '',
23+
public readonly ?int $size = null,
24+
public readonly bool $nullable = false,
25+
public readonly mixed $default = null,
26+
public readonly bool $autoIncrement = false,
27+
public readonly bool $primary = false,
28+
public readonly array $vendor = [],
29+
) {
30+
}
31+
32+
33+
public function __toString(): string
34+
{
35+
return $this->name;
36+
}
37+
}

0 commit comments

Comments
 (0)