Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#1208 closed defect (fixed)

SelectFeatures doesn't work if filter is secondary property

Reported by: christinebao Owned by: Christine Bao
Priority: medium Milestone: 2.2
Component: Feature Service Version: 2.1.0
Severity: major Keywords:
Cc: aleck.sun@…, Bruce, Dechant External ID: 1282026

Description

Steps to reproduce:
(The following data names are for explanation and understanding. You can use any data as needed)
Open MapGuide Studio:

  1. Connect to Primary.SDF, assuming it has properties: ID, Name.
  2. Connect to Secondary.SDF, assuming it has properties: ID, Code.
  3. Open Primary.FeatureSource, create a join with following conditions:

Extension name is: Join_Extension
Primary.ID = Secondary.ID
One-to-one

  1. View the extension data in MapGuide FeatureSource editor, and there are properties: ID, Name, SecondaryID, SecondaryCode. Please note the last two, they are from secondary table, and the property name is formatted by "Secondary table name" + "Property name".
  2. Use MapGuide agent to test FeatureService -> SelectFeatures:
    1. If use property from primary table as filter, for example "ID=1", the result is right.
    2. If use property from secondary table as filter, for example "SecondaryID=1", there is an exception: FDO can't execute query.

Attachments (1)

JoinSelect.patch (2.1 KB ) - added by christinebao 15 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by christinebao, 15 years ago

Cc: Bruce Dechant added

Tech diagnosis:

In r3524 Bruce submitted a patch about "Selection against a joined feature source returns an extra feature", which is to fix ticket http://trac.osgeo.org/mapguide/ticket/614.

In this submission, there is a snippet of code added into ServerSelectFeatures.cpp:

            // Search the filter to see if it contains the extension name
            // If the extension name is not found it means that the filter involves attribute(s) only from the primary
            if(NULL != filter)
            {
                FdoString* filterText = filter->ToString();
                if(NULL != filterText)
                {
                    if(NULL == wcsstr(filterText, name.c_str()))
                    {
                        // Add the filter to the query because it only applies to the primary
                        query->SetFilter(filter);
                    }
                }
            }


And name is extension name, which is "Join_Extension" in this case.

The problem is: when property from secondary feature source(such as "SecondaryID") comes here, it doesn't contain extension name, so it's treated as from primary feature source, thus cause an exception.

comment:2 by christinebao, 15 years ago

How to fix:

The purpose of the above comparison

if(NULL == wcsstr(filterText, name.c_str()))


should be whether the filter contains secondary name ("Secondary" in this case), not extension name ("Join_Extension" in this case).

Take "SecondaryID=1" for example, if it contains secondary feature source name, it shouldn't be treated from primary.

by christinebao, 15 years ago

Attachment: JoinSelect.patch added

comment:3 by christinebao, 15 years ago

Attach patch http://trac.osgeo.org/mapguide/attachment/ticket/1208/JoinSelect.patch for fixing this. Please review.

Use MapGuide agent test, and it works.

comment:4 by chrisclaydon, 15 years ago

The patch looks good Christine. Please verify that the code still works for the case that Bruce's submission originally addressed before you check it in.

comment:5 by christinebao, 15 years ago

Resolution: fixed
Status: newclosed

Thanks Chris for reviewing :)

This submission won't break Bruce's fixing. It's submitted.

comment:6 by brucedechant, 15 years ago

Milestone: 2.2

Submitted to trunk - r4446

Note: See TracTickets for help on using tickets.