olirice / alembic_utils

An alembic/sqlalchemy extension for migrating sql views, functions, triggers, and policies
MIT License
193 stars 42 forks source link

Colon character escaped unnecessarily in view autogeneration #95

Closed johnwiseheart closed 2 years ago

johnwiseheart commented 2 years ago

Similar to the example in #58, My view looks something like this

query = "SELECT concat('https://something/', column) FROM table"
some_view = PGMaterializedView(schema="public", signature="example", definition=query)

Which generated a revision something like so

public_something = PGMaterializedView(
    schema="public",
    signature="something",
    definition="SELECT concat('https\\://something/', column) FROM table",
)
op.replace_entity(public_something)

I'd expect that the : character should not be escaped in the definition, or at least there should be a way to un-escape it.

Seemingly, the way it is right now, there is not a way to auto-generate a view containing a URL without manual changes.

olirice commented 2 years ago

I was not able to reproduce that result. Are you on the latest version of alembic_utils?

Screen Shot 2022-07-01 at 2 52 34 PM
johnwiseheart commented 2 years ago

Ah my mistake, I missed a change in the example, which is that this is a Materialized view. I just checked locally and with the latest version, the issue seems to only appear for the materialized view, and not the regular view. Does that make sense?

I updated the example to reflect the change

olirice commented 2 years ago

thanks for reporting the update is available in alembic_utils==0.7.8

johnwiseheart commented 2 years ago

Amazing, thank you!