Repository navigation
Closed
Labels
Description
Issue Description
With an entity using @column("simple-array") the creation statement will fail in SAP HANA.
Expected Behavior
Creation statement works, arrays in a single string work as well
Actual Behavior
Error: sql syntax error: incorrect syntax near "text": line 1 col 511 (at pos 511)
2020-10-28T14:43:40.591+0000 [APP/PROC/WEB/0] OUT at /home/vcap/app/node_modules/typeorm/driver/sap/SapQueryRunner.js (/home/vcap/app/node_modules/typeorm/driver/sap/SapQueryRunner.js:183:74)
2020-10-28T14:43:40.591+0000 [APP/PROC/WEB/0] OUT at /home/vcap/app/node_modules/typeorm/node_modules/tslib/tslib.js.step (/home/vcap/app/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
2020-10-28T14:43:40.591+0000 [APP/PROC/WEB/0] OUT at /home/vcap/app/node_modules/typeorm/node_modules/tslib/tslib.js (/home/vcap/app/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
2020-10-28T14:43:40.591+0000 [APP/PROC/WEB/0] OUT at /home/vcap/app/node_modules/typeorm/node_modules/tslib/tslib.js.fulfilled (/home/vcap/app/node_modules/typeorm/node_modules/tslib/tslib.js:112:62)
Steps to Reproduce
@Entity()
export class AwesomeEntity {
@PrimaryColumn()
id: string;
@Column("simple-array")
myField: string[] = [];
constructor(data: Partial<AwesomeEntity>) {
Object.assign(this, data);
}
}My Environment
I'm using nestjs.
| Dependency | Version |
|---|---|
| Operating System | MacOS 10.14.6 (18G6032) |
| Node.js version | v10.20.1 |
| Typescript version | [email protected] |
| TypeORM version | [email protected] |
(I've checked the latest version of typeorm as well)
Additional Context
Issue seems to be here
typeorm/src/driver/sap/SapDriver.ts
Line 447 in a5eb946
| return "text"; |
Relevant Database Driver(s)
-
aurora-data-api -
aurora-data-api-pg -
better-sqlite3 -
cockroachdb -
cordova -
expo -
mongodb -
mysql -
nativescript -
oracle -
postgres -
react-native -
sap -
sqlite -
sqlite-abstract -
sqljs -
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time, and I know how to start.
- Yes, I have the time, but I don't know how to start. I would need guidance.
- No, I don't have the time, although I believe I could do it if I had the time...
- No, I don't have the time and I wouldn't even know how to start.
I can try, I think I know where the issue is, but I'm not familiar with how internally the project works, specially regarding build and testing.
Activity
imnotjames commentedon Nov 1, 2020
Yeah - you did find where the issue is. I suggest finding a field type that works better and switching it over - also adding some tests somewhere if you can.
Once you open a PR there is automated CI that will run the tests & tell you if something didn't work as expected.
sickmartian commentedon Nov 2, 2020
I had monkey patched it to
nvarcharand it's working, but I'm guessing the column length might be a bit of a surprise for someone, so it might not be ideal.I just checked the docs and seems like
textis valid, but for column store tables only. Also it seems the default has been changed from row store to column at some point, and thecreateTableSqlinSapQueryRunneris using the default, so this might be happening because I'm using an old version (which would be weird, as I'm using it from SAP Cloud Platform), I will check more in depth when able and maybe give it a go with a column store and see what happens, might actually not be an issue in the end.fix: remove references to `text` column type in SAP Driver (typeorm#6985
fix: remove references to `shorttext` and `alphanum` column type in S…
sickmartian commentedon Nov 16, 2020
Okay, so, I think this is a feature disguised as a small fix... it goes like this:
I was unable to reproduce the issue in a HXE docker image, even with a newer version ( 2.00.045.00.20200121.1 ) than the one docker-compose has, it only happens in SAP HANA Service or in SAP HANA Cloud, so it's not an old version issue, they are just not the same exact thing. Here is the documentation of the things not supported in SAP HANA Cloud, from what I can see it impacts field types
text,alphanumandshorttext.It's a PITA to check it out but for anyone interested the steps are:
devspace automatically created{ "schema": "typeorm" }can help with manual checks{ "skip": false, "name": "sap", "type": "sap", "host": "<some uuid>.hana.trial-eu10.hanacloud.ondemand.com", "port": 443, "username": "<schema from previous step>", "password": "<password>", "logging": true, "schema": "<schema from previous step>", "encrypt": true, "extra": { "sslValidateCertificate": false } }Additionally you might need:
The timeout is because the non-local DB is obviously slower to return data, and the max is because
take-multiple-tkwould fail otherwise (even in HXE) as it's doing a ton of connections and hdb-pool doesn't deal with passing above the default very well.I made a patch here but not a pull request as I don't think it's merge-worthy. Ended up replacing
textfornclobinstead ofnvarcharbecause of the column length issue, and ended up eliminating field types, which is alarming as there might be code using it there and tables already created this way...Testing this version against HXE is working fine, testing against SAP HANA Cloud is (ultra slow and...) failing, in particular there is a way to create a cache table and the cache is returning a different number of results than expected, it's actually going to the real DB table from the logs, instead of hitting the cache table, I think the cache is just expiring because of the DB being remote and taking longer, I will have to check this out more in depth, also the query builder select text is expecting an specific SQL statement and here we are adding the schema before the table, I think both are easy fixes but the most important thing is the approach to this...
All in all, as this is working against HXE it might not be adequate to patch the driver to only support the subset of things supported in SAP HANA Cloud, the options I see are:
SapDriverand overriding some methodsSapDriverto deal with this, as a configuration attribute@imnotjames I'm going to need way more guidance before proceeding with any of these options, otherwise the patch contains two commits, second one is a version compatible with both HXE and SAP HANA Cloud but with the less support possible, first one just removes TEXT as that's the most critical part and everything kind of works fine at runtime for SAP HANA Cloud as well until a non-available type is explicitly used.
sagentac commentedon May 24, 2024
Hi,
we are facing the same issue. Is there any update on any progress or plans for addressing this issue?
Any information would be greatly appreciated.
alumni commentedon Mar 4, 2025
HANA Cloud removed the
TEXTdata type AFAIR. The data type should beNCLOB, so that it works both on-premise and in cloud.As a workaround, declaring the column as
ncloband using a transformer would work identically to how TypeORM normally would handle this.