Skip to Content
0
Mar 19, 2019 at 12:24 PM

PLEASE ! CD&S View and Associations Error

582 Views Last edit Mar 20, 2019 at 06:31 PM 4 rev

Hello everyone,

I have this issue right now, thanks in advance for any guidence.

File: Movies.cds:

namespace dhana;
type int: Integer;
type decimal: Decimal(13,3);

entity Movies{
	key MOVIEID: Integer;
	ratings: association to many Ratings on ratings.MOVIEID = MOVIEID; 
        // using $self got Syntax error: unexpected token "$SELF"
	TITLE: longString;
	GENRES: longString;
}

entity Ratings{
	key USERID: Integer;
	key MOVIEID: Integer;
	movies: association[1] to Movies on movies.MOVIEID = MOVIEID;
        // also tried only: association to Movies;
	RATING: Decimal(13,3);
	TIMESTAMP: Integer;
}



File: my-service.cds 
using dhana.Movies as MoviesTable from '../db/data-model';
using dhana.Ratings as RatingsTable from '../db/data-model';

service CatalogService {
  entity Movies @(
	title: '{i18n>moviesService}',
	Capabilities:{
		InsertRestrictions: {Insertable:false},
		UpdateRestrictions: {Updatable: false},
		DeleteRestrictions: {Deletable: false}
	}
  ) as projection on MoviesTable;
  
  entity Ratings @(
	title: '{i18n>moviesService}',
	Capabilities:{
		InsertRestrictions: {Insertable:false},
		UpdateRestrictions: {Updatable: false},
		DeleteRestrictions: {Deletable: false}
	}
  ) as projection on RatingsTable;  
}



Error:

Error: column ambiguously defined: T62FD280C30B9823D99FA1E3649EF293B_MOVIEID:

Another testings:

/* Also tried : */
ratings: association[0..*] to Ratings on ratings.MOVIEID = MOVIEID;
ratings: association[*] to Ratings on ratings.MOVIEID = MOVIEID;
ratings: association to many Ratings on ratings.MOVIEID = MOVIEID;
ratings: association to Ratings;

Another testing was creating a view just like in documentation example: 

define view MovieSample select from Movies{
   key MOVIEID,
   TITLE,
   ratings
} group by MOVIEID, TITLE;

And finally, tried changing column name "MOVIEID" in "Ratings" table to "MOVIE_ID",
buy again, same "ambiguously column".

The expected result :

http://myhana:x90x/Catalogs/Movies?$expand=ratings

{
value: [
{
    MOVIEID: 1,
    TITLE: "Toy Story (1995)",
    GENRES: "a|b|c",
    ratings: [
       { 1: ...}, { 2: ...}, { 3: ...}
    ]
}]
}

Please some help!

Thanks!

xOCh