cancel
Showing results for 
Search instead for 
Did you mean: 

Can't save data with '@' in key column

JakobRuf
Explorer
0 Kudos

Hi experts,

I am currently developing a node-based CAP-application with HANA as database. I have created a table via CDS that manages the assignment between user and a warehouse. It all ran fine but recently some problems started coming up when trying to change data in the table when the user ID column contains the '@' sign (which in productive scenarios is always because we are using email addresses for the user ID). In my test cases, the data manipulation ran fine when omitting the '@' sign (which is not really a possibility without bigger restructuring)

When trying to update the data, the request basically times out. It does not matter if I update the data programmatically via CAP, via direct OData calls to the table entity or directly in HANA DB Explorer (no difference between change via Open Data or INSERT/UPDATE statement)

My dependencies in package.json look as follows:

  "dependencies": {
    "@sap/approuter": "~10.2.0",
    "@sap/audit-logging": "~5.0.0",
    "@sap/cds": "~5.0.4",
    "@sap/cds-odata-v2-adapter-proxy": "~1.6.1",
    "@sap/hana-client": "~2.7.26",
    "@sap/xsenv": "~3.1.0",
    "@sap/xssec": "~3.1.2",
    "express": "~4.17.1",
    "node-rest-server": "~2.0.0",
    "passport": "~0.4.1"
  },
  "devDependencies": {
    "@sap/hdi-deploy": "~4",
    "@sap/html5-app-deployer": "2.0.0"
  },

The table is defined as seen below

@cds.autoexpose
entity User2ForwardingAgent {
    key UserId            : String(100);
    key ForwardingAgentId : String(20);
        User              : Association to one UserMaster
                                on $self.UserId = User.Username;
        ForwardingAgent   : Association to one ForwardingAgent
                                on $self.ForwardingAgentId = ForwardingAgent.ForwardingAgentId;
}


// related tables for completeness:
entity UserMaster : managed {
    key Username         : String(100);
        Email            : String(100);
        Firstname        : String(30);
        Lastname         : String(30);
        Language         : String(2);
        UserType         : String(1) enum {
            T = 'customerintenal';
            W = 'warehouse';
            A = 'forwardingagent';
            P = 'PowerUser';
        };
        IsActive         : Boolean;
        Warehouses       : Association to many User2Warehouse
                                on $self.Username = Warehouses.UserId;
        ForwardingAgents : Association to many User2ForwardingAgent
                                on $self.Username = ForwardingAgents.UserId;
        whses            : String;
        agents           : String;
}

entity ForwardingAgent {
    key ForwardingAgentId : String(20);
        Description       : String(100);
        City              : String(40);
        Country           : String(50);
        Street            : String(100);
        Users             : Association to many User2ForwardingAgent
                                on $self.ForwardingAgentId = Users.ForwardingAgentId;
        Warehouses        : Association to many Warehouse2ForwardingAgent
                                on $self.ForwardingAgentId = Warehouses.ForwardingAgentId;
}

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor

Your used CAP version is very old. I would suggest you try an upgrade.

JakobRuf
Explorer
0 Kudos

Hi Gregor,

thank you for the answer! I actually had the same idea after asking the question so I updated cds and hdi-deploy (because I thought if it's a DB problem, maybe the deployer is at fault) and apparently one of them was the culprit and so far it is working

Thank you!

Jakob

Answers (0)