Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    .ds.xml-generated criteria bug ("and" instead of "or")

    Hi Isomorphic,

    please see this v10.1p_2016-04-08 BuiltInDS-based testcase, where the generated SQL-WHERE is not as expected.
    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle(".ds.xml-generated criteria problem" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            ListGrid animalsLG = new ListGrid(DataSource.get("animals"));
            animalsLG.setAutoFetchData(false);
            animalsLG.fetchData(new AdvancedCriteria("commonName", OperatorId.ISTARTS_WITH, "A"));
            w.addItem(animalsLG);
            w.show();
        }
    }
    animals.ds.xml:
    Code:
    <DataSource
        ID="animals"
        serverType="sql"
        tableName="animals"
        testFileName="animals.data.xml"
    >
        <fields>
            <field name="commonName"      title="Animal"             type="text"/>
            <field name="scientificName"  title="Scientific Name"    type="text"  primaryKey="true"  required="true"/>
            <field name="lifeSpan"        title="Life Span"          type="integer"/>
            <field name="status"          title="Endangered Status"  type="text">
                <valueMap>
                    <value>Threatened</value>
                    <value>Endangered</value>
                    <value>Not Endangered</value>
                    <value>Not currently listed</value>
                    <value>May become threatened</value>
                    <value>Protected</value>
                </valueMap>
            </field>
            <field name="diet"            title="Diet"               type="text"/>
            <field name="information"     title="Interesting Facts"  type="text"  length="1000"/>
            <field name="picture"         title="Picture"            type="image" detail="true"
                   imageURLPrefix="/isomorphic/system/reference/inlineExamples/tiles/images/"/>
        </fields>
        <operationBindings>
                <operationBinding operationType="fetch">
                    <criteria _constructor="AdvancedCriteria" operator="or">
                        <criteria fieldName="lifeSpan" operator="lessOrEqual" value="50" />
                        <criteria fieldName="diet" operator="equals" value="Herbivore" />
                    </criteria>
                </operationBinding>
            </operationBindings>
    </DataSource>
    Server log:​
    Code:
    SELECT   LIMIT 0 75 animals.commonName,
        animals.scientificName,
        animals.lifeSpan,
        animals.status,
        animals.diet,
        animals.information,
        animals.picture
         FROM animals
        WHERE((animals.lifeSpan <= 50
        OR animals.lifeSpan     IS NULL)
        AND(LOWER(animals.commonName) LIKE LOWER('a%') ESCAPE '\'
        AND animals.commonName IS NOT NULL)
        AND(animals.diet        = 'Herbivore'
        AND animals.diet       IS NOT NULL))
    My expectation would be:
    Code:
    LOWER(animals.commonName) LIKE LOWER('a%') --client criteria
    AND --server criteria
    (lifeSpan <= 50
    OR --operator="or"
    animals.diet = 'Herbivore')
    Best regards
    Blama

    #2
    Hi Isomorphic,

    sorry, it has to be "<criterion ..." for the inner tags in the operationBinding, but this does not change the outcome.

    Best regards
    Blama

    Comment


      #3
      This is fixed and is available in nightly builds since Apr 18.

      Comment


        #4
        Hi Isomorphic,

        great, thank you. I'll retest asap.
        Could you also answer this question in a related area (not urgent, still on 5.1p)?

        Thank you & Best regards
        Blama

        Comment

        Working...
        X