Error happened during query after delete referenced data :cascade obj is not exist #1772

Open
opened 2020-08-24 10:02:54 +00:00 by xiaogan18 · 4 comments

table definition

type ClusterGroup struct {
	Id                   int64                  `json:"id" xorm:"pk autoincr unique notnull 'id'"`
	Name                 string                 `json:"name" xorm:"notnull"`
	Description          string                 `json:"description"`
	models.Common        `xorm:"extends"`
}

type Cluster struct {
	Id               int64               `json:"id" xorm:"pk autoincr unique notnull 'id'"`
	Name             string              `json:"name" xorm:"notnull"`
	ClusterGroup     *ClusterGroup       `json:"cluster_group"`
	models.Common    `xorm:"extends"`
}

issue

When I deleted row from ClusterGroup which is referenced by Cluster, all query with table Cluster were failed if result include the reference-missing rows, error message: cascade obj is not exist. Is there any solution for this?

## table definition ```go type ClusterGroup struct { Id int64 `json:"id" xorm:"pk autoincr unique notnull 'id'"` Name string `json:"name" xorm:"notnull"` Description string `json:"description"` models.Common `xorm:"extends"` } type Cluster struct { Id int64 `json:"id" xorm:"pk autoincr unique notnull 'id'"` Name string `json:"name" xorm:"notnull"` ClusterGroup *ClusterGroup `json:"cluster_group"` models.Common `xorm:"extends"` } ``` ## issue When I deleted row from `ClusterGroup` which is referenced by `Cluster`, all query with table `Cluster` were failed if result include the reference-missing rows, error message: `cascade obj is not exist`. Is there any solution for this?
Owner

Did you enabled cache?

Did you enabled cache?
Author

Did you enabled cache?

I suppose I didn't.

> Did you enabled cache? I suppose I didn't.
Author

I hope query result as ClusterGroup=nil when reference missing, instead of return error.

I hope query result as `ClusterGroup=nil` when reference missing, instead of return error.
Owner

Maybe we can add an option to ignore the cascade loading.

Maybe we can add an option to ignore the cascade loading.
lunny added the
kind
proposal
label 2021-06-12 08:38:52 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1772
No description provided.