Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSSQL - Diff generates wrong syntax on ALTER TABLE #1294

Closed
MDT-FGI opened this issue Nov 10, 2016 · 2 comments
Closed

MSSQL - Diff generates wrong syntax on ALTER TABLE #1294

MDT-FGI opened this issue Nov 10, 2016 · 2 comments

Comments

@MDT-FGI
Copy link

MDT-FGI commented Nov 10, 2016

When you change a type in your schema.xml and the column has to be modified, propel generates wrong syntax on the update statements. This happens on any table/column if you change their type afterwards.

Generated statement:

ALTER TABLE [Note] MODIFY
(
[created_at] DATETIME2 NULL,
[updated_at] DATETIME2 NULL
);

Exception of the executed statement:

[Propel\Runtime\Exception\RuntimeException]
Failed to execute SQL "ALTER TABLE [Note] MODIFY
(
[created_at] DATETIME2 NULL,
[updated_at] DATETIME2 NULL
)". Aborting migration.
[PDOException]
SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near 'MODIFY'.

Correct Syntax would look like this:

ALTER TABLE [Note] ALTER COLUMN
[created_at] DATETIME2 NULL;
ALTER TABLE [Note] ALTER COLUMN
[updated_at] DATETIME2 NULL;

You can not modify multiple columns at once with MSSQL.

@MDT-FGI
Copy link
Author

MDT-FGI commented Feb 13, 2017

Same problem happends with "ALTER TABLE x ADD column_a;"
There is some brackets "( ... )" not being expected by MSSQL

atompulse added a commit to atompulse/Propel2 that referenced this issue Aug 28, 2017
propelorm#1294
propelorm#1343
Solved:
- size checking issue
- default values issue
- foreign keys actions (on delete/on update)
Remaining:
- sql syntax for alter table
atompulse added a commit to atompulse/Propel2 that referenced this issue Aug 29, 2017
atompulse added a commit to atompulse/Propel2 that referenced this issue Aug 31, 2017
atompulse added a commit to atompulse/Propel2 that referenced this issue Nov 22, 2017
propelorm#1294
propelorm#1343
Solved:
- size checking issue
- default values issue
- foreign keys actions (on delete/on update)
Remaining:
- sql syntax for alter table
atompulse added a commit to atompulse/Propel2 that referenced this issue Nov 22, 2017
atompulse added a commit to atompulse/Propel2 that referenced this issue Nov 22, 2017
@dereuromark
Copy link
Contributor

Closing in favor of the other ticket with more details.
Also, PR seems open and just needs to get finished and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants