tursodatabase / tursodatabase/libsql
Getting 'failed to execute SQL' error instead of constraint error
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
I have a users table in Turso where the id is a primary key and the email field has a unique index constraint. When I attempt to insert a row with a duplicate id or a duplicate email, I only receive the following error:
insert into users (id, email) values('duplicateid', 'duplicate@email.com');
Error: failed to execute SQL: insert into users (id, email) values('duplicateid', 'duplicate@email.com');
The row is inserted successfully when the values are unique.
When I attempt to insert a row with a duplicate email in my application, I get the following error
HttpServerError: Server returned HTTP status 500
This is the schema for the user table:
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`name` text,
`email` text NOT NULL,
`hash` text,
`role` text DEFAULT 'user',
`created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL
);
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);
I would appreciate any input on receiving detailed errors.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the duplicate-id and duplicate-email INSERT examples with the shown users schema to reproduce the generic failure. Trace the SQL execution and error path in libSQL; done means constraint violations expose detailed errors instead of only “failed to execute SQL” or an HTTP 500 response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100