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

relation not work for react native #6233

Closed
CodingByJerez opened this issue Jun 9, 2020 · 5 comments
Closed

relation not work for react native #6233

CodingByJerez opened this issue Jun 9, 2020 · 5 comments

Comments

@CodingByJerez
Copy link

CodingByJerez commented Jun 9, 2020

Issue type:

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

Database system/driver:

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

TypeORM version:

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

TypeORM version:
[*] sqlite (react-native-sqlite-storage)

@Entity()
export class Test1Entity{

    @PrimaryGeneratedColumn()
    public id!:number;

    @Column({type: 'varchar'})
    public label!:string;

    @OneToOne(() => Test2Entity, {cascade: true})
    @JoinColumn()
    public relation!:Test2Entity;

}
@Entity()
export class Test2Entity{

    @PrimaryGeneratedColumn()
    public id!:number;

    @Column({type: 'varchar'})
    public label!:string;

}
    try{
        const test2Entity = new Test2Entity();
        test2Entity.label = 'label2';

        const test1Entity = new Test1Entity();
        test1Entity.label = 'label1';
        test1Entity.relation = test2Entity;

        const r = await getConnection().manager.save(test1Entity);

    }catch(e){

        console.log(e); // return msg: Right-hand side of 'instanceof' is not an object

    }

relation not work @joincolumn() return error:

TypeError: Right-hand side of 'instanceof' is not an object
    at Function.OrmUtils.mergeDeep (OrmUtils.js:81)
    at Subject.js:208
    at Array.reduce (<anonymous>)
    at Subject.createValueSetAndPopChangeMap (Subject.js:165)
    at SubjectExecutor.js:270
    at Array.forEach (<anonymous>)
    at SubjectExecutor.<anonymous> (SubjectExecutor.js:257)
    at step (tslib.js:141)
    at Object.next (tslib.js:122)
    at tslib.js:115

If anyone knows a solution to this problem thank you in advance :)
because I did not find any solution other than changing DB for realm :(

@hesyifei
Copy link

hesyifei commented Jun 19, 2020

Maybe this is related to #6142?


Update: I tried using master (https://github.com/typeorm/typeorm/tree/defa9bced0b5d1258e4f50d5c590978e6d3324d3) (which has #6145), and it seems to fix the problem.

@Thomascogez
Copy link

Hey @hesyifei, is it possible to explain how did you manage to fix that problem, I'm currently facing the same problem

@hesyifei
Copy link

hesyifei commented Jun 23, 2020

Hey @hesyifei, is it possible to explain how did you manage to fix that problem, I'm currently facing the same problem

I built a fresh copy from master (ref: https://github.com/typeorm/typeorm/blob/master/DEVELOPER.md) and replaced the typeorm folder in node_modules with the built build/package directory.

Another thing I think you can try is to just use an older version of typeorm in package.json, a version before that problematic commit.

@Thomascogez
Copy link

Thomascogez commented Jun 24, 2020

thank for the answer @hesyifei , I was able to resolve this by using @ next version (Be aware if your are using this version relations has some changes )

@imnotjames
Copy link
Contributor

Sounds like you're all set here - I'll be closing this as having been resolved but please feel free to reach out if it's still an issue!

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

No branches or pull requests

4 participants