Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cds.Vector support for the HANAService #442

Merged
merged 7 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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})`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also send the binary variant over the wire (less bytes), but I'm fine to just use TO_REAL_VECTOR for now.

}

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]',
},
]