Skip to content
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

JoinTable in non synchronized model still synchronized ? #4545

Open
S0PEX opened this issue Aug 5, 2019 · 0 comments
Open

JoinTable in non synchronized model still synchronized ? #4545

S0PEX opened this issue Aug 5, 2019 · 0 comments

Comments

@S0PEX
Copy link

S0PEX commented Aug 5, 2019

Issue type:

[ X] question
[ ] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[X ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[ X] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

I am currently working on two schema's. One is created and managed by TypeOrm and the other one is a xenforo instance. I only have query permissions on the xenforo schema. Each user has subscriptions saved on a different table which needs to be joined with the user. This is done through a join table again managed by xenforo so I only have read access to that. So I set up the decorations and everything is working fine. But although the entity is marked as non synchronized TypeOrm tries to create the JoinTable in the xenforo schema which fails because of missing permissions.
This is how my entity class looks like :

@ObjectType()
@Entity({ schema: 'dev_xf', name: 'xf_user', synchronize: false })
export class User extends BaseEntity {
  @Field(type => Int)
  @PrimaryGeneratedColumn({ name: 'user_id', unsigned: true })
  id: number;

  @Field()
  @Column()
  username: string;

  @Column({ name: 'is_moderator' })
  isModerator: boolean;

  @Column({ name: 'is_admin' })
  isAdmin: boolean;

  @Field()
  @Column({ name: 'is_banned' })
  isBanned: boolean;

  @OneToOne(type => UserAuthentication)
  @JoinColumn({ name: 'user_id' })
  authentication: UserAuthentication;

  @Field(type => [UserUpgrade])
  @ManyToMany(type => UserUpgrade)
  @JoinTable({
    schema: 'dev_xf',
    name: 'xf_user_upgrade_active',
    joinColumn: {
      name: 'user_id'
    },
    inverseJoinColumn: {
      name: 'user_upgrade_id'
    }
  })
  userUpgrades: Promise<UserUpgrade[]>;
}
@ObjectType()
@Entity({ schema: 'dev_xf', name: 'xf_user_upgrade', synchronize: false })
export class UserUpgrade extends BaseEntity {
  @Field(type => Int)
  @PrimaryGeneratedColumn({ name: 'user_upgrade_id', unsigned: true })
  id: number;

  @Field()
  @Column()
  title: string;
}

Is there a workaround to fix the issue that TypeOrm tries to create the JoinTable although both Entities are marked as non synchronized ?

Regards Artur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants