Repository navigation
Conversation
jchate6
left a comment
There was a problem hiding this comment.
Do we have a test for trying to get_or_create an object where the unique constraints are identical but fields that are not checked for uniqueness differ?
I'm still concerned that without something like this, get_or_create will fail to get because they are too different, but also fail to create because they are too similiar.
What should happen in that case?
|
I still don't follow. If get_or_create() fails to create because of a uniqueness check, how is that different than just .create()? It should fail, even if the non-indexed columns differ. And it should also not return an existing object, if the non-indexed fields are different. I think in the case you are thinking of, you just don't pass in the non-indexed fields? There is no requirement to pass in every field to get_or_create. |
|
I think I disagree. It feels like if two objects are so similar that we would not create a new one, I would want the |
This sounds like you are describing a heuristic, not how get or create normally works. We can write this as a different method, but I wouldn’t override it. I think would be fine as domain specific logic at the call site instead of overriding Django built ins. |
c0fe653 to
ea8c44c
Compare
jchate6
left a comment
There was a problem hiding this comment.
That makes sense. I guess I'd like to see some tests that run this scenario for the places we rely on get_or_create in the code.
|
I added a few tests which look like how get_or_create is used in the alerce broker: tom_base/tom_alerts/brokers/alerce.py Line 570 in c0fe653 Though it doesn't really feel like the specific case the overriden method was designed for. I couldn't find any calls in tom_base that look like they were, maybe in an external app? |
No description provided.