Skip to content

Commit

Permalink
Merge pull request #37 from kiko240/feature/add-type-hana_tinyint
Browse files Browse the repository at this point in the history
Add hana.tinyint type mapping to number.
  • Loading branch information
HeneryHawk authored Jul 29, 2022
2 parents 6d0a25b + 5c11f5b commit 9ca4aaf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/types/base.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ export abstract class BaseType<O = unknown> {
): morph.PropertySignatureStructure {
let fieldName = name;
if (fieldName.includes("/")) fieldName = `"${fieldName}"`;
if (element.canBeNull || element.type === Type.Association) fieldName = `${fieldName}?`;
if (element.canBeNull || element.type === Type.Association)
fieldName = `${fieldName}?`;

let fieldType = "unknown";
if (element.enum) {
Expand All @@ -161,7 +162,6 @@ export abstract class BaseType<O = unknown> {
fieldType = this.cdsElementToType(element, types, prefix);
}


return {
kind: morph.StructureKind.PropertySignature,
name: fieldName,
Expand Down Expand Up @@ -390,6 +390,10 @@ export abstract class BaseType<O = unknown> {
case Type.LargeBinary:
result = "Buffer";
break;

case Type.HanaTinyint:
result = "number";
break;
}

return result;
Expand Down
1 change: 1 addition & 0 deletions src/utils/cds.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export enum Type {
LargeString = "cds.LargeString",
LargeBinary = "cds.LargeBinary",
User = "User",
HanaTinyint = "cds.hana.TINYINT",
}

export enum Kind {
Expand Down
13 changes: 7 additions & 6 deletions test/srv/service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@ service CatalogService @(path : '/browse') {
@readonly
entity Books as
select from my.Books {
* ,
author.name as author
*,
author.name as author,
virtual 1 as isStockVisible : hana.TINYINT
}
excluding {
createdBy,
modifiedBy
}

actions {
action addRating(stars : Integer);
action addRating(stars : Integer);
function getViewsCount() returns Integer;
}

function getBooks(author : my.Authors:ID) returns array of Books;
action unboudAction(simpleParameter : String, arrayParameter : array of arrayParameterType, typedParameter : typedParameterType) returns ActionReturnType;
function getBooks(author : my.Authors:ID) returns array of Books;
action unboudAction(simpleParameter : String, arrayParameter : array of arrayParameterType, typedParameter : typedParameterType) returns ActionReturnType;

@requires_ : 'authenticated-user'
action submitOrder(book : Books:ID, amount : Integer);
action submitOrder(book : Books:ID, amount : Integer);


type arrayParameterType : {
Expand Down

0 comments on commit 9ca4aaf

Please sign in to comment.