I used pocketbase v0.11.3

Ok, so let me try to explain my issue.

You need two collections, I will call them A and B. If A and B have the same id there seems to be some weird behavior if:

  1. Make a relation field from A to B and set it to delete if B is deleted
  2. Delete B

Expect: A should be deleted as well What actually happens: A still persists with empty relation

This is the code I used to get the record id to be the same.

func main() {
	app := pocketbase.New()

	app.OnRecordAuthRequest().Add(func(e *core.RecordAuthEvent) error {
		if e.Record.GetString("status") != "" {
			return nil
		collection, err := app.Dao().FindCollectionByNameOrId("status")
		if err != nil {
			return err

		record := models.NewRecord(collection)
		form := forms.NewRecordUpsert(app, record)
			"id":     e.Record.Id,
			"online": true,
			"user":   e.Record.Id,

		if err := form.Submit(); err != nil {
			return err

		e.Record.Set("status", record.Id)
		return app.Dao().SaveRecord(e.Record)

	if err := app.Start(); err != nil {

In this scenario the user collection had a relation field to status and status back to user. If you delete the status the user still persists and vice versa. I set all the relations to delete if they get deleted. Am I doing something wrong here is this just how sqlite works or is this a bug?

And thanks for such a great project and all the hard work.


It is a bug and a remain from the old delete implementation. It should be fixed in v0.11.4 with https://github.com/pocketbase/pocketbase/commit/eb1246fc41a1d6b9ff7309f787c342ee4241d80b.

The tests were also updated to check:

  • self references (eg. A1<->A1)
  • different records references within the same collection (A1->A2)
  • reference to another record with the same id (A1->BA1)
© 2022 pullanswer.com - All rights reserved.