Changeset 3933


Ignore:
Timestamp:
Nov 7, 2007, 6:01:32 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #655

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/mysql-queries.xml

    r3675 r3933  
    151151  </query>
    152152
     153  <query id="UPDATE_PROPERTY_FILTER" type="SQL">
     154    <sql>
     155      UPDATE IGNORE [PropertyFilters]
     156      SET [property] = :newProperty
     157      WHERE [property] = :oldProperty
     158    </sql>
     159    <description>
     160      An SQL query that changes the property for all PropertyFilters
     161      which filters on a given property. It must ignore any filter that 
     162      causes a duplicate key violation if a filter with the new
     163      property already exists for any context.
     164    </description>
     165  </query>
     166
     167
    153168</predefined-queries>
  • trunk/src/core/common-queries.xml

    r3871 r3933  
    27212721  <query id="UPDATE_PROPERTY_FILTER" type="SQL">
    27222722    <sql>
    2723       UPDATE [PropertyFilters]
     2723      UPDATE [PropertyFilters] 
    27242724      SET [property] = :newProperty
    27252725      WHERE [property] = :oldProperty
     2726      AND [context_id] NOT IN
     2727      (
     2728         SELECT [context_id]
     2729         FROM [PropertyFilters]
     2730         WHERE [property] = :newProperty
     2731      )
    27262732    </sql>
    27272733    <description>
    27282734      An SQL query that changes the property for all PropertyFilters
    2729       with a given value.
     2735      which filters on a given property. It must ignore any filter that 
     2736      causes a duplicate key violation if a filter with the new
     2737      property already exists for any context.
    27302738    </description>
    27312739  </query>
  • trunk/src/core/net/sf/basedb/core/Update.java

    r3871 r3933  
    16471647      tx = HibernateUtil.newTransaction(session);
    16481648 
    1649       // Change property values
     1649      // Change property values -- query must ignore filters
     1650      // that may cause duplicate filters on the same property
    16501651      org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(session,
    16511652          "UPDATE_PROPERTY_FILTER");
    16521653      /*
    1653         UPDATE PropertyFilters pf
    1654         SET pf.property = :newProperty
    1655         WHERE pf.property = :oldProperty
    1656        */
     1654        UPDATE [PropertyFilters]
     1655        SET [property] = :newProperty
     1656        WHERE [property] = :oldProperty
     1657        AND [context_id] NOT IN
     1658        (
     1659           SELECT [context_id]
     1660           FROM [PropertyFilters]
     1661           WHERE [property] = :newProperty
     1662        )
     1663      */
    16571664      query.setString("oldProperty", "guiContexts.itemType");
    16581665      query.setString("newProperty", "$ctx.itemType");
    16591666      HibernateUtil.executeUpdate(query);
    16601667 
     1668      //Delete any remaining filter with the old property
     1669      query = HibernateUtil.getPredefinedSQLQuery(session,
     1670        "DELETE_PROPERTY_FILTER");
     1671      /*
     1672        DELETE FROM [PropertyFilters]
     1673        WHERE [property] = :property
     1674      */
     1675      query.setString("property", "guiContexts.itemType");
     1676      HibernateUtil.executeUpdate(query);
     1677     
    16611678      // Update the schema version number
    16621679      setSchemaVersion(session, schemaVersion);
Note: See TracChangeset for help on using the changeset viewer.