Fix queries for $in: [null, ...etc] in pg (#7253)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-12-02 23:20:26 +07:00 committed by GitHub
parent 44e55f3f61
commit 1526ae2055
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 3 deletions

View File

@ -1137,7 +1137,16 @@ abstract class PostgresAdapterBase implements DbAdapter {
case '$in': case '$in':
switch (type) { switch (type) {
case 'common': case 'common':
res.push(`${tkey} IN (${val.length > 0 ? val.map((v: any) => `'${v}'`).join(', ') : 'NULL'})`) if (Array.isArray(val) && val.includes(null)) {
res.push(
`(${tkey} IN (${val
.filter((it) => it != null)
.map((v: any) => `'${v}'`)
.join(', ')}) OR ${tkey} IS NULL)`
)
} else {
res.push(`${tkey} IN (${val.length > 0 ? val.map((v: any) => `'${v}'`).join(', ') : 'NULL'})`)
}
break break
case 'array': case 'array':
res.push(`${tkey} && array[${val.length > 0 ? val.map((v: any) => `'${v}'`).join(', ') : 'NULL'}]`) res.push(`${tkey} && array[${val.length > 0 ? val.map((v: any) => `'${v}'`).join(', ') : 'NULL'}]`)
@ -1148,7 +1157,14 @@ abstract class PostgresAdapterBase implements DbAdapter {
} }
break break
case '$nin': case '$nin':
if (val.length > 0) { if (Array.isArray(val) && val.includes(null)) {
res.push(
`(${tkey} NOT IN (${val
.filter((it) => it != null)
.map((v: any) => `'${v}'`)
.join(', ')}) AND ${tkey} IS NOT NULL)`
)
} else if (val.length > 0) {
res.push(`${tkey} NOT IN (${val.map((v: any) => `'${v}'`).join(', ')})`) res.push(`${tkey} NOT IN (${val.map((v: any) => `'${v}'`).join(', ')})`)
} }
break break

View File

@ -0,0 +1,6 @@
/**
* @public
*/
export const githubConfiguration = {
ResolveThreadSupported: false
}

View File

@ -41,6 +41,7 @@ import { Analytics } from '@hcengineering/analytics'
import { PullRequestReviewThreadEvent } from '@octokit/webhooks-types' import { PullRequestReviewThreadEvent } from '@octokit/webhooks-types'
import config from '../config' import config from '../config'
import { syncConfig } from './syncConfig' import { syncConfig } from './syncConfig'
import { githubConfiguration } from './configuration'
export type ReviewThreadData = Pick< export type ReviewThreadData = Pick<
GithubReviewThread, GithubReviewThread,
@ -362,7 +363,7 @@ export class ReviewThreadSyncManager implements DocSyncManager {
if (Object.keys(platformUpdate).length > 0) { if (Object.keys(platformUpdate).length > 0) {
// Check and update external // Check and update external
if (platformUpdate.isResolved !== undefined) { if (platformUpdate.isResolved !== undefined && githubConfiguration.ResolveThreadSupported) {
const okit = (await this.provider.getOctokit(account as Ref<PersonAccount>)) ?? container.container.octokit const okit = (await this.provider.getOctokit(account as Ref<PersonAccount>)) ?? container.container.octokit
const q = `mutation updateReviewThread($threadID: ID!) { const q = `mutation updateReviewThread($threadID: ID!) {
${platformUpdate.isResolved ? 'resolveReviewThread' : 'unresolveReviewThread'} ( ${platformUpdate.isResolved ? 'resolveReviewThread' : 'unresolveReviewThread'} (