CamilleTeruel commented on code in PR #7032: URL: https://github.com/apache/incubator-devlake/pull/7032#discussion_r1504217228
########## backend/python/pydevlake/pydevlake/model.py: ########## @@ -125,13 +128,17 @@ def set_tool_origin(self, tool_model: 'ToolModel'): class NoPKModel(RawDataOrigin): - created_at: Optional[datetime] = Field( + created_at: [datetime] = Field( Review Comment: > collect and store data again, then new yield data with created_at = None will make records in database tables created_at = NULL. (it works during session.merge()) OK, I get it now, the merge overrides the previous value. I didn't understand how it ended up NULL. First, about `Optional`. With SQLModel, the model gets validated at instanciation. But fields like `created_at` and `updated_at` are set when saving the model to the database. They need to be `Optional`, otherwise we always have to provide them when creating models. So here, maybe a bit counter-intuitively, `Optional` means that we don't have to provide a value at instanciation but it doesn't necessarily mean that we allow the column value to be `NULL` when saved. So you can either keep like you did and put `Optional` back or look for an alternative to `session.merge`, like loading saved model if any, write some merge logic, and saving the model back (although it might make collection slower...). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
