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

INSERT vs UPDATE for a Vertex Type using JSON payload and @cat Behavior for Remote API #2060

Open
ShakeIQAdmin opened this issue Mar 12, 2025 · 0 comments

Comments

@ShakeIQAdmin
Copy link

ShakeIQAdmin commented Mar 12, 2025

Starting in 25.x release I am experiencing an issue with Vertex records coming back with @cat = "d" and not properly converting into a Result object.

I was able to create a small example and able to reproduce the issue. I start from a clean DB.

I have a Vertex type in the DB called Tenant. The schema in the JSON format is below.

When I insert a new record I use the following command:

INSERT INTO Tenant CONTENT {"tenantStatus":"Active","empowerTenantId":"01958b6a-7484-7970-a461-62a5c4502e26","tenantName":"ShakeIQ, Inc.","@type":"Tenant","empowerType":"empower.tenant.Tenant","@cat":"v","_auditMetadata":{"createdDate":1741800764557,"createdByUser":"service-account-empower-platform-admin","lastModifiedDate":1741800764557,"lastModifiedByUser":"service-account-empower-platform-admin"},"id":"01958b6a-7484-7970-a461-62a5c4502e26","tenantCode":"shakeiq","primaryTenant":false,"tenantDomain":"platform.local.shakeiq.ai"}

The record is properly added and I can see it in the studio and it has @type = "Tenant" and @cat = "v".

When I run an HTTP API command in the same way it is executed by the RemoteDatabase class:

curl -X POST http://localhost:2480/api/v1/query/local_shakeiq_empower_platform -d '{"language":"SQL","command":"SELECT * FROM Tenant","serializer":"record"}' -H "Content-Type: application/json" --user root:xxxxxxxxxx
I get a JSON with @cat = "d" as follows:

{
  "user": "root",
  "version": "25.3.1 (build c591d9e53ba796d35d0658197ea3b96fad200c2c/1741370755387/main)",
  "serverName": "Arcade_DB1",
  "result": [
    {
      "@rid": "#7:0",
      "@type": "Tenant",
      "@cat": "d",
      "tenantStatus": "Active",
      "empowerTenantId": "01958b6a-7484-7970-a461-62a5c4502e26",
      "tenantName": "ShakeIQ, Inc.",
      "empowerType": "empower.tenant.Tenant",
      "_auditMetadata": {
        "createdDate": 1741800764557,
        "createdByUser": "service-account-empower-platform-admin",
        "lastModifiedDate": 1741800764557,
        "lastModifiedByUser": "service-account-empower-platform-admin"
      },
      "id": "01958b6a-7484-7970-a461-62a5c4502e26",
      "tenantCode": "shakeiq",
      "primaryTenant": false,
      "tenantDomain": "platform.local.shakeiq.ai"
    }
  ]
}]

If I use no serializer the result is the same.

If I use serializer = "graph" I get the correct JSON for my record with "@cat": "v" as follows:

{
  "user": "root",
  "version": "25.3.1 (build c591d9e53ba796d35d0658197ea3b96fad200c2c/1741370755387/main)",
  "serverName": "Arcade_DB1",
  "result": {
    "vertices": [
      {
        "p": {
          "tenantStatus": "Active",
          "empowerTenantId": "01958b6a-7484-7970-a461-62a5c4502e26",
          "tenantName": "ShakeIQ, Inc.",
          "empowerType": "empower.tenant.Tenant",
          "_auditMetadata": {
            "createdDate": 1741800764557,
            "createdByUser": "service-account-empower-platform-admin",
            "lastModifiedDate": 1741800764557,
            "lastModifiedByUser": "service-account-empower-platform-admin"
          },
          "id": "01958b6a-7484-7970-a461-62a5c4502e26",
          "tenantCode": "shakeiq",
          "primaryTenant": false,
          "tenantDomain": "platform.local.shakeiq.ai",
          "@cat": "v",
          "@type": "Tenant",
          "@rid": "#7:0"
        },
        "r": "#7:0",
        "t": "Tenant",
        "i": 0,
        "o": 0
      }
    ],
    "edges": []
  }
}

At this point if I use the RemoteDatabase API the Result isn't properly classified as a Vertex and my app fails.

Interestingly though, if the INSERT command is immediately followed by an UPDATE with MERGE command the HTTP API return correctly.

After I execute the following in the studio:

UPDATE #7:0 MERGE {"tenantStatus":"Active","empowerTenantId":"01958b6a-7484-7970-a461-62a5c4502e26","tenantName":"ShakeIQ, Inc.","@type":"Tenant","empowerType":"empower.tenant.Tenant","@cat":"v","_auditMetadata":{"createdDate":1741800764557,"createdByUser":"service-account-empower-platform-admin","lastModifiedDate":1741800764580,"lastModifiedByUser":"service-account-empower-platform-admin"},"id":"01958b6a-7484-7970-a461-62a5c4502e26","tenantCode":"shakeiq","primaryTenant":true,"tenantDomain":"platform.local.shakeiq.ai"} RETURN AFTER @rid

