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

fix: Support multi byte characters #639

Merged
merged 1 commit into from
May 13, 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
3 changes: 2 additions & 1 deletion hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ class HANAService extends SQLService {
Int64: () => `BIGINT`,
UUID: () => `NVARCHAR(36)`,
Boolean: () => `NVARCHAR(5)`,
String: e => `NVARCHAR(${(e.length || 5000) * 4})`,

Choose a reason for hiding this comment

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

Is this enough for all use-cases? What is the max character that can occur...

LargeString: () => `NVARCHAR(2147483647)`,
LargeBinary: () => `NVARCHAR(2147483647)`,
Binary: () => `NVARCHAR(2147483647)`,
Expand All @@ -1041,7 +1042,7 @@ class HANAService extends SQLService {
// HANA types
'cds.hana.TINYINT': () => 'INT',
'cds.hana.REAL': () => 'DECIMAL',
'cds.hana.CHAR': e => `NVARCHAR(${e.length || 1})`,
'cds.hana.CHAR': e => `NVARCHAR(${(e.length || 1) * 4})`,
'cds.hana.ST_POINT': () => 'NVARCHAR(2147483647)',
'cds.hana.ST_GEOMETRY': () => 'NVARCHAR(2147483647)',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module.exports = [
{
char: 'A',
},
{
char: '대', // Ensure multi byte utf-8 characters also fit into a single character column

Choose a reason for hiding this comment

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

Are we sure, that the character that is not utf-8 converted is still the same, when read from database?
Maybe a test can be added, that INSERTed value is the same then the afterwards selected value...

},
{
large: () => [...new Array(1000)].map(alphabetize).join(''),
},
Expand Down