Skip to content

PHPLIB-1634: Support encoding DateTimeInterface instances in aggregation builder#1610

Merged
alcaeus merged 7 commits intomongodb:v1.xfrom
alcaeus:phplib-1634-accept-datetime-instances
Feb 26, 2025
Merged

PHPLIB-1634: Support encoding DateTimeInterface instances in aggregation builder#1610
alcaeus merged 7 commits intomongodb:v1.xfrom
alcaeus:phplib-1634-accept-datetime-instances

Conversation

@alcaeus
Copy link
Copy Markdown
Member

@alcaeus alcaeus commented Feb 26, 2025

PHPLIB-1634

With a new encoder, we only need to add DateTimeInterface to be accepted for the date type, as well as any. In addition, the stage factory needs manual updating, as well as some return types in the expression encoders.

@alcaeus alcaeus requested a review from GromNaN February 26, 2025 08:25
@alcaeus alcaeus requested a review from a team as a code owner February 26, 2025 08:25
* @param QueryInterface|FieldQueryInterface|Type|stdClass|array<array-key, mixed>|bool|float|int|string|DateTimeInterface|null ...$queries The query predicates to match
*/
public static function match(QueryInterface|FieldQueryInterface|Type|stdClass|array|bool|float|int|string|null ...$queries): MatchStage
public static function match(QueryInterface|FieldQueryInterface|Type|stdClass|array|bool|float|int|string|DateTimeInterface|null ...$queries): MatchStage
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sent me on a short chase as I couldn't figure out why the match stage itself wasn't updated automatically. I forgot why we had to manually write this factory, but just leaving this here as a reminder for myself for the next time I have to make changes to the types accepted for $match.

@alcaeus alcaeus force-pushed the phplib-1634-accept-datetime-instances branch from ca19c38 to 71f7f5d Compare February 26, 2025 08:28
@alcaeus alcaeus enabled auto-merge (squash) February 26, 2025 09:10
@alcaeus alcaeus merged commit dd77c8d into mongodb:v1.x Feb 26, 2025
29 of 31 checks passed
This was referenced Feb 26, 2025
@alcaeus alcaeus deleted the phplib-1634-accept-datetime-instances branch February 26, 2025 11:41
GromNaN pushed a commit to GromNaN/mongo-php-library that referenced this pull request Feb 23, 2026
…ion builder (mongodb#1610)

* PHPLIB-1634: Support encoding DateTimeInterface instances in aggregation builder

* Sort types correctly

* Accept DateTimeInterface for query objects

* Add missing psalm annotation

* Use BSON Type class instead of UTCDateTime

* Update psalm baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants