This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » Unwanted DELETE
Unwanted DELETE [message #97648] Mon, 19 April 2010 23:29
drifter  is currently offline drifter
Messages: 2
Registered: March 2009
Junior Member
Hi, friends.
I got a slightly weird problem. At the start, some code:


schema.yml (fragment)
  
colors: 
    _attributes: { isI18N: true, i18nTable: colors_i18n }
    rgb: {type: varchar, size: 12, required: true}
    showInOthers: { type: boolean, required: false, default: false }
    id: ~
colors_i18n:
    id: {type: integer, required: true, primaryKey: true, foreignTable: colors, foreignReference: id, onDelete: CASCADE }
    name: { type: varchar(32), required: false }
    culture: { isCulture: true, type: varchar(7), required: true, primaryKey: true }

products_colors:
    color_id: { type: integer, size: 10, primaryKey: true, required: true, foreignTable: colors, foreignReference: id }
    product_id: { type: integer, size: 10, primaryKey: true, required: true, foreignTable: products, foreignReference: id }

products:
    _attributes: { isI18N: true, i18nTable: products_i18n }
    id: ~
    (..)

orders_products:
    id: ~
    product_id: { type: integer, size: 11, primaryKey: true, required: true, foreignTable: products, foreignReference: id, onDelete: CASCADE, onUpdate: RESTRICT }
    (..)



And now, what happens: when i edit any record from 'colors' table, associated records from 'products_colors' (and one more table) are deleted.


In debug file i got:
(..)
kwi 19 21:34:32 symfony [debug] {sfPropelLogger} prepare: UPDATE colors SET `SHOWINOTHERS`=:p1 WHERE colors.ID=:p2
kwi 19 21:34:32 symfony [debug] {sfPropelLogger} Binding 1 at position :p1 w/ PDO type PDO::PARAM_INT
kwi 19 21:34:32 symfony [debug] {sfPropelLogger} Binding 9 at position :p2 w/ PDO type PDO::PARAM_INT
kwi 19 21:34:32 symfony [debug] {sfPropelLogger} prepare: DELETE FROM orders_products WHERE orders_products.COLOR_ID=:p1
kwi 19 21:34:32 symfony [debug] {sfPropelLogger} Binding 9 at position :p1 w/ PDO type PDO::PARAM_INT
kwi 19 21:34:32 symfony [debug] {sfPropelLogger} prepare: DELETE FROM products_colors WHERE products_colors.COLOR_ID=:p1
(..)


This happens only when i'm using admin panel, not when updating table through pure sql.
What's curious, records are deleted from 'orders_products' as well, but not from 'products' (associations are: colors <> products_colors <> products <> orders_products <> orders) or any other table.
I've removed onDelete and onUpdate from 'products_colors' (and rebuilded), but it did't help.

Any ideas why this happends? or how should i look for a reason?

[Updated on: Tue, 20 April 2010 02:16]

Previous Topic:problem performance with sfDoctrinePager (page display very slow)
Next Topic:throw validator error schema on an embedded form
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software