Ticket #1756 (closed defect: invalid)

Opened 15 months ago

Last modified 13 months ago

Application level cascade and self-referencing relation

Reported by: mikovali Owned by: romanb
Priority: minor Milestone: 1.0.7
Component: Relations Version: 1.1.0-BETA1
Severity: Keywords: delete cascade self-referencing relation
Cc: Has Test: no
Status: Pending Core Response Has Patch: no

Description

My schema:

Category:
    columns:
        title:
            type: string(255)
            notnull: true
        parent_id:
            type: integer
    relations:
        Children:
            class: Category
            local: id
            foreign: parent_id
            type: many
            foreignAlias: Parent
            foreignType: one
            cascade: [delete]

But when deleting parent row that has children I get a constraint violation.

I'm not sure, but I think the problem is that the parent row is being deleted before the children (Or and once, because they are in the same table).

The query that failed was something like this:

DELETE FROM category WHERE id = 1 OR id = 2 ...

So I'm guessing there should be at least two queries (one for children and then one for parent).

(I've tried both 1.0 series and 1.1)

Sorry for not trying to write a patch or smth but really busy time before Christmas unfortunately.

Change History

Changed 14 months ago by jwage

  • milestone changed from 1.1.0-BETA2 to 1.0.7

Changed 14 months ago by jwage

Could you provide a failing test case?

Changed 13 months ago by jwage

  • status changed from new to closed
  • resolution set to invalid

I believe your schema is incorrect. Try the following. If it still does not work then re-open the ticket.

Category:
    columns:
        title:
            type: string(255)
            notnull: true
        parent_id:
            type: integer
    relations:
        Children:
            class: Category
            local: id
            foreign: parent_id
            type: many
            autoComplete: false
        Parent:
            class: Category
            local: parent_id
            foreign: id
            type: one
            autoComplete: false
            cascade: [delete]
Note: See TracTickets for help on using tickets.