sirius-tedarik / sirutils

MIT License
0 stars 2 forks source link

Object Problem (@sirutils/seql) #15

Closed siaeyy closed 1 month ago

siaeyy commented 1 month ago

When i try store an object value in database as a string by using seql object:

const insert = await scylla.api.exec`${scylla.api.insert('users', {
    id: '11111111-1111-1111-1111-111111111111',
    username: 'siaeyy'
    age: 99,
    data:  scylla.api.object({
        test: 'test',
    }),
})}`

I get this error:

siaeyy@fedora:~$ bun run test/app.ts
ℹ connected to redis                                                     @sirutils/driver-redis.logger 5:57:49 PM
ℹ connected to scylla                                                   @sirutils/driver-scylla.logger 5:57:49 PM

 ERROR  {                                                                @sirutils/driver-scylla.logger 5:57:49 PM
  "name": "@sirutils/core.lazy-unexpected",
  "message": "catch missused",
  "cause": [
    "@sirutils/core.capsule",
    "@sirutils/driver-scylla.driver#exec",
    "@sirutils/core.create-actions",
    "@sirutils/driver-scylla.plugin"
  ],
  "data": [
    {
      "coordinator": "<ip>",
      "query": "INSERT INTO users (id, username, age, data) VALUES (?, ?, ?, ?)"
    }
  ],
  "timestamp": 1726239469525,
  "originalLine": 2,
  "originalColumn": 1747
}

If i set the data property's value to a string, it works @giveerr

siaeyy commented 1 month ago

Problem is solved in development branch. Problem was dont converting raw object to string. Also if value field's type is string and format is matched with ejson, it is transformed to js object.