-
Notifications
You must be signed in to change notification settings - Fork 0
Sync Laravel updates: #58337 → #58564 #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
8ffa0ec
Complete vector casting and MariaDB similarity queries
binaryfire 86efebc
Use direct Stringable construction internally
binaryfire 9d3294b
Preserve health-page CSS when Blade theme directives exist
binaryfire 7e9b603
Fix decimal number summaries and complete Number typing and coverage
binaryfire a87a661
Constrain model identifier collection class annotations
binaryfire dc7a53a
Preserve raw queue payloads and index failed-job counts
binaryfire bbef3fc
Remove unused host port publications from container CI jobs
binaryfire 7ec1be3
Preserve non-error HTTP responses when retrying asynchronously
binaryfire 4ba0cfa
Complete upstream fractional translation selector coverage
binaryfire a842eff
Document conditional CORS middleware bypass
binaryfire 8468c7b
Explain deferred queue callback ownership beside the lifecycle listener
binaryfire e5e0842
Verify parallel compiled-view cleanup through its real lifecycle
binaryfire 3279294
Port collection merge union type assertions
binaryfire f7645d6
Document queue startup, pop and exception-release events
binaryfire 74a0928
Complete HTTP response JSON flag types
binaryfire d90bc91
Document HTTP response decoding flags and defaults
binaryfire 184d7a4
Preserve explicit handlers when deferred dispatch is disabled
binaryfire d9ac030
Reject malformed CSRF tokens through the existing validator
binaryfire b5166be
Complete request-forgery exclusion coverage
binaryfire 8b71c51
Document the supported CSRF middleware replacements
binaryfire 7e6a6dc
Fix raw expression selection and preserve authorization attributes
binaryfire 591c9dd
Document explicit expression aliases and policy selections
binaryfire 94eb720
Complete notification failure event regression coverage
binaryfire b56155e
Preserve character boundaries and encodings in string helpers
binaryfire e5af2ab
Document fluent resource collection key preservation
binaryfire 86d9ed8
Preserve morph-map opt-in and integer model aliases
binaryfire c6f8467
Honor inherited relation exclusion when serializing jobs
binaryfire a5055cc
Document queued relationship restoration and morph aliases
binaryfire 03a89f7
Release owned database lock rows after expiration
binaryfire f3defb7
Preserve enum defaults in request input types
binaryfire 23cc5ad
Document and test multiple MySQL index hints
binaryfire 162ba36
Verify unique listener lock release with real lock state
binaryfire 53d8305
Correct unique listener scope and queue example imports
binaryfire 9923311
Complete associative eager-load key coverage and documentation
binaryfire 92a321c
Complete typed cache getter coverage and documentation
binaryfire a660254
Align the column starting-value description with upstream
binaryfire 5e80d6b
Format summarized zero using the requested locale
binaryfire f83605d
Compare vector casts at database storage precision
binaryfire 30073bc
Complete enum notification channel resolution coverage
binaryfire 1d40ae0
Explain the queue identifier storage regression
binaryfire 0598d24
Select Arabic-Indic digits explicitly in number tests
binaryfire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,116 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Database\Eloquent\Casts; | ||
|
|
||
| use Hypervel\Contracts\Database\Eloquent\Castable; | ||
| use Hypervel\Contracts\Database\Eloquent\CastsAttributes; | ||
| use Hypervel\Contracts\Database\Eloquent\ComparesCastableAttributes; | ||
| use Hypervel\Contracts\Database\Query\Expression as ExpressionContract; | ||
| use Hypervel\Contracts\Support\Arrayable; | ||
| use Hypervel\Database\Eloquent\Model; | ||
| use Hypervel\Database\Query\Expression; | ||
| use Hypervel\Database\Query\Grammars\MariaDbGrammar; | ||
| use Hypervel\Support\Str; | ||
| use InvalidArgumentException; | ||
| use JsonException; | ||
|
|
||
| class AsVector implements Castable | ||
| { | ||
| /** | ||
| * Get the caster class to use when casting from / to this cast target. | ||
| * | ||
| * @return CastsAttributes<array<int, float>, array<int, float>|Arrayable<int, float>> | ||
| */ | ||
| public static function castUsing(array $arguments): CastsAttributes | ||
| { | ||
| return new class implements CastsAttributes, ComparesCastableAttributes { | ||
| // Eloquent otherwise caches an assigned Arrayable and returns it instead of a float array. | ||
| public bool $withoutObjectCaching = true; | ||
|
|
||
| /** | ||
| * Transform the attribute from the underlying model values. | ||
| * | ||
| * @return null|array<int, float> | ||
| * | ||
| * @throws JsonException | ||
| */ | ||
| public function get(Model $model, string $key, mixed $value, array $attributes): ?array | ||
| { | ||
| if ($value === null) { | ||
| return null; | ||
| } | ||
|
|
||
| $grammar = $model->getConnection()->getQueryGrammar(); | ||
|
|
||
| // Decode a MariaDB expression assigned to the model before it is persisted... | ||
| if ($value instanceof ExpressionContract) { | ||
| $value = Str::between($value->getValue($grammar), "('", "')"); | ||
|
|
||
| return array_map(floatval(...), json_decode($value, true, flags: JSON_THROW_ON_ERROR)); | ||
| } | ||
|
|
||
| // MariaDB vector columns return little-endian float32 bytes... | ||
| if ($grammar instanceof MariaDbGrammar) { | ||
| return array_values(unpack('g*', $value)); | ||
| } | ||
|
|
||
| // PostgreSQL (pgvector) returns JSON text... | ||
| return array_map(floatval(...), json_decode($value, true, flags: JSON_THROW_ON_ERROR)); | ||
| } | ||
|
|
||
| /** | ||
| * Transform the attribute to its underlying model values. | ||
| * | ||
| * @return array<string, null|Expression|string> | ||
| * | ||
| * @throws InvalidArgumentException | ||
| * @throws JsonException | ||
| */ | ||
| public function set(Model $model, string $key, mixed $value, array $attributes): array | ||
| { | ||
| if ($value === null) { | ||
| return [$key => null]; | ||
| } | ||
|
|
||
| if ($value instanceof Arrayable) { | ||
| $value = $value->toArray(); | ||
| } | ||
|
|
||
| if (! is_array($value)) { | ||
| throw new InvalidArgumentException( | ||
| sprintf('The [%s] attribute must be an array of floats or an Arrayable instance.', $key) | ||
| ); | ||
| } | ||
|
|
||
| $vector = json_encode(array_values(array_map(floatval(...), $value)), JSON_THROW_ON_ERROR); | ||
|
|
||
| // MariaDB requires vectors to be converted from JSON text server-side... | ||
| return [ | ||
| $key => $model->getConnection()->getQueryGrammar() instanceof MariaDbGrammar | ||
| ? new Expression("vec_fromtext('{$vector}')") | ||
| : $vector, | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Determine if the given values are equal. | ||
| * | ||
| * @throws JsonException | ||
| */ | ||
| public function compare(Model $model, string $key, mixed $firstValue, mixed $secondValue): bool | ||
| { | ||
| $first = $this->get($model, $key, $firstValue, []); | ||
| $second = $this->get($model, $key, $secondValue, []); | ||
|
|
||
| if ($first === null || $second === null) { | ||
| return $first === $second; | ||
| } | ||
|
|
||
| // Both supported engines store 32-bit floats, so compare the values as they are stored. | ||
| return pack('g*', ...$first) === pack('g*', ...$second); | ||
| } | ||
| }; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.