loopbackio / loopbackio/loopback-next

Cassandra UDT not being persisted in cassandra database

Open
#8,331 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

Describe the bug

The code converts Json object in request payload to string for UDT. We debugged and found the issue with Cassandra.prototype.create function in loopback-connector-cassandra/lib/cassandra.js. Please provide the solution for the issue.

Logs
Payload object:
{
  id: 'c',
  name: 'otlsgy4',
  phone: '88774622572',
  address: {
    street: 'Sahastradhara Road',
    city: 'Dehradun',
    state_or_province: 'Uttarakhand',
    postal_code: '248001',
    country: 'India'
  }
}


Insert Query by loopback:
INSERT INTO "hotels"("id","name","phone","address") VALUES(?,?,?,?) [
  'c',
  'otlsgy4',
  '88774622572',
  '{"street":"Sahastradhara Road","city":"Dehradun","state_or_province":"Uttarakhand","postal_code":"248001","country":"India"}'
]

Expected Result: 
INSERT INTO "hotels"("id","name","phone","address") VALUES(?,?,?,?) [
  'c',
  'otlsgy4',
  '88774622572',
  {"street":"Sahastradhara Road","city":"Dehradun","state_or_province":"Uttarakhand","postal_code":"248001","country":"India"}
]
Additional information

No response

Reproduction

https://github.com/nishankpathak/cassandrademo

@dhmlau

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in loopback-connector-cassandra/lib/cassandra.js at Cassandra.prototype.create and reproduce the issue using the linked cassandrademo example. Trace how the address UDT is bound in the INSERT parameters; done means the UDT is persisted as Cassandra structured data rather than a JSON string.

Written by the indexing model from the issue text.

Assessment

Tech stack
cassandra, typescript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.