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

Transactions do not accept JSON objects #1501

Open
kostasb opened this issue Jun 10, 2024 · 0 comments
Open

Transactions do not accept JSON objects #1501

kostasb opened this issue Jun 10, 2024 · 0 comments
Labels
bug Something isn't working needs-triage

Comments

@kostasb
Copy link
Contributor

kostasb commented Jun 10, 2024

Describe the bug

  • Reproduced with client version: 0.29.5

The transactions endpoint does not support objects. The object must be stringified to work in a transaction.
For reference, record create calls support objects directly.

SDK example:

const myblob = { test: "a" };
await xata.transactions.run([
  { insert: { table: "test", record: { json_column: myblob } } },
]);

Payload:

{"operations":[{"insert":{"table":"test","record":{"json_column":{"test":"a"}}}}]}

Response 400:

{"errors":[{"index":0,"message":"table [trs]: invalid record: column [json_column]: type mismatch: expected string"}],"id":"a458f426-9f63-90ca-b64e-b30b3f633c40"}

For the operation to succeed with the current state of things, the object must be stringified:

await xata.transactions.run([
  { insert: { table: "test", record: { json_column: JSON.stringify(myblob) } } },
]);
@kostasb kostasb added the bug Something isn't working label Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant