fix: Make tests pass on MySQl and Postgres (no-changelog) (#5005)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-12-22 11:13:22 +01:00
committed by GitHub
parent e4785da2e1
commit 365ffec3b2
5 changed files with 11 additions and 7 deletions

View File

@@ -61,7 +61,7 @@ export class PermissionChecker {
credentialsWhereCondition, credentialsWhereCondition,
); );
const accessibleCredIds = credentialSharings.map((s) => s.credentialId.toString()); const accessibleCredIds = credentialSharings.map((s) => s.credentialsId.toString());
const inaccessibleCredIds = workflowCredIds.filter((id) => !accessibleCredIds.includes(id)); const inaccessibleCredIds = workflowCredIds.filter((id) => !accessibleCredIds.includes(id));

View File

@@ -438,7 +438,7 @@ export function usersNamespace(this: N8nApp): void {
// workflows and credentials might be a sharee // workflows and credentials might be a sharee
await transactionManager.delete(SharedWorkflow, { await transactionManager.delete(SharedWorkflow, {
user: transferee, user: transferee,
workflow: In(sharedWorkflowIds.map((sharedWorkflowId) => ({ id: sharedWorkflowId }))), workflowId: In(sharedWorkflowIds),
}); });
// Transfer ownership of owned workflows // Transfer ownership of owned workflows
@@ -456,7 +456,7 @@ export function usersNamespace(this: N8nApp): void {
}); });
const sharedCredentialIds = sharedCredentials.map((sharedCredential) => const sharedCredentialIds = sharedCredentials.map((sharedCredential) =>
sharedCredential.credentialId.toString(), sharedCredential.credentialsId.toString(),
); );
// Prevents issues with unique key constraints since user being assigned // Prevents issues with unique key constraints since user being assigned

View File

@@ -80,7 +80,7 @@ export class CredentialsService {
select: SELECT_FIELDS, select: SELECT_FIELDS,
relations: options?.relations, relations: options?.relations,
where: { where: {
id: In(userSharings.map((x) => x.credentialId)), id: In(userSharings.map((x) => x.credentialsId)),
}, },
}); });
} }

View File

@@ -1,4 +1,4 @@
import { Entity, ManyToOne, RelationId } from 'typeorm'; import { Entity, ManyToOne, PrimaryColumn, RelationId } from 'typeorm';
import type { CredentialsEntity } from './CredentialsEntity'; import type { CredentialsEntity } from './CredentialsEntity';
import type { User } from './User'; import type { User } from './User';
import type { Role } from './Role'; import type { Role } from './Role';
@@ -12,6 +12,7 @@ export class SharedCredentials extends AbstractEntity {
@ManyToOne('User', 'sharedCredentials', { primary: true }) @ManyToOne('User', 'sharedCredentials', { primary: true })
user: User; user: User;
@PrimaryColumn()
@RelationId((sharedCredential: SharedCredentials) => sharedCredential.user) @RelationId((sharedCredential: SharedCredentials) => sharedCredential.user)
userId: string; userId: string;
@@ -21,6 +22,7 @@ export class SharedCredentials extends AbstractEntity {
}) })
credentials: CredentialsEntity; credentials: CredentialsEntity;
@PrimaryColumn()
@RelationId((sharedCredential: SharedCredentials) => sharedCredential.credentials) @RelationId((sharedCredential: SharedCredentials) => sharedCredential.credentials)
credentialId: number; credentialsId: number;
} }

View File

@@ -1,4 +1,4 @@
import { Entity, ManyToOne, RelationId } from 'typeorm'; import { Entity, ManyToOne, PrimaryColumn, RelationId } from 'typeorm';
import type { WorkflowEntity } from './WorkflowEntity'; import type { WorkflowEntity } from './WorkflowEntity';
import type { User } from './User'; import type { User } from './User';
import type { Role } from './Role'; import type { Role } from './Role';
@@ -12,6 +12,7 @@ export class SharedWorkflow extends AbstractEntity {
@ManyToOne('User', 'sharedWorkflows', { primary: true }) @ManyToOne('User', 'sharedWorkflows', { primary: true })
user: User; user: User;
@PrimaryColumn()
@RelationId((sharedWorkflow: SharedWorkflow) => sharedWorkflow.user) @RelationId((sharedWorkflow: SharedWorkflow) => sharedWorkflow.user)
userId: string; userId: string;
@@ -21,6 +22,7 @@ export class SharedWorkflow extends AbstractEntity {
}) })
workflow: WorkflowEntity; workflow: WorkflowEntity;
@PrimaryColumn()
@RelationId((sharedWorkflow: SharedWorkflow) => sharedWorkflow.workflow) @RelationId((sharedWorkflow: SharedWorkflow) => sharedWorkflow.workflow)
workflowId: number; workflowId: number;
} }