cancel
Showing results for 
Search instead for 
Did you mean: 

Using Draft Enabled Entity for creating new entities in CDS

virajpatel
Member
0 Kudos

I am referring to URL:

https://cap.cloud.sap/docs/java/fiori-drafts

Please get back to me on the following feedback:

Hi experts,

We are using the Node.js CDS library for our application. We have the following Sample entities,

Draft-enabled Books entity

namespace sap.bookshop;
using {
  cuid,
  managed
} from '@sap/cds/common';

entity Books : cuid, managed {
    name            : String;
    releaseDate     : Timestamp;
    description     : String;
}
annotate Books with @odata.draft.enabled;

index.cds for OData (For demo purpose)

using {sap.bookshop.Books}'../books';
service BookService @(path: '/bookstore') {


  entity PublishedBooks as select from Books {
    releaseDate,
    count (
      ID
    ) as numberOfBooks : Integer
  }
  group by
    releaseDate;
}

we are getting the following error when we try to GET data from PublishedBooks entity,

http://localhost:8181/browse/PublishedBooks

error: [.@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-commons/logging/LoggerFacade.js] [2021-03-23T14:03:10.570Z | ERROR | 1058866]: { [Error: SQLITE_ERROR: no such column: active.undefined] errno: 1, code: 'SQLITE_ERROR', query: 'SELECT active.releaseDate, active.numberOfBooks, true AS "IsActiveEntity", false AS "HasActiveEntity", null AS "DraftAdministrativeData_DraftUUID", CASE WHEN DRAFTS.DRAFTADMINISTRATIVEDATA_DRAFTUUID IS NOT NULL THEN TRUE ELSE FALSE END AS "HasDraftEntity" FROM BookService_PublishedBooks active LEFT JOIN BookService_PublishedBooks_drafts drafts ON active.undefined = drafts.undefined LIMIT 1000' }

It also gives same error when we use the HANA database.

dependency versions we are using are as below,

@sap/cds: 4.6.4

@sap/cds-runtime: 2.9.6

View Entire Topic
AndreM
Explorer
0 Kudos

Hi david.kunz2 ,

I have tried to put the annotation in front of the service-projection-entity:

service frontendService @(path: '/frontend') { 
  @odata.draft.enabled
  entity Names as projection on test.MyFrontendData excluding { ID };
}

But I still get the error described above when I try to call the service without fiori-frontend.

André

david_kunz2
Advisor
Advisor
0 Kudos

Hi Andre,

Does the error still happen when you upgrade to the latest version of @sap/cds?