Closed YaraslauZhylko closed 1 year ago
Thanks for the report! The Function/Trigger implementations are under utilized in comparison to some of the other features, so much appreciated.
Fix should be released in v0.6.5
@DanCardin The release seems to work fine.
No false-positive migrations generated. Even if I reformat the multi-line function code to make it look prettier (as long as the relative indentation of the function body is maintained).
But if I change the relative indentation in the function definition, a re-create command is generated as expected.
Thanks a lot!
Function definition:
Generated Alembic command:
The statement is correct and is successfully applied.
But when trying to generate a new migration, the function is incorrectly considered to be modified:
As you can see, the only difference is in the number of leading spaces.
This is most probably caused by the indentation of the Alembic code and the way Python handles multi-line strings.
To mitigate that on my side I have a custom function:
that I use to wrap function definitions:
The resulting Alembic command looks like that:
As the final function has no new lines and no indentation, trying to generate a new migration does not cause false-positive changes.
The potential fix would be to use the same
oneliner()
function to pre-process both the Python definition and the returned PostgreSQL definition before comparing them and making a decision on whether the function has to be re-created.