{"id":15404611,"url":"https://github.com/k1low/sqlc-go-one-or-fail","last_synced_at":"2026-02-23T11:39:40.069Z","repository":{"id":189112828,"uuid":"680068723","full_name":"k1LoW/sqlc-go-one-or-fail","owner":"k1LoW","description":"Modify the Go code generated by sqlc to fail if more than one record is retrieved in the `:one` command.","archived":false,"fork":false,"pushed_at":"2025-10-23T01:50:47.000Z","size":42,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T05:41:47.918Z","etag":null,"topics":["go","sqlc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k1LoW.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"k1LoW","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2023-08-18T09:09:46.000Z","updated_at":"2024-07-04T03:25:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"a8843563-e17e-4775-93f5-290f6aafda3e","html_url":"https://github.com/k1LoW/sqlc-go-one-or-fail","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.4285714285714286,"last_synced_commit":"6cfb73692c950667952e7e10c42e09a2d149abdb"},"previous_names":["k1low/sqlc-go-one-or-fail"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/k1LoW/sqlc-go-one-or-fail","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fsqlc-go-one-or-fail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fsqlc-go-one-or-fail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fsqlc-go-one-or-fail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fsqlc-go-one-or-fail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k1LoW","download_url":"https://codeload.github.com/k1LoW/sqlc-go-one-or-fail/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fsqlc-go-one-or-fail/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29741684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","sqlc"],"created_at":"2024-10-01T16:13:50.438Z","updated_at":"2026-02-23T11:39:39.897Z","avatar_url":"https://github.com/k1LoW.png","language":"Go","funding_links":["https://github.com/sponsors/k1LoW"],"categories":[],"sub_categories":[],"readme":"# sqlc-go-one-or-fail\n[![CI](https://github.com/k1LoW/sqlc-go-one-or-fail/actions/workflows/ci.yml/badge.svg)](https://github.com/k1LoW/sqlc-go-one-or-fail/actions/workflows/ci.yml) ![Coverage](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/sqlc-go-one-or-fail/coverage.svg) ![Code to Test Ratio](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/sqlc-go-one-or-fail/ratio.svg) ![Test Execution Time](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/sqlc-go-one-or-fail/time.svg)\n\n`sqlc-go-one-or-fail` modifies the Go code generated by [sqlc](https://sqlc.dev/) to fail if more than one record is retrieved in the [`:one`](https://docs.sqlc.dev/en/latest/reference/query-annotations.html#one) command.\n\n## Usage\n\n```console\n$ sqlc generate\n$ sqlc-go-one-or-fail path/to/generated_by_sqlc/*.go\n```\n\n### Before\n\n```go\nconst getAuthorByName = `-- name: GetAuthorByName :one\nSELECT id, name, bio FROM authors\nWHERE name = ?\n`\n\nfunc (q *Queries) GetAuthorByName(ctx context.Context, name string) (Author, error) {\n\trow := q.db.QueryRowContext(ctx, getAuthorByName, name)\n\tvar i Author\n\terr := row.Scan(\u0026i.ID, \u0026i.Name, \u0026i.Bio)\n\treturn i, err\n}\n```\n\n### After\n\n```go\nconst getAuthorByName = `-- name: GetAuthorByName :one\nSELECT id, name, bio FROM authors\nWHERE name = ?\n`\n\nfunc (q *Queries) GetAuthorByName(ctx context.Context, name string) (Author, error) {\n\trows, err := q.db.QueryContext(ctx, getAuthorByName, name)\n\tif err != nil {\n\t\treturn Author{}, err\n\t}\n\tdefer rows.Close()\n\tif !rows.Next() {\n\t\tif err := rows.Err(); err != nil {\n\t\t\treturn Author{}, err\n\t\t}\n\t\treturn Author{}, sql.ErrNoRows\n\t}\n\tvar i Author\n\tif err := rows.Scan(\u0026i.ID, \u0026i.Name, \u0026i.Bio); err != nil {\n\t\treturn Author{}, err\n\t}\n\tif rows.Next() {\n\t\treturn Author{}, fmt.Errorf(\"multiple records were retrieved when the following query was executed: %q\", getAuthorByName)\n\t}\n\tif err := rows.Close(); err != nil {\n\t\treturn Author{}, err\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn Author{}, err\n\t}\n\treturn i, err\n\n}\n```\n\n## Install\n\n**deb:**\n\n``` console\n$ export SQLC_GO_ONE_OR_FAIL_VERSION=X.X.X\n$ curl -o sqlc-go-one-or-fail.deb -L https://github.com/k1LoW/sqlc-go-one-or-fail/releases/download/v$SQLC_GO_ONE_OR_FAIL_VERSION/sqlc-go-one-or-fail_$SQLC_GO_ONE_OR_FAIL_VERSION-1_amd64.deb\n$ dpkg -i sqlc-go-one-or-fail.deb\n```\n\n**RPM:**\n\n``` console\n$ export SQLC_GO_ONE_OR_FAIL_VERSION=X.X.X\n$ yum install https://github.com/k1LoW/sqlc-go-one-or-fail/releases/download/v$SQLC_GO_ONE_OR_FAIL_VERSION/sqlc-go-one-or-fail_$SQLC_GO_ONE_OR_FAIL_VERSION-1_amd64.rpm\n```\n\n**apk:**\n\n``` console\n$ export SQLC_GO_ONE_OR_FAIL_VERSION=X.X.X\n$ curl -o sqlc-go-one-or-fail.apk -L https://github.com/k1LoW/sqlc-go-one-or-fail/releases/download/v$SQLC_GO_ONE_OR_FAIL_VERSION/runn_$SQLC_GO_ONE_OR_FAIL_VERSION-1_amd64.apk\n$ apk add sqlc-go-one-or-fail.apk\n```\n\n**homebrew tap:**\n\n```console\n$ brew install k1LoW/tap/sqlc-go-one-or-fail\n```\n\n**manually:**\n\nDownload binary from [releases page](https://github.com/k1LoW/sqlc-go-one-or-fail/releases)\n\n**go install:**\n\n```console\n$ go install github.com/k1LoW/sqlc-go-one-or-fail@latest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1low%2Fsqlc-go-one-or-fail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk1low%2Fsqlc-go-one-or-fail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1low%2Fsqlc-go-one-or-fail/lists"}