-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix incorrect ordering of columns in clustered indexes on sql server #826
fix incorrect ordering of columns in clustered indexes on sql server #826
Conversation
…when hydrated from schema info
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DBAL-1186 We use Jira to track the state of pull requests and the versions they got |
@zeroedin-bill can you please provide a failing test case here plox? \m/ thanks |
@deeky666 test shows the bug with the old query, should be good to go now. All hail sql server... |
$table = new Table('sqlsrv_pk_ordering'); | ||
$table->addColumn('colA', 'integer', array('notnull' => true)); | ||
$table->addColumn('colB', 'integer', array('notnull' => true)); | ||
$table->setPrimaryKey(['colB', 'colA']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't use short array syntax here as we are still on PHP 5.3
Can't use short array in php < 5.4
@deeky666 Fixed, thanks :) |
fix incorrect ordering of columns in clustered indexes on sql server
Thanks @zeroedin-bill ! |
When schema information is fetched from SQL server, the getListTableIndexesSQL was fetching index columns ordered by sys.index_columns.index_column_id. This was incorrect, because that column is simply a unique id for the column within the index. The column ordering information is actually in the key_ordinal column.
This PR changes SQLServerPlatform to generate a resultset ordered by key_ordinal instead of index_column_id.
This was causing schema diffs on tables with composite primary keys to try to drop and re-create the indexes every time the diff is run.
So this solves index churn in schema diffs on SQL server.