You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alembic treats the output of render_item as both python code to be added to tables and compiled code to be rendered in sql statements.
When rendering a custom function type for a table we want the output to be something like app.migration_types.custom_func.
However internally that type of output will cause an error.
For example when alembic renders a field for comparison it uses the user_defined_render.
def _render_server_default_for_compare(
metadata_default: Optional[Any],
metadata_col: Column,
autogen_context: AutogenContext,
) -> Optional[str]:
rendered = _user_defined_render(
"server_default", metadata_default, autogen_context
)
Later in the postgres server_default_comparison, and maybe in others, the rendered item is compared in sql.
This comparison is the source of the reported error. The output should be compiled sql but its just the python path to the user's function.
SELECT timezone('utc'::text, now()) = CustomUtcNow()
Currently trying to fix this with an overload for compare_server_default and it seems possible but I think this is a bit of a flaw in either the instructions for rendering custom types or the logic for comparing custom types.
Expected behavior
Default functionality should probably compare the compiled output to the rendered output.
To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.
I don't have a MCV or stack trace. Just opening the issue to provide context since I ran into a similar issue as another user #641 (comment).
If one of the maintainers asks for an MCV I can provide.
# Insert code here
Error
# Copy error here. Please include the full stack trace.
Versions.
OS:
Python:
Alembic:
SQLAlchemy:
Database:
DBAPI:
Additional context
Have a nice day!
The text was updated successfully, but these errors were encountered:
Describe the bug
Alembic treats the output of render_item as both python code to be added to tables and compiled code to be rendered in sql statements.
When rendering a custom function type for a table we want the output to be something like app.migration_types.custom_func.
However internally that type of output will cause an error.
For example when alembic renders a field for comparison it uses the user_defined_render.
def _render_server_default_for_compare(
metadata_default: Optional[Any],
metadata_col: Column,
autogen_context: AutogenContext,
) -> Optional[str]:
rendered = _user_defined_render(
"server_default", metadata_default, autogen_context
)
Later in the postgres server_default_comparison, and maybe in others, the rendered item is compared in sql.
This comparison is the source of the reported error. The output should be compiled sql but its just the python path to the user's function.
SELECT timezone('utc'::text, now()) = CustomUtcNow()
Currently trying to fix this with an overload for compare_server_default and it seems possible but I think this is a bit of a flaw in either the instructions for rendering custom types or the logic for comparing custom types.
Expected behavior
Default functionality should probably compare the compiled output to the rendered output.
To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.
I don't have a MCV or stack trace. Just opening the issue to provide context since I ran into a similar issue as another user #641 (comment).
If one of the maintainers asks for an MCV I can provide.
# Insert code here
Error
Versions.
Additional context
Have a nice day!
The text was updated successfully, but these errors were encountered: