Skip to content

Commit

Permalink
Fix queries for $in: [null, ...etc] in pg (#7253)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <[email protected]>
  • Loading branch information
haiodo authored Dec 2, 2024
1 parent 44e55f3 commit 1526ae2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
20 changes: 18 additions & 2 deletions server/postgres/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,16 @@ abstract class PostgresAdapterBase implements DbAdapter {
case '$in':
switch (type) {
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
case 'array':
res.push(`${tkey} && array[${val.length > 0 ? val.map((v: any) => `'${v}'`).join(', ') : 'NULL'}]`)
Expand All @@ -1148,7 +1157,14 @@ abstract class PostgresAdapterBase implements DbAdapter {
}
break
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(', ')})`)
}
break
Expand Down
6 changes: 6 additions & 0 deletions services/github/pod-github/src/sync/configuration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @public
*/
export const githubConfiguration = {
ResolveThreadSupported: false
}
3 changes: 2 additions & 1 deletion services/github/pod-github/src/sync/reviewThreads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { Analytics } from '@hcengineering/analytics'
import { PullRequestReviewThreadEvent } from '@octokit/webhooks-types'
import config from '../config'
import { syncConfig } from './syncConfig'
import { githubConfiguration } from './configuration'

export type ReviewThreadData = Pick<
GithubReviewThread,
Expand Down Expand Up @@ -362,7 +363,7 @@ export class ReviewThreadSyncManager implements DocSyncManager {

if (Object.keys(platformUpdate).length > 0) {
// 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 q = `mutation updateReviewThread($threadID: ID!) {
${platformUpdate.isResolved ? 'resolveReviewThread' : 'unresolveReviewThread'} (
Expand Down

0 comments on commit 1526ae2

Please sign in to comment.