Skip to Content
0
Jan 30, 2020 at 10:56 AM

Error in custom logic of CAP: " invalid column name: COUNT"

1135 Views Last edit Jan 30, 2020 at 11:10 AM 2 rev

I am creating an OData service using CAP.

Target is to get the below URL working.

<CF Trail>/analytics-output/ApplicationUsage?select=application,count&$orderby=count

Here is the service model.

    @readonly
    entity ApplicationUsage {
        key application : String(80);
            count       : Decimal;
            timestamp   : DateTime null;
    }

Here is the implementation in custom logic (js file)

    srv.on('READ', 'ApplicationUsage', (req) => {
        selectQuery = 'select ' +
            'key app.application as application, ' +
            'COUNT(app.application) as count : Decimal ' +
            'from cis.fiorianalytics.Actions as action ' +
            'inner join cis.fiorianalytics.Apps as app on action.applicationID = app.id '+
            'group by app.application';

        let query = cds.parse.cql(selectQuery);
        //Append the timestamp WHERE and ORDERBY condition
        query.SELECT.orderBy = req.query.SELECT.orderBy;
        query.SELECT.where = req.query.SELECT.where;
        return cds.run(query);
    });

This works great in local deployment and I get the data. But it fails to work in HANA (after deployment to trial CF).

I end up getting not so useful error as below in the browser.

<error xmlns="http://docs.oasis-open.org/odata/ns/metadata">
<code>500</code>
<message>Internal Server Error</message>
</error>

When I look into the 'Log' on SCP, I see below line which seems to be related.

Any help is greatly appreciated.

Attachments

cap-error.png (34.0 kB)