Announcement

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

    summaryRow problem

    SmartClient Version: v13.0p_2024-11-19/Enterprise Development Only (built 2024-11-19)
    and
    SmartClient Version: v13.1p_2024-11-19/Enterprise Development Only (built 2024-11-19)

    Hello, please try this modified sample in the showcase (fetchOperationFS):

    Code:
    <DataSource isSampleDS="true"
        ID="supplyItem"
        serverType="sql"
        tableName="supplyItem"
        titleField="itemName"
        testFileName="/examples/shared/ds/test_data/supplyItem.data.xml"
        dbImportFileName="/examples/shared/ds/test_data/supplyItemLarge.data.xml"
    >
        <fields>
            <field name="itemID" type="sequence" hidden="true" primaryKey="true"/>
            <field name="itemName" type="text" title="Item" length="128" required="true"/>
            <field name="SKU" type="text" title="SKU" length="10" required="true"/>
            <field name="description" type="text" title="Description" length="2000"/>
            <field name="category" type="text" title="Category" length="128" required="true"
                   foreignKey="supplyCategory.categoryName"/>
            <field name="units" type="enum" title="Units" length="5">
                <valueMap>
                    <value>Roll</value>
                    <value>Ea</value>
                    <value>Pkt</value>
                    <value>Set</value>
                    <value>Tube</value>
                    <value>Pad</value>
                    <value>Ream</value>
                    <value>Tin</value>
                    <value>Bag</value>
                    <value>Ctn</value>
                    <value>Box</value>
                </valueMap>
            </field>
            <field name="unitCost" type="float" title="Unit Cost" required="true">
                <validators>
                    <validator type="floatRange" min="0" errorMessage="Please enter a valid (positive) cost"/>
                    <validator type="floatPrecision" precision="2" errorMessage="The maximum allowed precision is 2"/>
                </validators>
            </field>
            <field name="inStock" type="boolean" title="In Stock"/>
            <field name="nextShipment" type="date" title="Next Shipment"/>
        </fields>
           <operationBindings>
           <operationBinding operationType="fetch" operationId="summary">
                <summaryFunctions>
                    <unitCost>sum</unitCost>
                    <itemName>count</itemName>
                </summaryFunctions>
            </operationBinding>
        </operationBindings>
    </DataSource>
    Code:
    isc.ListGrid.create({
        ID: "countryList",
        height:"100%", width:"100%", alternateRecordStyles:true,
        dataSource: supplyItem,
        showFilterEditor:true,
        showGridSummary: true,
        summaryRowDataSource: supplyItem,
        summaryRowFetchRequestProperties: {
            operationId: "summary"
        },
        autoFetchData:true
    })
    then try to filter by typing "add" in the itemName column, you'll see this error:

    Code:
    === 2024-11-20 09:47:12,285 [ec-8] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36': Safari with Accept-Encoding header
    === 2024-11-20 09:47:12,294 [ec-8] INFO IDACall - Performing 1 operation(s) [UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36]
    === 2024-11-20 09:47:12,295 [ec-8] INFO DSRequest - Executing countryList->supplyItem.fetch rows: 0->75 with
    criteria: {itemName:"add"}
    === 2024-11-20 09:47:12,298 [ec-8] INFO SQL - Executing SQL query on 'HSQLDB': SELECT COUNT(*) FROM supplyItem WHERE (LOWER(supplyItem.itemName) LIKE '%add%' ESCAPE '\' AND supplyItem.itemName IS NOT NULL)
    === 2024-11-20 09:47:12,313 [ec-2] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36': Safari with Accept-Encoding header
    === 2024-11-20 09:47:12,318 [ec-2] INFO IDACall - Performing 1 operation(s) [UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36]
    === 2024-11-20 09:47:12,318 [ec-2] INFO DSRequest - Executing countryList_summaryRow->supplyItem.fetch[summary] rows: 0->1 with
    criteria: {itemName:"add"}
    === 2024-11-20 09:47:12,319 [ec-2] INFO SQLWhereClause - empty condition
    === 2024-11-20 09:47:12,320 [ec-2] INFO SQL - 521: Executing query on 'HSQLDB': SELECT LIMIT 0 1 COUNT(supplyItem.itemName) AS itemName, SUM(supplyItem.unitCost) AS unitCost FROM supplyItem WHERE ('1'='1') HAVING (LOWER(COUNT(supplyItem.itemName)) LIKE '%add%' ESCAPE '\' AND COUNT(supplyItem.itemName) IS NOT NULL)
    === 2024-11-20 09:47:12,326 [ec-2] WARN RequestContext - dsRequest.execute() failed:
    java.sql.SQLSyntaxErrorException: incompatible data type in operation
        at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
        at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
        at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
        at org.hsqldb.jdbc.JDBCStatement.executeQuery(Unknown Source)
        at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
        at com.isomorphic.sql.SQLDataSource.executeWindowedSelect(SQLDataSource.java:2813)
        at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1893)
        at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1727)
        at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:522)
        at com.isomorphic.sql.SQLDataSource.executeFetch(SQLDataSource.java:458)
        at com.isomorphic.datasource.DataSource.execute(DataSource.java:2934)
        at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:658)
        at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:555)
        at com.isomorphic.application.AppBase.execute(AppBase.java:498)
        at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:3493)
        at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:230)
        at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:187)
        at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:152)
        at com.isomorphic.servlet.IDACall._processRequest(IDACall.java:123)
        at com.isomorphic.servlet.IDACall.doPost(IDACall.java:79)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:555)
        at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:178)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
        at com.isomorphic.servlet.URIRegexFilter.ignore(URIRegexFilter.java:566)
        at com.isomorphic.servlet.URIRegexFilter.ignore(URIRegexFilter.java:561)
        at com.isomorphic.servlet.URIRegexFilter.matchedRule(URIRegexFilter.java:524)
        at com.isomorphic.servlet.URIRegexFilter._doFilter(URIRegexFilter.java:377)
        at com.isomorphic.servlet.BaseFilter.doFilter(BaseFilter.java:91)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
        at com.isomorphic.js.JSSyntaxScannerFilter._doFilter(JSSyntaxScannerFilter.java:262)
        at com.isomorphic.servlet.BaseFilter.doFilter(BaseFilter.java:91)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
        at com.isomorphic.servlet.CompressionFilter._doFilter(CompressionFilter.java:263)
        at com.isomorphic.servlet.BaseFilter.doFilter(BaseFilter.java:91)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
        at com.isomorphic.servlet.VersionedURLFilter._doFilter(VersionedURLFilter.java:83)
        at com.isomorphic.servlet.BaseFilter.doFilter(BaseFilter.java:91)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:396)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:937)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.hsqldb.HsqlException: incompatible data type in operation
        at org.hsqldb.error.Error.error(Unknown Source)
        at org.hsqldb.error.Error.error(Unknown Source)
        at org.hsqldb.FunctionSQL.resolveTypes(Unknown Source)
        at org.hsqldb.ExpressionLike.resolveTypes(Unknown Source)
        at org.hsqldb.ExpressionLogical.resolveTypes(Unknown Source)
        at org.hsqldb.QuerySpecification.resolveExpressionTypes(Unknown Source)
        at org.hsqldb.QuerySpecification.resolveTypesPartOne(Unknown Source)
        at org.hsqldb.QueryExpression.resolve(Unknown Source)
        at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
        at org.hsqldb.ParserCommand.compilePart(Unknown Source)
        at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
        at org.hsqldb.Session.executeDirectStatement(Unknown Source)
        at org.hsqldb.Session.execute(Unknown Source)
        ... 61 more
    === 2024-11-20 09:47:12,331 [ec-8] INFO SQL - 520: Executing query on 'HSQLDB': SELECT LIMIT 0 75 supplyItem.itemID, supplyItem.itemName, supplyItem.SKU, supplyItem.description, supplyItem.category, supplyItem.units, supplyItem.unitCost, supplyItem.inStock, supplyItem.nextShipment FROM supplyItem WHERE (LOWER(supplyItem.itemName) LIKE '%add%' ESCAPE '\' AND supplyItem.itemName IS NOT NULL)
    === 2024-11-20 09:47:12,346 [ec-2] INFO Compression - /isomorphic/IDACall: 171 -> 150
    === 2024-11-20 09:47:12,369 [ec-8] INFO DSResponse - DSResponse: List with 46 items
    === 2024-11-20 09:47:12,373 [ec-8] INFO Compression - /isomorphic/IDACall: 8,0k -> 2,1k
    I actually see a similar error in my application, using Oracle DB.

    #2
    Also, if you use as summaryFunctions:

    Code:
    <summaryFunctions>
        <unitCost>count</unitCost>
    </summaryFunctions>
    and try to filter the unitCost column by typing 9, you'll see this query for the summary row:

    Code:
     SELECT LIMIT 0 1  COUNT(supplyItem.unitCost) AS unitCost FROM supplyItem WHERE ('1'='1') HAVING (COUNT(supplyItem.unitCost)=9)
    which isn't the expected query

    Comment


      #3
      Thanks for letting us know Claudio. We'll take a look

      Comment


        #4
        Hi Claudio, we'll look into your SQL syntax error for your first post, but regarding your second post, that is actually the expected behavior - see the Server Summaries overview, specifically the "Criteria" header.

        https://smartclient.com/smartclient-...erverSummaries

        Criteria could be intended to be applied either to the summarized value or pre-summarization, but if you work through a variety of examples, we think you'll find that more often than not, developers mean to apply the value post-summarization (your example is highly synthetic). That is also the only way the client-side filtering can work on a summarized dataset, since client-side filtering will not have the values for summarized fields.

        You can reverse this on a per-OperationBinding basis, as covered in the docs.

        Comment


          #5
          Hello, thanks for the heads up about applyCriteriaBeforeAggregation.

          It seems to me that the reasoning flows smoothly with examples like the ones present here: https://www-demos.smartclient.com/sm...ummariesFolder, where the server summaries feature is used to produce a dataset displayed in a grid.

          However, my case seems fundamentally different: the summary, for me, is a row that presents data related to the records in the grid, and when I apply a filter, I expect it to be applied to the grid's data.

          Maybe it's easier to explain myself with a sample. Please modify the summariesBasic sample like this:

          Code:
          isc.ListGrid.create({
              ID:"orderItemList",
              dataSource:"basicAggregation_orderItem",
              width:500,
              height:300,
              showFilterEditor:true,
              showGridSummary: true,
              summaryRowDataSource: "basicAggregation_orderItem",
              summaryRowFetchRequestProperties: {
                  operationId: "sum"
              },
              autoFetchData:true,
              canEdit:false,
              canRemoveRecords:false,
              fields: [
                  { name: "orderCustomerName", hidden: "true", title: "Customer name" },
                  { name: "itemDescription" },
                  { name: "unitPrice"},
                  { name: "pk", title: "Count" }
              ]
          });
          Code:
          <DataSource
                  ID="basicAggregation_orderItem"
                  serverType="sql"
                  tableName="aggregation_orderItem"
                  testFileName="/examples/shared/ds/serverExamples/test_data/aggregation_orderItem.data.xml"
          >
              <fields>
                  <field name="pk" type="sequence" primaryKey="true" hidden="false" />
                  <field name="orderID" type="integer" canEdit="false" foreignKey="basicAggregation_order.orderID"/>
                  <field name="orderCustomerName" type="text" canEdit="false" includeFrom="basicAggregation_order.customerName"/>
                  <field name="itemDescription" type="text" />
                  <field name="quantity" type="integer" />
                  <field name="unitPrice" type="float" />
              </fields>
              <operationBindings>
                  <operationBinding operationType="fetch" operationId="sum" applyCriteriaBeforeAggregation="true">
                      <summaryFunctions>
                          <unitPrice>sum</unitPrice>
                      </summaryFunctions>
                  </operationBinding>
              </operationBindings>
          </DataSource>
          Here, the behaviour I expect as a user is that filtering for unitPrice less than 12 will show records with a unit price < 12, and the summary will display the sum of those prices lower than 12.

          Since I've used this older default behaviour in the past, would it be possible to have a global setting like applyCriteriaBeforeAggregation in the server.properties file?

          Also, note that if you try this sample in the latest 13.1 version with applyCriteriaBeforeAggregation="true", the summary row doesn't show after filtering, even though the summary record is returned. This works correctly in version 13.0.

          Comment


            #6
            You're correct that this is a case where criteria should be applied pre-grouping, especially since client-side filtering never applies to the summaryRow. However, it's still the case that post-grouping filtering is more common, so we don't want a system-wide flag, especially since that could break built-in features that assume normal filtering.

            For now, just set opBinding.applyCriteriaBeforeGrouping for this use case.

            We plan to add a flag dsRequest.filterBeforeGrouping which will can be used to dynamically control this, so we can set it for summaryRow requests. However, this is low priority and probably won't happen for a while.

            Comment


              #7
              Originally posted by Isomorphic View Post
              You're correct that this is a case where criteria should be applied pre-grouping, especially since client-side filtering never applies to the summaryRow. However, it's still the case that post-grouping filtering is more common, so we don't want a system-wide flag, especially since that could break built-in features that assume normal filtering.
              ok, I didn't though of that
              Originally posted by Isomorphic View Post
              We plan to add a flag dsRequest.filterBeforeGrouping which will can be used to dynamically control this, so we can set it for summaryRow requests. However, this is low priority and probably won't happen for a while.
              Ok, so, if and when you'll add that flag, the pre-grouping will become the default for this use case?

              PS: should I open a new thread for the 13.1 bug:
              Originally posted by claudiobosticco View Post
              Hello, thanks for the heads up about applyCriteriaBeforeAggregation.
              Also, note that if you try this sample in the latest 13.1 version with applyCriteriaBeforeAggregation="true", the summary row doesn't show after filtering, even though the summary record is returned. This works correctly in version 13.0.
              ?

              Comment


                #8
                Ok, so, if and when you'll add that flag, the pre-grouping will become the default for this use case?
                Yes, the flag will be automatically set for the dsRequest issued for the summaryRow, since the summaryRow is supposed to represent aggregate values.

                No need for another thread, we'll check on the problem with the summaryRow not appearing.

                Comment

                Working...
                X