-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
GlobalID may have an issue with historical objects fetched via as_of
#192
Comments
the 2nd one does not point to historical record |
Yes, let me try to clarify Vendor.last.history.last.model_name.name
"Vendor::History"
Vendor.history.last.to_gid
#<GlobalID:0x00007fd3ba2ed9f8 @uri=#<URI::GID gid://app/Vendor::History/123>>
Vendor.as_of(1.day.ago).last.model_name.name
"Vendor"
Vendor.as_of(1.day.ago).last.to_gid
#<GlobalID:0x00007fd3bac4ba18 @uri=#<URI::GID gid://app/Vendor/1>> The second one is indeed a class of "Vendor" because it is how chronomodel works. However, we can't support GlobalID properly because fetching |
I understood that, what I mean is that |
Correct. And it is correct to return a I do not know GlobalID internals, so I will take note of this and implement a workaround for our specific use case |
I do not think it's correct, there should be a convention that when you ask a historical query always get a historical record, even if it's the most recent one, while non-historical queries return normal models |
I think that Chronomodel itself is not correct, but in the specific case, unfortunately this behavior is correct. If I'm getting a Example: if the Vendor is returned as its historical reference with an instance of
because everything is expecting an instance of Vendor class However, here it is a prototype workaround: GlobalID::Locator.use :chronolocator do |gid|
collection = gid.model_class
collection = collection.as_of(Time.parse.utc(gid.params[:as_of])) if gid.params[:as_of] # safe parse here
collection.find(gid.model_id)
end Then: vendor.to_gid(app: 'chronolocator', as_of: vendor.as_of_time&.iso8601) # chronolocator should reflect app name I don't want to provide a custom locator for chronomodel and override |
It is not clear to me what is the correct behavior, but it is worth to mention the following:
The text was updated successfully, but these errors were encountered: