-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
17 changed files
with
390 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nette Framework (https://nette.org) | ||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nette\Database; | ||
|
||
|
||
/** | ||
* Date Time. | ||
*/ | ||
final class DateTime extends \DateTimeImmutable implements \JsonSerializable | ||
{ | ||
/** | ||
* Returns JSON representation in ISO 8601 (used by JavaScript). | ||
*/ | ||
public function jsonSerialize(): string | ||
{ | ||
return $this->format('c'); | ||
} | ||
|
||
|
||
/** | ||
* Returns the date and time in the format 'Y-m-d H:i:s.u'. | ||
*/ | ||
public function __toString(): string | ||
{ | ||
return $this->format('Y-m-d H:i:s.u'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nette Framework (https://nette.org) | ||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nette\Database; | ||
|
||
use Nette\Database\Reflection\Table; | ||
|
||
|
||
final class Reflection | ||
{ | ||
/** @var array<string, Table> */ | ||
public readonly array $tables; | ||
private ?string $schema; | ||
|
||
|
||
public function __construct( | ||
private readonly Driver $driver, | ||
) { | ||
$this->schema = $this->driver->isSupported(Driver::SUPPORT_SCHEMA) ? 'public' : null; | ||
unset($this->tables); | ||
} | ||
|
||
|
||
/** @return Table[] */ | ||
public function getTables(): array | ||
{ | ||
return array_values($this->tables); | ||
} | ||
|
||
|
||
public function getTable(string $name): Table | ||
{ | ||
$name = $this->getFullName($name); | ||
return $this->tables[$name] ?? throw new \InvalidArgumentException("Table '$name' not found."); | ||
} | ||
|
||
|
||
public function hasTable(string $name): bool | ||
{ | ||
$name = $this->getFullName($name); | ||
return isset($this->tables[$name]); | ||
} | ||
|
||
|
||
private function getFullName(string $name): string | ||
{ | ||
return $this->schema !== null && !str_contains($name, '.') | ||
? $this->schema . '.' . $name | ||
: $name; | ||
} | ||
|
||
|
||
/** @internal */ | ||
public function getDriver(): Driver | ||
{ | ||
return $this->driver; | ||
} | ||
|
||
|
||
private function initTables(): void | ||
{ | ||
$res = []; | ||
foreach ($this->driver->getTables() as $row) { | ||
$res[$row['fullName'] ?? $row['name']] = new Table($this, $row['name'], $row['view'], $row['fullName'] ?? null); | ||
} | ||
$this->tables = $res; | ||
} | ||
|
||
|
||
public function __get($name): mixed | ||
{ | ||
match ($name) { | ||
'tables' => $this->initTables(), | ||
default => throw new \LogicException("Undefined property '$name'."), | ||
}; | ||
return $this->$name; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
site/vendor/nette/database/src/Database/Reflection/Column.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nette Framework (https://nette.org) | ||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nette\Database\Reflection; | ||
|
||
|
||
/** | ||
* Column reflection. | ||
*/ | ||
final class Column | ||
{ | ||
/** @internal */ | ||
public function __construct( | ||
public readonly string $name, | ||
public readonly ?Table $table = null, | ||
public readonly string $nativeType = '', | ||
public readonly ?int $size = null, | ||
public readonly bool $nullable = false, | ||
public readonly mixed $default = null, | ||
public readonly bool $autoIncrement = false, | ||
public readonly bool $primary = false, | ||
public readonly array $vendor = [], | ||
) { | ||
} | ||
|
||
|
||
public function __toString(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
Oops, something went wrong.