repo.save throwing UpdateValuesMissingError: Cannot perform update query because update values are not defined
See original GitHub issueIssue type:
[ ] question [X] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[X] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[X] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Hi friends I am having a weird behavior trying to call save:
Consider the following:
const repo = getRepository(NewAssignmentNotification)
const notification = new NewAssignmentNotification()
const owner = await customer.owner
notification.recipient = owner
notification.newCustomerAssignment = customer
notification.account = await owner.account
notification.createdAt = now()
console.log(JSON.stringify(notification, null, 2));
try{
await repo.save(notification)
}catch (e) {
console.log(e)
}
With that we get the exception:
UpdateValuesMissingError: Cannot perform update query because update values are not defined. Call "qb.set(...)" method to specify updated values.
The Entity looks like so …
@InterfaceType({ description: `a timely message to display to a user of quala` })
@Entity({ orderBy: { createdAt: 'DESC' }, synchronize: true })
@TableInheritance({ column: { type: 'varchar', name: 'type' } })
export class Notification {
@Field(() => ID)
@PrimaryGeneratedColumn('uuid')
id: string
@Field()
@Column({ nullable: false })
type: string
@Field(() => User)
@ManyToOne(() => User, { lazy: true, nullable: false })
recipient: Lazy<User>
@Field()
@CreateDateColumn()
createdAt: Date
@Field()
@Column({ nullable: true })
dismissedAt: Date
}
and
@ObjectType({ implements: Notification })
@ChildEntity()
export class NewAssignmentNotification extends Notification {
@Field(() => Customer)
@ManyToOne(() => Customer, { lazy: true })
@JoinTable()
newCustomerAssignment: Lazy<Customer>
}
Might be similar to: https://github.com/typeorm/typeorm/issues/4501
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
Cannot perform update query because update values are not ...
"message": "Cannot perform update query because update values are not defined. Call \"qb.set(...)\" method to specify updated values.",.
Read more >Micronaut Data - GitHub Pages
Micronaut Data is a database access toolkit that uses Ahead of Time (AoT) compilation to pre-compute queries for repository interfaces that are then...
Read more >TypeORM Sucks!! Something I wanted to talk about since long!
I have performed dozens of migrations using TypeORM; it is not perfect, but I have never had to write a raw query to...
Read more >Spring Data JPA - Reference Documentation
It looks up a declared query first, and, if no declared query is found, it creates a custom method name-based query. This is...
Read more >Common Hibernate Exceptions - Baeldung
Many conditions can cause exceptions to be thrown while using Hibernate. ... When we insert, update, delete or query data using Hibernate, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
so i solved this for myself – and plan going to close the issue.
The issue for me was that I was passing a object graph where one of the entities was not yet saved, causing a weird behavior.
I don’t think there is much TypeOrm can do here – expect potenitally make a better error message
I would think that my STI (Single Table Inheritance) would handle that (and it fact it does for many other of my notification types)