Announcement

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

    12.0p problem with outputs and criteria on a field not in outputs (can't reproduce, yet)

    Hi Isomorphic,

    recently (~1 month ago) I found a problem with outputs and criteria on a field that is not in outputs. It wasn't important to us back then, but I wanted to create a testcase anyway.
    I did so now (in v12.0p_2019-01-17), but did not succeed so far, so no need to look into it closely for you right now. I just wanted to ask if you can imagine something here could not work together (a join for a field not in outputs but in criteria not getting put into the "list of fields necessary for a query" and therefore no join is generated and therefore no criteria on that field are possible ('1' = '1' in the SQL-statement)).

    This is my testcase so far (not showing an issue):

    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.Criterion;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.SortSpecifier;
    import com.smartgwt.client.types.DSOperationType;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.SortDirection;
    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.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
    
        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();
    
            mainLayout.addMember(new IButton("Recreate Fetch normal (OK)") {
                {
                    setWidth(300);
                    addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            recreate("normal");
                        }
                    });
                }
            });
    
            mainLayout.addMember(new IButton("Recreate Fetch outputs clientside (OK)") {
                {
                    setWidth(300);
                    addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            recreate("ocs");
                        }
                    });
                }
            });
    
            mainLayout.addMember(new IButton("Recreate Fetch outputs serverside (OK here, problem for me)") {
                {
                    setWidth(300);
                    addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            recreate("oss");
                        }
                    });
                }
            });
    
            mainLayout.addMember(new IButton("Recreate Fetch no crit outputs serverside (OK)") {
                {
                    setWidth(300);
                    addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            recreate("ossNoCriteria");
                        }
                    });
                }
            });
    
            mainLayout.draw();
        }
    
        private void recreate(String mode) {
            Window w = new Window();
            w.setKeepInParentRect(true);
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("outputs also stops criteria from working" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid employeesGrid = new ListGrid(DataSource.get("employees"));
    
            employeesGrid.setHeight100();
            employeesGrid.setAutoFetchData(false);
    
            ListGridField employeeId = new ListGridField("EmployeeId");
    
            ListGridField name = new ListGridField("Name");
    
            ListGridField gender = new ListGridField("Gender");
    
            ListGridField job = new ListGridField("Job");
    
            ListGridField reportsTo = new ListGridField("ReportsTo");
    
            ListGridField reportsToName = new ListGridField("ReportsToName");
    
            employeesGrid.setFields(employeeId, name, gender, job, reportsTo, reportsToName);
            employeesGrid.setSort(new SortSpecifier[] { new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
    
            AdvancedCriteria reportsToAC = new AdvancedCriteria(new Criterion(reportsToName.getName(), OperatorId.EQUALS, "Charles Madigen"));
    
            DSRequest restrictedOutputsCS = new DSRequest(DSOperationType.FETCH);
            restrictedOutputsCS.setOutputs("EmployeeId, Name, Gender, Job");
    
            DSRequest fetchWithOutputs = new DSRequest(DSOperationType.FETCH);
            fetchWithOutputs.setOperationId("fetchWithOutputs");
    
            if ("normal".equals(mode))
                employeesGrid.fetchData(reportsToAC);
            else if ("ocs".equals(mode))
                employeesGrid.fetchData(reportsToAC, null, restrictedOutputsCS);
            else if ("oss".equals(mode))
                employeesGrid.fetchData(reportsToAC, null, fetchWithOutputs);
            else if ("ossNoCriteria".equals(mode))
                employeesGrid.fetchData(null, null, fetchWithOutputs);
            w.addItem(employeesGrid);
            w.show();
        }
    }
    employees.ds.xml:
    Code:
    <DataSource
        ID="employees"
        serverType="sql"
        tableName="employeeTable"
        recordName="employee"
        testFileName="/examples/shared/ds/test_data/employees.data.xml"
        titleField="Name"
        useAnsiJoins="true"
    >
        <fields>
            <field name="userOrder"       title="userOrder"       type="integer"  canEdit="false"    hidden="true"/>
            <field name="Name"            title="Name"            type="text"     length="128"/>
            <field name="EmployeeId"      title="Employee ID"     type="integer"  primaryKey="true"  required="true"/>
            <field name="ReportsTo"       title="Manager"         type="integer"  foreignKey="employees.EmployeeId" joinType="outer" />
            <field name="ReportsToName"   includeFrom="employees.Name" />
            <field name="Job"             title="Title"           type="text"     length="128"/>
            <field name="Email"           title="Email"           type="text"     length="128"/>
            <field name="EmployeeType"    title="Employee Type"   type="text"     length="40"/>
            <field name="EmployeeStatus"  title="Status"          type="text"     length="40"/>
            <field name="Salary"          title="Salary"          type="float"/>
            <field name="OrgUnit"         title="Org Unit"        type="text"     length="128"/>
            <field name="Gender"          title="Gender"          type="text"     length="7">
                <valueMap>
                    <value>male</value>
                    <value>female</value>
                </valueMap>
            </field>
            <field name="MaritalStatus"   title="Marital Status"  type="text"     length="10">
                <valueMap>
                    <value>married</value>
                    <value>single</value>
                </valueMap>
            </field>
        </fields>
       <operationBindings>
            <operationBinding operationType="fetch" />
            <operationBinding operationType="fetch" operationId="fetchWithOutputs" outputs="EmployeeId, Name, Gender, Job" />
        </operationBindings>
    </DataSource>
    Best regards
    Blama

    #2
    @all, this thread most likely shows the issue.

    Comment

    Working...
    X