Skip to content

Unnecessary relations in factories after bob upgrade #620

@VRmnv

Description

@VRmnv

I recently updated my bob version from 0.34.2 to 0.42.0. Afterwards i found my tests failing. All failing tests have similar issue of bob, creating unnecessary relations. Factory code example:

f.NewTask(
	factory.TaskMods.WithNewExporters(1),
).CreateOrFail(t.Context(), t, bob.Debug(db))

Table task connects to exporter via m2m relation:
task -> task_exporter_id -> exporter

Relationships described in bob config:

relationships:
  task:
    - name: "task_to_exporters"
      sides:
        - from: "task"
          to: "task_exporter_id"
          columns: [ [ uuid, task_id ] ]
        - from: "task_exporter_id"
          to: "exporter"
          columns: [ [ exporter_id, id ] ]

I expect that this code will create 1 task and 1 exporter associated with this task. However, in log i see creation of multiple tasks:

INSERT INTO "task" AS "task" ...
INSERT INTO "exporter" ...
INSERT INTO "task" AS "task" ...
INSERT INTO "task_exporter_id" AS "task_exporter_id"...
INSERT INTO "exporter" AS "exporter"...
UPDATE "task_exporter_id" AS "task_exporter_id" SET...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions