Announcement

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

    Minor (?) bug with self-joining and includeFrom

    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" />
            [B]<field name="ReportsToName" includeFrom="employees.Name" />[/B]
            <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

    #2
    You don't seem to have said what actual bug you are reporting.. ?

    Comment


      #3
      Hi Isomorphic,

      "AND employeeTable.ReportsTo = employeeTable.EmployeeId" in the first SQL statement obviously does not make sense. Also, there is no join or second table.

      The combination of foreignKey on one field and includeFrom on an other field should be enough to create a join, even if the foreignKey points to the same datasource. There should be no need for also includeVia on the includeFrom-field.
      For foreignKeys pointing to a different datasource, this does work like a charm.

      Best regards
      Blama

      Comment


        #4
        We added support for the declaration you described. It also works in more complex scenarios when self-joined included field is included from another DataSource. These changes will be available for download in the next nightly build (2015-08-11).

        Thanks for reporting this!

        Comment

        Working...
        X