Read mssql index columns in key order

Index.Equal compares columns by position, but the mssql GetIndexes query
had no ORDER BY, so the column order it returned was up to the query plan.
This commit is contained in:
dualfroz committed 2026-09-29 15:57:45 +02:00
1 parent d9f01bc901
commit 9fa1420535
1 file changed
+1
+1
View File
@@ -604,6 +604,7 @@ ON IXS.OBJECT_ID=IXCS.OBJECT_ID AND IXS.INDEX_ID = IXCS.INDEX_ID
INNER JOIN sys.columns C ON IXS.OBJECT_ID=C.OBJECT_ID
AND IXCS.COLUMN_ID=C.COLUMN_ID
WHERE IXS.TYPE_DESC='NONCLUSTERED' and OBJECT_NAME(IXS.OBJECT_ID) =?
ORDER BY IXS.INDEX_ID, IXCS.IS_INCLUDED_COLUMN, IXCS.KEY_ORDINAL, IXCS.INDEX_COLUMN_ID
`
rows, err := queryer.QueryContext(ctx, s, args...)