Closed NateAGeek closed 2 months ago
After revisiting the SeaORM documentation, I've resolved the issue I encountered with the mock database while trying to mock the creation of an instance. The root cause was a misunderstanding of how the MockDatabase is intended to function, specifically regarding the use of append_query_results and append_exec_results.
To address the Type("A null value was encountered while decoding \"id\"") error, it was essential to properly simulate the database operations. For the example provided, both the creation of friendships::ActiveModel and the expected insert operation needed to be reflected in the mock setupβappend_query_results for the select operations and append_exec_results for the insert/update/delete operations.
This clarification made it evident that the mock database doesn't act merely as a container but requires explicit setup for each type of database operation to accurately test the behavior of the code under different conditions.
I recommend enhancing the documentation to more clearly explain the interaction between append_query_results and append_exec_results, especially for new users of SeaORM. This guidance could prevent similar misunderstandings in the future. The documentation at https://www.sea-ql.org/SeaORM/docs/write-test/mock/ would be a great place for such detailed examples and explanations.
I'm closing this issue as it was resolved through a better understanding of the documentation and the intended use of SeaORM's mocking capabilities. Thank you.
Description
When mocking my database I am attempting to mock the creation of a instance.
I keep getting
I am not sure what is the issue and why I keep getting the null. I have tried stack tracing it but not sure where it is happening.
Expected Behavior
Creation of request
Actual Behavior
Null error
Workarounds
I tried creating results and worked around making the id 0 by default.
Versions
βββ sea-orm v0.12.12 β βββ sea-orm-macros v0.12.12 (proc-macro) β β βββ sea-bae v0.2.0 (proc-macro) β βββ sea-query v0.30.7 β βββ sea-query-binder v0.5.0 β β βββ sea-query v0.30.7 (*)