DanCardin / sqlalchemy-declarative-extensions

Library to declare additional kinds of objects not natively supported by SqlAlchemy/Alembic.
https://sqlalchemy-declarative-extensions.readthedocs.io/en/latest/
Apache License 2.0
33 stars 5 forks source link

Procedures for MySQL #85

Closed jacobeatsspam closed 2 weeks ago

jacobeatsspam commented 2 weeks ago

Hello, it's me again :smile:

Opening this issue to discuss what it would take to add support for procedures.

Most everything seems to be straight forward, but I have one current question - how to handle replacement during creation.

The MySQL documentation suggests that OR REPLACE is not available, but unlike Triggers, the DDL is not written to support to_sql_update returning a list of operations, so I can't wrap a combined drop/create step.

Let me know what you think about this. I'm hoping the answer is to simply refactor the current DDL and compare approach, but maybe you have a better answer.

DanCardin commented 2 weeks ago

Ah yes, so basically the tact i've taken for other object has been to update to_sql (and thus to_sql_[create/update/drop]) to return list[str] instead of just str; and then deal with the fallout of that in procedure/ddl.py and alembic/procedure.py.

I've been meaning to do this to all the objects, mainly because this isn't the first time this has happened, but alas!

DanCardin commented 2 weeks ago

Were you planning on working on this? or should I?

jacobeatsspam commented 2 weeks ago

We prototyped out some code so we could get the ball rolling within our codebase, but it's not complete. It's missing things like support for specifying parameters and the DDL issue I asked about. You'd probably be faster than us since you're on a roll.

DanCardin commented 2 weeks ago

Thanks for the base impl! figuring out the queries (esp for a database i dont use personally) is always the biggest pain.