which updates a single field (primaryTenant is set to true) the following is the result of the API call with correct "@cat": "v":

{
  "user": "root",
  "version": "25.3.1 (build c591d9e53ba796d35d0658197ea3b96fad200c2c/1741370755387/main)",
  "serverName": "Arcade_DB1",
  "result": [
    {
      "@rid": "#7:0",
      "@type": "Tenant",
      "@cat": "v",
      "tenantStatus": "Active",
      "empowerTenantId": "01958b6a-7484-7970-a461-62a5c4502e26",
      "tenantName": "ShakeIQ, Inc.",
      "empowerType": "empower.tenant.Tenant",
      "_auditMetadata": {
        "createdDate": 1741800764557,
        "createdByUser": "service-account-empower-platform-admin",
        "lastModifiedDate": 1741800764580,
        "lastModifiedByUser": "service-account-empower-platform-admin"
      },
      "id": "01958b6a-7484-7970-a461-62a5c4502e26",
      "tenantCode": "shakeiq",
      "primaryTenant": true,
      "tenantDomain": "platform.local.shakeiq.ai"
    }
  ]
}

I didn't test other types of INSERT and UPDATE as I only use JSON.

Schema for type Tenant:

{
  "user": "root",
  "version": "25.3.1 (build c591d9e53ba796d35d0658197ea3b96fad200c2c/1741370755387/main)",
  "serverName": "Arcade_DB1",
  "result": {
    "vertices": [],
    "edges": [],
    "records": [
      {
        "name": "Tenant",
        "type": "vertex",
        "records": 1,
        "buckets": [
          "Tenant_0"
        ],
        "bucketSelectionStrategy": "round-robin",
        "parentTypes": [],
        "properties": [
          {
            "id": 4,
            "name": "empowerTenantId",
            "type": "STRING",
            "mandatory": true,
            "readOnly": true,
            "notNull": true,
            "default": "<DEFAULT_NOT_SET>",
            "custom": {}
          },
          {
            "id": 6,
            "name": "empowerType",
            "type": "STRING",
            "mandatory": true,
            "readOnly": true,
            "notNull": true,
            "default": "<DEFAULT_NOT_SET>",
            "custom": {}
          },
          {
            "id": 7,
            "name": "id",
            "type": "STRING",
            "mandatory": true,
            "readOnly": true,
            "notNull": true,
            "default": "<DEFAULT_NOT_SET>",
            "custom": {}
          },
          {
            "id": 9,
            "name": "primaryTenant",
            "type": "BOOLEAN",
            "default": "<DEFAULT_NOT_SET>",
            "custom": {}
          },
          {
            "id": 8,
            "name": "tenantCode",
            "type": "STRING",
            "mandatory": true,
            "readOnly": true,
            "notNull": true,
            "default": "<DEFAULT_NOT_SET>",
            "custom": {}
          },
          {
            "id": 10,
            "name": "tenantDomain",
            "type": "STRING",
            "default": "<DEFAULT_NOT_SET>",
            "custom": {}
          },
          {
            "id": 5,
            "name": "tenantName",
            "type": "STRING",
            "mandatory": true,
            "notNull": true,
            "default": "<DEFAULT_NOT_SET>",
            "custom": {}
          },
          {
            "id": 3,
            "name": "tenantStatus",
            "type": "STRING",
            "mandatory": true,
            "notNull": true,
            "default": "New",
            "custom": {}
          }
        ],
        "indexes": [
          {
            "name": "Tenant[id]",
            "typeName": "Tenant",
            "type": "LSM_TREE",
            "unique": true,
            "properties": [
              "id"
            ],
            "automatic": true
          },
          {
            "name": "Tenant[tenantCode]",
            "typeName": "Tenant",
            "type": "LSM_TREE",
            "unique": true,
            "properties": [
              "tenantCode"
            ],
            "automatic": true
          },
          {
            "name": "Tenant[tenantDomain]",
            "typeName": "Tenant",
            "type": "LSM_TREE",
            "unique": true,
            "properties": [
              "tenantDomain"
            ],
            "automatic": true
          }
        ],
        "custom": {
          "module": "EmpowerPlatformAdmin"
        }
      }
    ]
  },
  "explain": "+ FETCH DATABASE METADATA TYPES\n+ FILTER ITEMS WHERE \n  name = 'Tenant'\n+ LIMIT ( LIMIT 25)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant