SeaQL / SeaQL/sea-orm

Document, deprecate, and remove `SqlErr`

Open
#2,940 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

2.0
Dominant language
Rust
Stars
9.9k
Forks
734
Avg merge
6h 36m
Merged PRs (30d)
8

Description

SqlErr is a very incomplete, outdated, and unmaintained reimplementation of sqlx::DatabaseError. We shouldn't have it. This is a strong opinion.

As a user, it sent me down the wrong path. For months, I was doing a fragile text search of my unique index names in SqlErr::UniqueConstraintViolation(error_text). I've just learned that I can match sqlx::DatabaseError, and then simply call database_error.constraint() to get the index name. And that it can also detect and parse CHECK constraint violations for me. I'm mad.

If we're not ready to break the compatibility and remove SqlErr yet, we should definitely document these nuances now, and deprecate SqlErr sometime later in 2.x (keeping the 2.0 migration as easy as we can).

What to give our users instead

What we should actually do for ergonomic DatabaseError handling, is to provide a db_err.database_error() method. Easy, right? I know. We can even mention it the .sql_err() deprecation message.

On a side note

Now I hate the sea_orm::DbErr naming. It should've been sea_orm::Error. sqlx::DatabaseError makes much more sense, because that's an error returned from the database.

In an ideal world, unconcerned with compatibility and churn, I would introduce sea_orm::Error, turn sea_orm::DbErr into an alias, and deprecate it sometime later in 2.x.

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 by locating the existing SqlErr, DbErr, and sql_err() APIs, then review how sqlx::DatabaseError is currently exposed or matched. Done requires a decided compatibility plan plus the corresponding documentation, deprecation or removal work, and ergonomic database-error API changes; the issue does not name files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
backend-api-design, databases
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.