emmett-framework / emmett

The web framework for inventors
Other
1.03k stars 70 forks source link

Bug in migration alter field with MSSQL Server #372

Closed josejachuf closed 2 years ago

josejachuf commented 3 years ago

I do not know if the idea is to support MSSQL Server, as I said in another post, I am not a user, but now circumstantially I touch myself.

I report the case in which a field is modified and an error occurs.

In this case the width of a string field from 30 to 500 will be changed, for example. The generated SQL is:

ALTER TABLE "mytable" ALTER COLUMN "myfield" TYPE VARCHAR(60);

Should be the following, without TYPE

ALTER TABLE "mytable" ALTER COLUMN "myfield" VARCHAR(60);

The code is here [1], but I do not know how to refer to the database engine

Best Regards Jose

[1] https://github.com/emmett-framework/emmett/blob/46c765114ce5078b93361b218ef8197e461fad8f/emmett/orm/migrations/engine.py#L296

gi0baro commented 2 years ago

@josejachuf this would need a bit of refactoring of the migrations code in order to use dialects to construct queries. To be honest when I firstly designed it I ensured the code worked on sqlite and postgres.

I'm not sure I'll be able to include this in 2.3, let's see.

josejachuf commented 2 years ago

Thanks @gi0baro

For me it reaches with SQLite and PostgreSQL. All I have reported from MSSQL Server is so that it is registered that there is a bug. Everything is solvable doing it "by hand"