loopbackio / loopbackio/loopback-next
Cassandra UDT not being persisted in cassandra database
- 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
```shell
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
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