Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Minor (?) bug with self-joining and includeFrom

$
0
0
Hi Isomorphic,

I always had a problem preparing testcases with FK-resolution based on BuiltInDS.

Now I found out why. See this testcase (using v10.0p_2015-05-13):

Most minimal java code for a testcase:
Code:

package com.smartgwt.sample.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.widgets.grid.ListGrid;

public class BuiltInDS implements EntryPoint {

        public void onModuleLoad() {
                ListGrid boundList = new ListGrid(DataSource.get("employees"));
                boundList.setWidth("75%");
                boundList.setAutoFetchData(true);
                boundList.draw();
        }
}

employees.ds.xml (new field ReportsToName):
Code:

<DataSource
    ID="employees"
    serverType="sql"
    tableName="employeeTable"
    recordName="employee"
    testFileName="/examples/shared/ds/test_data/employees.data.xml"
    titleField="Name"
>
    <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"  required="true"
              foreignKey="employees.EmployeeId"  rootValue="1" detail="true" />
        <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>
</DataSource>

SQL generated:
Code:

SELECT COUNT(*) FROM employeeTable WHERE ('1'='1') AND employeeTable.ReportsTo = employeeTable.EmployeeId
Add following attribute to .ds.xml-field ReportsToName: includeVia="ReportsTo"
SQL generated:
Code:

SELECT COUNT(*) FROM employeeTable a0, employeeTable WHERE ('1'='1') AND employeeTable.ReportsTo = a0.EmployeeId
I think this is necessary because the table the foreignKey points to is the same, but I don't think that one should need the includeVia.

But this is only a minor bug and I can generate more easy generate testcases with FKs now.

Best regards
Blama

Viewing all articles
Browse latest Browse all 4756

Trending Articles