quick icon indicating copy to clipboard operation
quick copied to clipboard

.deleteAll() substitutes foreign key with "true"

Open MordantWastrel opened this issue 4 years ago • 4 comments

We have an invoice entity that hasMany lineItems, and in the preDelete() interceptor we had this code:

this.lineItems().deleteAll()

The resulting query was (from memory now, but the important part is right)

DELETE FROM invoice_lineItems WHERE invoiceID = [true]

this.getLineItems() works fine, as does this.ineItems().toSQL() -- the FK is correctly populated.

As a workaround, this works:

this.getLineItems()
	.each( ( l ) => {
		l.delete();
	} );

Overkill for what's needed but we only ever have 1-3 line items so it's not a big deal. I don't think I've ever used .deleteAll() before now.

Quick 4.1.3, qb 8.0.3

MordantWastrel avatar Oct 02 '20 16:10 MordantWastrel