You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 7, 2019. It is now read-only.
When using as_of() it using OR operator into query to add current record into result.
>>>print MyMode.objects.as_of(timezone.now()).query
SELECT `mymodel`.`id`, `mymodel`.`identity`, `mymodel`.`version_start_date`, `mymodel`.`version_end_date`, `mymodel`.`version_birth_date` FROM `mymodel` WHERE ((`mymodel`.`version_end_date` > 2018-03-20 14:30:18 OR `mymodel`.`version_end_date` IS NULL) AND `mymodel`.`version_start_date` <= 2018-03-20 14:30:18)
If set version_end_date default value to datetime.max (or other hard-to-reach value) it is possible to avoid using OR. This will lead to a decrease of query cost.
SELECT `mymodel`.`id`, `mymodel`.`identity`, `mymodel`.`version_start_date`, `mymodel`.`version_end_date`, `mymodel`.`version_birth_date` FROM `mymodel` WHERE (`mymodel`.`version_end_date` > 2018-03-20 14:30:18 AND `mymodel`.`version_start_date` <= 2018-03-20 14:30:18)