-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add support for partial unique indexes #237
Conversation
…ption Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
…ption Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
…ption Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
12e3a0c
to
555a2f6
Compare
…ption Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
…ption Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
name?: string; | ||
description?: string; | ||
nulls?: string; | ||
predicate?: BooleanTypeNodes; |
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.
I got the name from the PG CREATE INDEX synopsis.
See: https://www.postgresql.org/docs/16/sql-createindex.html
…ption Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
const sha = sbvrTypes.SHA.validateSync( | ||
`${tableName}$${JSON.stringify(ruleBody)}`, | ||
).replace(/^\$sha256\$/, ''); | ||
// Trim the trigger to a max of 63 characters, reserving at least 32 characters for the hash | ||
return `${tableName.slice(0, 30)}$${sha}`.slice(0, 63); |
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.
I think it'd make sense for this to take inspiration from the roughly equivalent code in https://github.com/balena-io-modules/odata-to-abstract-sql/blob/v6.2.4/src/odata-to-abstract-sql.ts#L393-L396 - the things of note to me are:
- using base36 allows it to still be a string but also fit as much of the hash in as possible in the same number of characters (vs hex/base 16)
- adjusting the truncation dynamically based upon the actual strings
- using a named constant for
MAX_ALIAS_LENGTH
rather than a magic number for which the reasoning is not as clear
…ption Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
555a2f6
to
2998222
Compare
It seems that the latest TS fails to compile on master |
src/AbstractSQLCompiler.ts
Outdated
// Without the `: SbvrType['validate']` widening TS complains that | ||
// "none of those signatures are compatible with each other". | ||
const validateFn: SbvrType['validate'] = | ||
validateTypes[dataType as keyof typeof sbvrTypes]; |
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.
That's on master atm, and will be dropped from this PR once I rebase.
package.json
Outdated
@@ -36,7 +36,7 @@ | |||
"lint-staged": "^13.2.1", | |||
"mocha": "^10.2.0", | |||
"ts-node": "^10.9.1", | |||
"typescript": "^5.0.4" | |||
"typescript": "^5.4.3" |
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.
Will be dropped once I rebase on top of master
Change-type: minor
Change-type: minor
Change-type: minor
694b370
to
6d00b7d
Compare
…ption Update @balena/abstract-sql-compiler from 9.0.4 to 9.1.0 Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
…ption Update @balena/abstract-sql-compiler from 9.0.4 to 9.1.0 Depends-on: balena-io-modules/abstract-sql-compiler#237 Change-type: minor
Change-type: minor
See: https://balena.zulipchat.com/#narrow/stream/346007-balena-io.2FbalenaCloud/topic/Pine.20Partial.20UNIQUE.20Index.20based.20rules