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

Error updating data with the save() function #6375

Closed
JoaoCRDias opened this issue Jul 9, 2020 · 4 comments
Closed

Error updating data with the save() function #6375

JoaoCRDias opened this issue Jul 9, 2020 · 4 comments

Comments

@JoaoCRDias
Copy link

Issue type:

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

Database system/driver:

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

TypeORM version:

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

Entity:

@Entity()
export class AgPaciente {
  @PrimaryColumn({type: 'character', name: 'CODIGO_PACIENTE', length: 45})
  @Generated('uuid')
  codigoPaciente!: string;

  @Column({type: 'varchar', name: 'NOME', length: 70})
  nome!: string;
}

JSON Typeorm returns in find():

{
codigoPaciente: "acedeae2-d572-4e27-ab3b-ec9616b0965f",
nome: "Example"
}

JSON i sent to save():

{
codigoPaciente: "acedeae2-d572-4e27-ab3b-ec9616b0965f",
nome: "Modified Example"
}

Function i use to save data:

  salvarPaciente = async (data) => {
    try {
      let pacienteRepository = getRepository(AgPaciente);
      let response = await pacienteRepository.save(data);
    } catch (error) {
      console.log(error);
    }
  };

Error:

TypeError: Right-hand side of 'instanceof' is not an object
    at Function.OrmUtils.compare2Objects (***\node_modules\typeorm\browser\util\OrmUtils.js:193)
    at Function.OrmUtils.deepCompare (***\node_modules\typeorm\browser\util\OrmUtils.js:111)
    at Function.OrmUtils.compareIds (***\node_modules\typeorm\browser\util\OrmUtils.js:130)
    at EntityMetadata.compareEntities (***\node_modules\typeorm\browser\metadata\EntityMetadata.js:329)
    at ***\node_modules\typeorm\browser\persistence\SubjectDatabaseEntityLoader.js:139
    at Array.filter (<anonymous>)
    at SubjectDatabaseEntityLoader.findByPersistEntityLike (***\node_modules\typeorm\browser\persistence\SubjectDatabaseEntityLoader.js:134)
    at ***\node_modules\typeorm\browser\persistence\SubjectDatabaseEntityLoader.js:91
    at Array.forEach (<anonymous>)
    at SubjectDatabaseEntityLoader.<anonymous> (***\node_modules\typeorm\browser\persistence\SubjectDatabaseEntityLoader.js:90)

Am I doing something wrong? How to solve this problem?

@Thomascogez
Copy link

Thomascogez commented Jul 9, 2020

@Kolisium i think you can try @ next version

Edit: I just check you can try next version or a fresh build of master, be aware if your are using next version when you call find with relation the structure of relation has change, it's now type safe.

so

   xx.find({..., relation: ["aa", "bb", "bb.cc"]})

to

   xx.find({..., relation: {aa: true, bb: true, bb: {cc: true}}})

same as #6233

@JoaoCRDias
Copy link
Author

JoaoCRDias commented Jul 9, 2020

The @ next solves this problem, thank you very much!

@josephmbeveridge
Copy link

Honestly this issue should be left open, I spent so many hours trying to figure out why the current stable release of TypeORM wasn't working. Any object relationships will break on current stable.

@cristian-milea
Copy link

cristian-milea commented Aug 23, 2020

it did not work for me on Expo, @ next version doesn't have the driver option for expo so all crashes

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