Skip to content

SAP HANA Driver using text column type for simple-array and simple-enum which is unsupported #6985

Closed

Description

@sickmartian

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

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

  1. imnotjames commented on Nov 1, 2020

    @imnotjames
    Contributor

    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.

  2. sickmartian commented on Nov 2, 2020

    @sickmartian
    Author

    I had monkey patched it to nvarchar and 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 text is valid, but for column store tables only. Also it seems the default has been changed from row store to column at some point, and the createTableSql in SapQueryRunner is 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.

  3. sickmartian commented on Nov 16, 2020

    @sickmartian
    Author

    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, alphanum and shorttext.

    It's a PITA to check it out but for anyone interested the steps are:

    1. setup a free trial account in SAP Cloud Platform ( https://developers.sap.com/tutorials/hcp-create-trial-account.html )
    2. enter the SAP Cloud Foundry dev space automatically created
    3. create a SAP HANA Cloud service instance (a HANA Service would also work, but it's being deprecated, creation takes a while)
    4. set it up to allow connections from outside the cloud platform (clicking the edit button, DB will restart, it takes a while)
    5. create a HANA/schema service using the service marketplace, using a JSON like { "schema": "typeorm" } can help with manual checks
    6. add a service key for the HANA/schema service instance, then view it's details to get the typeorm config values, use them to set up ormconfig.json like this:
    {
        "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:

    "pool": {
           "requestTimeout": 20000,
           "max": 50000
    }

    The timeout is because the non-local DB is obviously slower to return data, and the max is because take-multiple-tk would 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 text for nclob instead of nvarchar because 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:

    • A new driver that accounts for the differences, extending SapDriver and overriding some methods
    • Add a parameter in SapDriver to deal with this, as a configuration attribute
    • Just reject the whole thing and mention in the docs that typeorm doesn't work against the SAP Cloud DB services and link to the mentioned help page as to why that is.

    @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.

  4. sagentac commented on May 24, 2024

    @sagentac
    Contributor

    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.

  5. alumni commented on Mar 4, 2025

    @alumni
    Collaborator

    HANA Cloud removed the TEXT data type AFAIR. The data type should be NCLOB, so that it works both on-premise and in cloud.

    As a workaround, declaring the column as nclob and using a transformer would work identically to how TypeORM normally would handle this.

  6. added
    good first issue
    and removed on Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions