Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects versions: 1.5
    • Fix versions: None
    • Labels:
      None

      Description

      The find method in BaseModel generates wrong SQL when querying for list items of list attributes and possibly in other cases too.

      Repro:
      1. Create a user defined list with some items
      2. Add an attribute of type list to any object type and use the list created in step 1 as source.
      3. Add a UI bundle to change the list value on that object type
      4. Edit/Create an object of that type, chose any value from the list
      5. Save the object

      Expected:
      The list attribute is persisted.
      Actual:
      The list attribute is not persisted. If the attribute is required, the following error message is shown: "Value 158 for Category [category] is invalid." Where 158 is the item_id and category is the attribute.

      The reason is that ca_list_items::find() doesn't return anything when querying for the list item (by item_id and list_id). The actual bug is in the BaseModel->find() method. The $pa_values array is flattened in a weird way, resulting in an unwanted where clause.

      I have attached a screenshot that shows $pa_values and $vm_value when adding the where clause for type_id. $vm_value should be null in this case but is array(0 => 0) instead.

      The generated SQL looks like
      SELECT * FROM ca_list_items WHERE (deleted = 0) AND ((item_id = 158) and (list_id = 43) and (type_id IN (0)))
      but should be
      SELECT * FROM ca_list_items WHERE (deleted = 0) AND ((item_id = 158) and (list_id = 43)

        Attachments

          Activity

            People

            • Assignee:
              Former user (Inactive)
              Reporter:
              Jasper
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: