Open aquirdTurtle opened 3 months ago
can you confirm the data type you were using when you say this? I suspect it was not a string or int type, maybe something like a datetime
?
The column type is json (an example where the null()
function is useful) and the app crashes before anything is added to the Foo table. Or did you mean something else?
Can you try using the server_default
instead of default
for these types of default value configurations? It's currently not possible to use the DTO to infer these types of defaults.
Hello @aquirdTurtle i think that the problem lies in the definition of the sqlalchemy Model. The null() expression renders to “SQL NULL”, while you might want to use JSON.NULL. look at this note: https://docs.sqlalchemy.org/en/21/core/type_basics.html#sqlalchemy.types.JSON.NULL
Description
There is a
null()
function in sqlalchemy which is useful on JSON objects to disambiguate sqlnull
vs jsonnull
as a value. The advanced alchemy package appears to not have support for this however. Running the code below results in an unexpected exception:Examining the sqla_default object further reveals that the default _detect_defaults retrieves:
I'm not familiar enough with this ecosystem to be confident in any fixes, I'm not sure if just detecting the above and setting the
default=None
would work though?URL to code causing the issue
No response
MCVE
Steps to reproduce
Screenshots
"In the format of:
![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)
"Logs
Package Version
advanced-alchemy is version 0.17.3. Full list:
Platform