mattn / mattn/go-sqlite3

Add getters to sqlite3.Error

Open Beginner friendly
#1,324 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
9.2k
Forks
1.2k
Avg merge
19m
Merged PRs (30d)
4

Description

I'm working on a library which works with many different SQL drivers and maps to common errors for things like unique constraints etc.
I'd like to avoid having to import go-sqlite3 as it requires cgo so I was wondering whether you'd be open to adding getters for the error which can be used in a more dynamic environment e.g.

// Error implement sqlite error code.
type Error struct {
	Code         ErrNo         /* The error code returned by SQLite */
	ExtendedCode ErrNoExtended /* The extended error code returned by SQLite */
	SystemErrno  syscall.Errno /* The system errno returned by the OS through SQLite, if applicable */
	err          string        /* The error string returned by sqlite3_errmsg(),
	this usually contains more specific details. */
}


func (err Error) GetExtendedCode() int {
	return int(err.ExtendedCode)
}

That way libraries that need to support go-sqlite3 can do so without relying on the package by simply using an interface.

Contributor guide

No contributing guide indexed for this repository

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 at sqlite3.Error and review its exported error-code fields and existing error API. Determine which getter methods are needed to support an interface without importing the package, then add focused tests showing the getters return the corresponding error values.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sqlite
Domain
databases
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.