Skip to content

Commit

Permalink
Merge pull request #149 from balena-io-modules/block-alternate-key-pa…
Browse files Browse the repository at this point in the history
…rtial-unique-index

Properly error when using fields of a partial index as an alternate key
  • Loading branch information
flowzone-app[bot] authored Apr 23, 2024
2 parents 18795c8 + 8652f14 commit 56e6c98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"author": "",
"license": "BSD",
"dependencies": {
"@balena/abstract-sql-compiler": "^9.0.4",
"@balena/abstract-sql-compiler": "^9.1.4",
"@balena/odata-parser": "^3.0.3",
"@types/lodash": "^4.14.202",
"@types/memoizee": "^0.4.11",
Expand Down
3 changes: 2 additions & 1 deletion src/odata-to-abstract-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,8 @@ export class OData2AbstractSQL {
) &&
!resource.indexes.some((index) => {
return (
(index.type === 'UNIQUE' || index.type === 'PRIMARY KEY') &&
((index.type === 'UNIQUE' && index.predicate == null) ||
index.type === 'PRIMARY KEY') &&
sqlFieldNames.length === index.fields.length &&
_.isEqual(index.fields.slice().sort(), sqlFieldNames)
);
Expand Down

0 comments on commit 56e6c98

Please sign in to comment.