This repository was archived by the owner on Jul 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 40
This repository was archived by the owner on Jul 14, 2023. It is now read-only.
Virtual column does not exist #204
Copy link
Copy link
Closed
Description
I am facing an issue with a virtual column.
Given
- this simple data model using a virtual field
rating
(./db/schema.cds
):
using {
cuid,
managed
} from '@sap/cds/common';
namespace sap.cap.ideas;
entity Ideas : cuid, managed {
@mandatory
title : String(50);
@mandatory
description : String(250);
virtual rating : Decimal;
}
- this service (
./srv/ideas-service.cds
):
using {sap.cap.ideas as ideas} from '../db/schema';
service IdeasService {
entity Ideas as projection on ideas.Ideas;
}
- these fiori annotations (
./app/ideas/fiori-service.cds
):
using IdeasService from '../../srv/ideas-service';
annotate IdeasService.Ideas with @(
odata.draft.enabled,
UI.HeaderInfo : {
TypeName : '{i18n>Ideas.headerInfo.typeName}',
TypeNamePlural : '{i18n>Ideas.headerInfo.typeNamePlural}',
Title : {
$Type : 'UI.DataField',
Value : title
},
Description : {
$Type : 'UI.DataField',
Value : description
}
},
UI.SelectionFields : [
title,
description,
rating
],
UI.LineItem : [
{
$Type : 'UI.DataField',
Value : title,
![@UI.Importance] : #High
},
{
$Type : 'UI.DataField',
Value : description,
![@UI.Importance] : #Medium
},
{
$Type : 'UI.DataField',
Value : rating,
![@UI.Importance] : #Medium
},
{
$Type : 'UI.DataField',
Value : createdAt,
![@UI.Importance] : #Low
},
{
$Type : 'UI.DataField',
Value : createdBy,
![@UI.Importance] : #Low
},
{
$Type : 'UI.DataField',
Value : modifiedAt,
![@UI.Importance] : #Low
},
{
$Type : 'UI.DataField',
Value : modifiedBy,
![@UI.Importance] : #Low
}
],
UI.Identification : [
{
$Type : 'UI.DataField',
Value : title,
},
{
$Type : 'UI.DataField',
Value : description,
},
],
UI.FieldGroup #Managed : {Data : [
{Value : createdBy},
{Value : createdAt},
{Value : modifiedBy},
{Value : modifiedAt}
]},
UI.Facets : [{
ID : 'managed',
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Ideas.facet.managed}',
Target : '@UI.FieldGroup#Managed'
}]
) {
@UI.Hidden
ID;
@title : '{i18n>Ideas.element.title}'
title;
@title : '{i18n>Ideas.element.rating}'
rating;
@title : '{i18n>Ideas.element.description}'
@UI.MultiLineText
description;
}
-
this config
.cdsrc.json
:
{
"features": {
"fiori_preview": true
},
"requires": {
"db": {
"kind": "postgres"
},
"postgres": {
"impl": "cds-pg",
"model": [
"app"
]
},
"cap-ratings": {
"kind": "odata",
"credentials": {
"path": "/ratings",
"requestTimeout": 30000
}
}
},
"migrations": {
"db": {
"schema": {
"default": "public",
"clone": "_cdsdbm_clone",
"reference": "_cdsdbm_ref"
},
"deploy": {
"tmpFile": "tmp/_autodeploy.json",
"undeployFile": "db/undeploy.json"
}
}
}
}
default-env.json
{
"VCAP_SERVICES": {
"postgres": [
{
"name": "postgres",
"label": "postgres",
"tags": [
"postgres"
],
"credentials": {
"host": "postgres-svc",
"port": "5432",
"user": "***",
"password": "***",
"database": "cap",
"schema": "public"
}
}
],
"cap-ratings": [{
"name": "cap-ratings",
"label": "cap-ratings",
"tags": [
"cap-ratings"
],
"credentials": {
"url": "http://cap-ratings-svc:5005"
}
}]
},
"DEBUG": "ideas-service"
}
I am running npx cds-dbm deploy
to deploy the schema to the database.
Now when running the fiori app preview and creating a new entity I am receiving an error:
[cds] - POST /ideas/$batch
[cds] - > NEW Ideas
[cds] - error: column "rating" does not exist
at Parser.parseErrorMessage (/workspaces/cap-ideas/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/workspaces/cap-ideas/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/workspaces/cap-ideas/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/workspaces/cap-ideas/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:290:12)
at readableAddChunk (internal/streams/readable.js:265:9)
at Socket.Readable.push (internal/streams/readable.js:204:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
at TCP.callbackTrampoline (internal/async_hooks.js:131:17) {
length: 107,
severity: 'ERROR',
code: '42703',
detail: undefined,
hint: undefined,
position: '176',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '3504',
routine: 'errorMissingColumn',
id: '1515520',
level: 'ERROR',
timestamp: 1632136335162
}
Any ideas what could be the root cause and why the service tries to persist the virtual column to the database throwing an error?
Running the service with sqlite everything works as expected.
cds -v
node ➜ /workspaces/cap-ideas $ cds -v
@sap/cds: 5.3.2
@sap/cds-compiler: 2.5.2
@sap/cds-dk: 4.4.2
@sap/cds-foss: 2.3.1
@sap/cds-odata-v2-adapter-proxy: 1.7.11
Node.js: v14.17.6
cap-ideas: 0.1.0
Thanks in advance,
Pascal
Metadata
Metadata
Assignees
Labels
No labels