-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
What's the use of HistoricForeignKey ? I can't see any foreign key relationship between automatically created related tables inside the database #1380
Comments
Have you looked over this test case?
|
Will you please clear the air? I didn't get your point. |
from my understanding, I created an example to try to demonstrate what I mean. Maybe try running the test code below with your own demo DRF app. In the first test, I try to demonstrate getting historical data with explicit timestamps. In the second test, I try to use the
|
I was hoping that introduction of HistoricForeignKey may establish a foreignkey relationship between the historic tables of both the related tables inside the database, so that, we can easily retrieve child records while querying for the parent's history or vice versa.
For example, If I have a LineItem model having a foreign key field pointing to Invoice model, If I change either LineItem or Invoice, I will have new records for both Invoice and LineItem in their respective history tables with LineItem's historic table having history_id of Invoice's historic table so that we can easily retrieve historical data of either of them for a given point in time.
But what I found is instead of having history_id of Invoice's historical data, LineItem's historic table is actually saving original Invoice's id, which doesn't help to retrieve corresponding Invoice data in history.
Hope I made my point clear, It may have something to do with lack of documentation / example on HistoricForeignkey field. If someone could understand my point, Will you please help me achieve the same with an example preferably in context of django rest framework ?
The text was updated successfully, but these errors were encountered: