Skip to content

Commit

Permalink
feat: cds.Vector support for the HANAService (#442)
Browse files Browse the repository at this point in the history
Co-authored-by: Dr. David A. Kunz <[email protected]>
  • Loading branch information
BobdenOs and David-Kunz authored Feb 28, 2024
1 parent 38722fe commit 1057a13
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,9 @@ class HANAService extends SQLService {
LargeBinary: () => `NVARCHAR(2147483647)`,
Binary: () => `NVARCHAR(2147483647)`,
array: () => `NVARCHAR(2147483647)`,
Vector: () => `NVARCHAR(2147483647)`,

// Javascript types
// JavaScript types
string: () => `NVARCHAR(2147483647)`,
number: () => `DOUBLE`
}
Expand All @@ -947,6 +948,7 @@ class HANAService extends SQLService {
// Not encoded string with CESU-8 or some UTF-8 except a surrogate pair at "base64_decode" function
Binary: e => `HEXTOBIN(${e})`,
Boolean: e => `CASE WHEN ${e} = 'true' THEN TRUE WHEN ${e} = 'false' THEN FALSE END`,
Vector: e => `TO_REAL_VECTOR(${e})`,
}

static OutputConverters = {
Expand All @@ -957,6 +959,7 @@ class HANAService extends SQLService {
Time: e => `to_char(${e}, 'HH24:MI:SS')`,
DateTime: e => `to_char(${e}, 'YYYY-MM-DD"T"HH24:MI:SS"Z"')`,
Timestamp: e => `to_char(${e}, 'YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"')`,
Vector: e => `TO_NVARCHAR(${e})`,
}
}

Expand Down
11 changes: 9 additions & 2 deletions test/compliance/resources/db/basic/literals.cds
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ entity array {
}

entity binaries {
binary : Binary;
largebinary : LargeBinary;
binary : Binary;
largebinary : LargeBinary;
}


/* Excluded from the tests until fully supported
entity vectors {
vector : Vector;
}
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

module.exports = [
{
vector: null,
},
{
vector: '[0.1,0.2,0.3]',
},
]

0 comments on commit 1057a13

Please sign in to comment.