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

SQL query generated with AdvancedCriteria uses a completely different value for field

$
0
0
Version : v9.0p_2013-09-12

I have a datasource with following definition :
Code:

<DataSource
        tableName="vlogbookmaster"
        ID="vlogbookmaster"
        serverType="sql"
>
        <fields>
                <field name="actiondetailid" type="integer"></field>
                <field name="assetname" length="35" type="text"></field>
                <field name="periodfrom" type="datetime" ></field>
                <field name="username" length="50" type="text"></field>
                <field name="remarks" length="200" type="text"></field>
                <field name="alerts" type="integer"></field>
                <field name="partybranchid" type="integer"></field>
        </fields>
        <operationBindings>
   
    <operationBinding operationType="fetch">
      <customSQL>
            SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause and partybranchid=$session.partybranchid ORDER BY $defaultOrderClause
            </customSQL>
    </operationBinding>
 
  </operationBindings>
</DataSource>

The field partybranchid is of type bigint in our postgresql database ( version 9.1)
I am using this datasource in a simple listgrid with showFilterEditor=true. When the listgrid is initially populated, it sends a simple criteria object which generates a query like :
Code:

=== 2013-11-27 16:26:08,253 [c-25] INFO  SQLDataSource - [builtinApplication.vlogbookmaster_fetch] Performing fetch operation with
        criteria: {partybranchid:-2500000000}        values: {partybranchid:-2500000000}
=== 2013-11-27 16:26:08,253 [c-25] INFO  SQLDataSource - [builtinApplication.vlogbookmaster_fetch] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
=== 2013-11-27 16:26:08,254 [c-25] DEBUG SQLDataSource - [builtinApplication.vlogbookmaster_fetch] Executing row count query: SELECT COUNT(*) FROM $defaultTableClause WHERE $defaultWhereClause
=== 2013-11-27 16:26:08,254 [c-25] DEBUG SQLDataSource - [builtinApplication.vlogbookmaster_fetch] Eval'd row count query: SELECT COUNT(*) FROM vlogbookmaster WHERE (LOWER(CAST(vlogbookmaster.partybranchid AS varchar(50))) LIKE '%-2500000000%')
=== 2013-11-27 16:26:08,255 [c-25] DEBUG SQLDriver - [builtinApplication.vlogbookmaster_fetch] About to execute SQL query in 'USCProduction-localhost' using connection '1222743196'
=== 2013-11-27 16:26:08,255 [c-25] INFO  SQLDriver - [builtinApplication.vlogbookmaster_fetch] Executing SQL query on 'USCProduction-localhost': SELECT COUNT(*) FROM vlogbookmaster WHERE (LOWER(CAST(vlogbookmaster.partybranchid AS varchar(50))) LIKE '%-2500000000%')
=== 2013-11-27 16:26:08,328 [c-25] DEBUG SQLDataSource - [builtinApplication.vlogbookmaster_fetch] Using SQL Limit query
=== 2013-11-27 16:26:08,328 [c-25] DEBUG SQLDataSource - [builtinApplication.vlogbookmaster_fetch] SQL windowed select rows 0->75, result size 75. Query: SELECT vlogbookmaster.actiondetailid, vlogbookmaster.alerts, vlogbookmaster.assetname, vlogbookmaster.partybranchid, vlogbookmaster.periodfrom, vlogbookmaster.remarks, vlogbookmaster.username FROM vlogbookmaster WHERE (LOWER(CAST(vlogbookmaster.partybranchid AS varchar(50))) LIKE '%-2500000000%') OFFSET 0 LIMIT 75
=== 2013-11-27 16:26:08,373 [c-25] INFO  DSResponse - [builtinApplication.vlogbookmaster_fetch] DSResponse: List with 75 items

but when I try to filter data using the date filter shown for the periodfrom field, an adnavcedcriteria is generated and sent to the server like :
Code:

=== 2013-11-27 16:05:33,650 [ec-9] INFO  SQLDataSource - [builtinApplication.vlogbookmaster_fetch] Performing fetch operation with
        criteria: {criteria:[{value:-2500000000,fieldName:"partybranchid",operator:"equals"},{criteria:[{criteria:[{value:new Date(1380623640000),fieldName:"periodfrom",operator:"greaterOrEqual"},{value:new Date(1385576999000),fieldName:"periodfrom",operator:"lessOrEqual"}],operator:"and"}],operator:"and"}],operator:"and",_constructor:"AdvancedCriteria"}        values: {criteria:[{value:-2500000000,fieldName:"partybranchid",operator:"equals"},{criteria:[{criteria:[{value:new Date(1380623640000),fieldName:"periodfrom",operator:"greaterOrEqual"},{value:new Date(1385576999000),fieldName:"periodfrom",operator:"lessOrEqual"}],operator:"and"}],operator:"and"}],operator:"and",_constructor:"AdvancedCriteria"}

If you notice the value for partybranchid in the advanced criteria above is value:-2500000000,fieldName:"partybranchid".
But the actual query generated with this advanced criteria is :
Code:

=== 2013-11-27 16:05:33,651 [ec-9] DEBUG SQLDataSource - [builtinApplication.vlogbookmaster_fetch] Eval'd row count query: SELECT COUNT(*) FROM vlogbookmaster WHERE ((vlogbookmaster.partybranchid = 1794967296 AND vlogbookmaster.partybranchid IS NOT NULL) AND (((vlogbookmaster.periodfrom >= '2013-10-01 16:04:00' AND vlogbookmaster.periodfrom IS NOT NULL) AND (vlogbookmaster.periodfrom <= '2013-11-27 23:59:59' OR vlogbookmaster.periodfrom IS NULL))))
If you notice the value for partybranchid field in the generated query has changed to 1794967296. This is my problem.

Please advise?

Viewing all articles
Browse latest Browse all 4756

Trending Articles