UBERF-8856: Fix space security query and schema update (#7413)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2024-12-10 16:37:59 +07:00
committed by GitHub
parent f1dbf21146
commit cb9720f340
20 changed files with 106 additions and 111 deletions
+41 -1
View File
@@ -152,6 +152,11 @@ const docIndexStateSchema: Schema = {
type: 'bool',
notNull: true,
index: true
},
objectClass: {
type: 'text',
notNull: true,
index: false
}
}
@@ -212,6 +217,40 @@ const eventSchema: Schema = {
}
}
const docSyncInfo: Schema = {
...baseSchema,
needSync: {
type: 'text',
notNull: false,
index: false
},
externalVersion: {
type: 'text',
notNull: false,
index: false
},
repository: {
type: 'text',
notNull: false,
index: false
},
url: {
type: 'text',
notNull: false,
index: false
},
objectClass: {
type: 'text',
notNull: false,
index: false
},
deleted: {
type: 'bool',
notNull: false,
index: false
}
}
export function addSchema (domain: string, schema: Schema): void {
domainSchemas[translateDomain(domain)] = schema
domainSchemaFields.set(domain, createSchemaFields(schema))
@@ -231,7 +270,8 @@ export const domainSchemas: Record<string, Schema> = {
[translateDomain(DOMAIN_DOC_INDEX_STATE)]: docIndexStateSchema,
notification: notificationSchema,
[translateDomain('notification-dnc')]: dncSchema,
[translateDomain('notification-user')]: userNotificationSchema
[translateDomain('notification-user')]: userNotificationSchema,
github: docSyncInfo
}
export function getSchema (domain: string): Schema {
+4 -7
View File
@@ -1276,7 +1276,10 @@ abstract class PostgresAdapterBase implements DbAdapter {
return []
}
strimSize (str: string): string {
strimSize (str?: string): string {
if (str == null) {
return ''
}
const pos = str.indexOf('|')
if (pos > 0) {
return str.substring(0, pos)
@@ -1308,12 +1311,6 @@ abstract class PostgresAdapterBase implements DbAdapter {
if (client === undefined) {
client = await this.client.reserve()
}
// We need update hash to be set properly
await client.unsafe(
`UPDATE ${tdomain} SET "%hash%" = '${this.curHash()}' WHERE "workspaceId" = '${this.workspaceId.name}' AND "%hash%" IS NULL OR "%hash%" = ''`
)
initialized = true
bulk = createBulk('_id, "%hash%"')
}
+1 -1
View File
@@ -283,7 +283,7 @@ export function convertDoc<T extends Doc> (
modifiedOn: doc.modifiedOn,
createdOn: doc.createdOn ?? doc.modifiedOn,
_class: doc._class,
'%hash%': (doc as any)['%hash%'] ?? null
'%hash%': (doc as any)['%hash%'] ?? Date.now().toString(16)
}
const remainingData: Partial<T> = {}