-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
Support mapping time series collections #2687
Changes from 1 commit
7c61793
a92a370
13d01a5
1a15a99
b609364
bfaa88d
8655f57
945652a
73d5787
784bd64
61c0383
14f96e7
3359232
0420682
db758a3
4e8c52c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -987,15 +987,15 @@ public function testDefaultTimeSeriesMapping(): void | |
{ | ||
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class); | ||
|
||
self::assertFalse($metadata->isTimeSeries); | ||
self::assertNull($metadata->timeSeriesOptions); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a meaningful test? I'm also a bit confused that these tests reference a TimeSeriesDocument class defined in the same file, while you also have a separate TimeSeriesDocument class defined in its own file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it isn't. This was left over from refactoring out the As for the classes being used, there are lots of classes defined in this test file, I believe to avoid issues where changing the mapping of one class to test new functionality affects related tests. I've followed this for consistency, but we'd probably do well to refactor this in the near future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aye. Ideally, I suppose these tests would be split into their own files or define anonymous classes within the test itself. I understand there's so much prior art that it'd be a chore to clean everything up at once, though. |
||
} | ||
|
||
public function testTimeSeriesMappingOnlyWithTimeField(): void | ||
{ | ||
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class); | ||
$metadata->markAsTimeSeries(new ODM\TimeSeries('time')); | ||
|
||
self::assertTrue($metadata->isTimeSeries); | ||
self::assertNotNull($metadata->timeSeriesOptions); | ||
self::assertSame('time', $metadata->timeSeriesOptions->timeField); | ||
} | ||
|
||
|
@@ -1012,7 +1012,7 @@ public function testTimeSeriesMappingWithMetadataField(): void | |
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class); | ||
$metadata->markAsTimeSeries(new ODM\TimeSeries('time', 'metadata')); | ||
|
||
self::assertTrue($metadata->isTimeSeries); | ||
self::assertNotNull($metadata->timeSeriesOptions); | ||
self::assertSame('metadata', $metadata->timeSeriesOptions->metaField); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use
readonly
here? AFAIK, that would just mean thatmarkAsTimeSeries()
, which sets this, can only be called once. Perhaps that's something to defer until later, as I expect it could be done across the board for all "READ ONLY" metadata properties.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and no. What we'd want here is asymetric visibility, where changing the property is only done through accessors (such as
markAsTimeSeries
) that can incorporate checks, while reading is always allowed.readonly
in PHP actually meanswrite-once
, meaning that one wouldn't be able to override the time series configuration (e.g. to change granularity) when using inheritance mapping.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly
= you can change the assigned object properties. You cannot change the reference to the object. And I think - I'm not sure though - that you can only make assignment in the constructor 🤔 ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought something like that as well, but then it seems we are wrong, and the property can be initialised after the constructor, but only from within the class scope: https://3v4l.org/cV5QL
For our case, this still wouldn't work however, as we can't assign a default value to a readonly property but have to leave it uninitialised, which means that accessing the property always needs to be guarded by an
isset
check :(