{"id":42750841,"url":"https://github.com/bool64/sqluct","last_synced_at":"2026-01-29T19:33:33.120Z","repository":{"id":38314110,"uuid":"319768495","full_name":"bool64/sqluct","owner":"bool64","description":"Struct-based database access layer for Go","archived":false,"fork":false,"pushed_at":"2025-08-17T18:48:27.000Z","size":94,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-22T15:04:03.930Z","etag":null,"topics":["database","go","hacktoberfest","query-builder","sql"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/bool64/sqluct","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/bool64.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2020-12-08T21:44:41.000Z","updated_at":"2025-08-17T18:48:26.000Z","dependencies_parsed_at":"2024-04-05T12:29:09.427Z","dependency_job_id":"46f429fe-7558-413b-87c0-4d53cb74ae24","html_url":"https://github.com/bool64/sqluct","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/bool64/sqluct","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bool64%2Fsqluct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bool64%2Fsqluct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bool64%2Fsqluct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bool64%2Fsqluct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bool64","download_url":"https://codeload.github.com/bool64/sqluct/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bool64%2Fsqluct/sbom","scorecard":{"id":247867,"data":{"date":"2025-08-11","repo":{"name":"github.com/bool64/sqluct","commit":"15650b19080b541fea8f533f65852f0e9e9a9d5b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/15 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":3,"reason":"4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/bench.yml:1","Warn: no topLevel permission defined: .github/workflows/cloc.yml:1","Warn: no topLevel permission defined: .github/workflows/golangci-lint.yml:1","Warn: no topLevel permission defined: .github/workflows/gorelease.yml:1","Warn: no topLevel permission defined: .github/workflows/test-unit.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/bench.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/bench.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/bench.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/bench.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/bench.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:63: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/bench.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/bench.yml:89: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/bench.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/cloc.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/cloc.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/cloc.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/cloc.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/cloc.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/cloc.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/golangci-lint.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/golangci-lint.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/golangci-lint.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/golangci-lint.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/golangci-lint.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/golangci-lint.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gorelease.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/gorelease.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gorelease.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/gorelease.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gorelease.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/gorelease.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/gorelease.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/gorelease.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-unit.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/test-unit.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-unit.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/test-unit.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-unit.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/test-unit.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-unit.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/test-unit.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-unit.yml:97: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/test-unit.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-unit.yml:123: update your workflow using https://app.stepsecurity.io/secureworkflow/bool64/sqluct/test-unit.yml/master?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/gorelease.yml:32","Info:   0 out of  17 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   6 third-party GitHubAction dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T07:55:59.736Z","repository_id":38314110,"created_at":"2025-08-17T07:55:59.736Z","updated_at":"2025-08-17T07:55:59.736Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28883091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T19:23:39.025Z","status":"ssl_error","status_checked_at":"2026-01-29T19:22:11.631Z","response_time":59,"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":["database","go","hacktoberfest","query-builder","sql"],"created_at":"2026-01-29T19:33:32.404Z","updated_at":"2026-01-29T19:33:33.115Z","avatar_url":"https://github.com/bool64.png","language":"Go","readme":"# Struct-based database access layer for Go\n\n[![test-unit](https://github.com/bool64/sqluct/actions/workflows/test-unit.yml/badge.svg)](https://github.com/bool64/sqluct/actions/workflows/test-unit.yml)\n[![Coverage Status](https://codecov.io/gh/bool64/sqluct/branch/master/graph/badge.svg)](https://codecov.io/gh/bool64/sqluct)\n[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/github.com/bool64/sqluct)\n[![Time Tracker](https://wakatime.com/badge/github/bool64/sqluct.svg)](https://wakatime.com/badge/github/bool64/sqluct)\n![Code lines](https://sloc.xyz/github/bool64/sqluct/?category=code)\n![Comments](https://sloc.xyz/github/bool64/sqluct/?category=comments)\n\nThis module integrates [`github.com/Masterminds/squirrel`](https://github.com/Masterminds/squirrel) query builder\nand [`github.com/jmoiron/sqlx`](https://github.com/jmoiron/sqlx) to allow seamless operation based on field tags of row\nstructure.\n\nAll three libraries collaborate with standard `database/sql` and do not take away low level control from user.\n\nThis library helps to eliminate literal string column references (e.g. `\"created_at\"`) and use field references\ninstead (e.g. `rf.Ref(\u0026row.CreatedAt)` and other mapping functions).\n\nField tags (`db` by default) act as a source of truth for column names to allow better maintainability and fewer errors.\n\n## Components\n\n`Storage` is a high level service that provides query building, query executing and result fetching facilities\nas easy to use facades.\n\n`StorageOf[V any]` typed query builder and scanner for specific table(s).\n\n`Mapper` is a lower level tool that focuses on managing `squirrel` query builder with row structures.\n\n`Referencer` helps to build complex statements by providing fully qualified and properly escaped names for \nparticipating columns.\n\n## Simple CRUD\n\n```go\n// Open DB connection.\ns, _ := sqluct.Open(\n    \"postgres\",\n    \"postgres://pqgotest:password@localhost/pqgotest?sslmode=disable\",\n)\n\n// Or if you already have an *sql.DB or *sqlx.DB instances, you can use them:\n// \t db, _ := sql.Open(\"postgres\", \"postgres://pqgotest:password@localhost/pqgotest?sslmode=disable\")\n//   s := sqluct.NewStorage(sqlx.NewDb(db, \"postgres\"))\n\nctx := context.TODO()\n\nconst tableName = \"products\"\n\ntype Product struct {\n    ID        int       `db:\"id,omitempty\"`\n    Title     string    `db:\"title\"`\n    CreatedAt time.Time `db:\"created_at,omitempty\"`\n}\n\n// INSERT INTO products (id, title, created_at) VALUES (1, 'Apples', \u003cnow\u003e), (2, 'Oranges', \u003cnow\u003e)\n_, err := s.Exec(ctx, s.InsertStmt(tableName, []Product{{\n    ID:        1,\n    Title:     \"Apples\",\n    CreatedAt: time.Now(),\n}, {\n    ID:        2,\n    Title:     \"Oranges\",\n    CreatedAt: time.Now(),\n},\n}))\nif err != nil {\n    log.Fatal(err)\n}\n\n// UPDATE products SET title = 'Bananas' WHERE id = 2\n_, err = s.Exec(\n    ctx,\n    s.UpdateStmt(tableName, Product{Title: \"Bananas\"}).\n        Where(s.WhereEq(Product{ID: 2})),\n)\nif err != nil {\n    log.Fatal(err)\n}\n\nvar (\n    result []Product\n    row    Product\n)\n// SELECT id, title, created_at FROM products WHERE id != 3 AND created_at \u003c= \u003cnow\u003e\nerr = s.Select(ctx,\n    s.SelectStmt(tableName, row).\n        Where(squirrel.NotEq(s.WhereEq(Product{ID: 3}, sqluct.SkipZeroValues))).\n        Where(squirrel.LtOrEq{s.Col(\u0026row, \u0026row.CreatedAt): time.Now()}),\n    \u0026result,\n)\nif err != nil {\n    log.Fatal(err)\n}\n\n// You can also use generic sqluct.Get and sqluct.List in go1.18 or later.\n//\n// SELECT id, title, created_at FROM products WHERE id != 3 AND created_at \u003c= \u003cnow\u003e\nresult, err = sqluct.List[Product](ctx,\n\ts,\n    s.SelectStmt(tableName, row).\n        Where(squirrel.NotEq(s.WhereEq(Product{ID: 3}, sqluct.SkipZeroValues))).\n        Where(squirrel.LtOrEq{s.Col(\u0026row, \u0026row.CreatedAt): time.Now()}),\n)\nif err != nil {\n    log.Fatal(err)\n}\n\n\n// DELETE FROM products WHERE id = 2\n_, err = s.Exec(ctx, s.DeleteStmt(tableName).Where(Product{ID: 2}, sqluct.SkipZeroValues))\nif err != nil {\n    log.Fatal(err)\n}\n```\n\n## Referencing Fields In Complex Statements\n\n```go\ntype User struct {\n    ID        int    `db:\"id\"`\n    FirstName string `db:\"first_name\"`\n    LastName  string `db:\"last_name\"`\n}\n\ntype DirectReport struct {\n    ManagerID  int `db:\"manager_id\"`\n    EmployeeID int `db:\"employee_id\"`\n}\n\nvar s sqluct.Storage\n\nrf := s.Ref()\n\n// Add aliased tables as pointers to structs.\nmanager := \u0026User{}\nrf.AddTableAlias(manager, \"manager\")\n\nemployee := \u0026User{}\nrf.AddTableAlias(employee, \"employee\")\n\ndr := \u0026DirectReport{}\nrf.AddTableAlias(dr, \"dr\")\n\n// Find direct reports that share same last name and manager is not named John.\nqb := squirrel.StatementBuilder.Select(rf.Fmt(\"%s, %s\", \u0026dr.ManagerID, \u0026dr.EmployeeID)).\n    From(rf.Fmt(\"%s AS %s\", rf.Q(\"users\"), manager)). // Quote literal name and alias it with registered struct pointer.\n    InnerJoin(rf.Fmt(\"%s AS %s ON %s = %s AND %s = %s\",\n        rf.Q(\"direct_reports\"), dr,\n        \u0026dr.ManagerID, \u0026manager.ID, // Identifiers are resolved using row field pointers.\n        \u0026dr.EmployeeID, \u0026employee.ID)).\n    Where(rf.Fmt(\"%s = %s\", \u0026manager.LastName, \u0026employee.LastName)).\n    Where(rf.Fmt(\"%s != ?\", \u0026manager.FirstName), \"John\") // Regular binds work same way as in standard squirrel.\n\nstmt, args, err := qb.ToSql()\nif err != nil {\n    log.Fatal(err)\n}\n\nfmt.Println(stmt)\nfmt.Println(args)\n\n// SELECT dr.manager_id, dr.employee_id \n// FROM users AS manager \n// INNER JOIN direct_reports AS dr ON dr.manager_id = manager.id AND dr.employee_id = employee.id \n// WHERE manager.last_name = employee.last_name AND manager.first_name != ?\n//\n// [John]\n```\n\n## Typed Storage\n\n`sqluct.Table[RowType](storageInstance, tableName)` creates a type-safe storage accessor to a table with `RowType`.\nThis accessor can help to retrieve or store data. Columns from multiple tables can be joined using field pointers.\n\nPlease check features overview in an example below.\n\n```go\nvar (\n    st  = sqluct.NewStorage(sqlx.NewDb(sql.OpenDB(dumpConnector{}), \"postgres\"))\n    ctx = context.Background()\n)\n\nst.IdentifierQuoter = sqluct.QuoteANSI\n\ntype User struct {\n    ID     int    `db:\"id\"`\n    RoleID int    `db:\"role_id\"`\n    Name   string `db:\"name\"`\n}\n\n// Users repository.\nur := sqluct.Table[User](st, \"users\")\n\n// Pointer to row, that can be used to reference columns via struct fields.\n_ = ur.R\n\n// Single user record can be inserted, last insert id (if available) and error are returned.\nfmt.Println(\"Insert single user.\")\n_, _ = ur.InsertRow(ctx, User{Name: \"John Doe\", ID: 123})\n\n// Multiple user records can be inserted with sql.Result and error returned.\nfmt.Println(\"Insert two users.\")\n_, _ = ur.InsertRows(ctx, []User{{Name: \"Jane Doe\", ID: 124}, {Name: \"Richard Roe\", ID: 125}})\n\n// Update statement for a single user with condition.\nfmt.Println(\"Update a user with new name.\")\n_, _ = ur.UpdateStmt(User{Name: \"John Doe, Jr.\", ID: 123}).Where(ur.Eq(\u0026ur.R.ID, 123)).ExecContext(ctx)\n\n// Delete statement for a condition.\nfmt.Println(\"Delete a user with id 123.\")\n_, _ = ur.DeleteStmt().Where(ur.Eq(\u0026ur.R.ID, 123)).ExecContext(ctx)\n\nfmt.Println(\"Get single user with id = 123.\")\nuser, _ := ur.Get(ctx, ur.SelectStmt().Where(ur.Eq(\u0026ur.R.ID, 123)))\n\n// Squirrel expression can be formatted with %s reference(s) to column pointer.\nfmt.Println(\"Get multiple users with names starting with 'John '.\")\nusers, _ := ur.List(ctx, ur.SelectStmt().Where(ur.Fmt(\"%s LIKE ?\", \u0026ur.R.Name), \"John %\"))\n\n// Squirrel expressions can be applied.\nfmt.Println(\"Get multiple users with id != 123.\")\nusers, _ = ur.List(ctx, ur.SelectStmt().Where(squirrel.NotEq(ur.Eq(\u0026ur.R.ID, 123))))\n\nfmt.Println(\"Get all users.\")\nusers, _ = ur.List(ctx, ur.SelectStmt())\n\n// More complex statements can be made with references to other tables.\n\ntype Role struct {\n    ID   int    `db:\"id\"`\n    Name string `db:\"name\"`\n}\n\n// Roles repository.\nrr := sqluct.Table[Role](st, \"roles\")\n\n// To be able to resolve \"roles\" columns, we need to attach roles repo to users repo.\nur.AddTableAlias(rr.R, \"roles\")\n\nfmt.Println(\"Get users with role 'admin'.\")\nusers, _ = ur.List(ctx, ur.SelectStmt().\n    LeftJoin(ur.Fmt(\"%s ON %s = %s\", rr.R, \u0026rr.R.ID, \u0026ur.R.RoleID)).\n    Where(ur.Fmt(\"%s = ?\", \u0026rr.R.Name), \"admin\"),\n)\n\n_ = user\n_ = users\n\n// Output:\n// Insert single user.\n// exec INSERT INTO \"users\" (\"id\",\"role_id\",\"name\") VALUES ($1,$2,$3) [123 0 John Doe]\n// Insert two users.\n// exec INSERT INTO \"users\" (\"id\",\"role_id\",\"name\") VALUES ($1,$2,$3),($4,$5,$6) [124 0 Jane Doe 125 0 Richard Roe]\n// Update a user with new name.\n// exec UPDATE \"users\" SET \"id\" = $1, \"role_id\" = $2, \"name\" = $3 WHERE \"users\".\"id\" = $4 [123 0 John Doe, Jr. 123]\n// Delete a user with id 123.\n// exec DELETE FROM \"users\" WHERE \"users\".\"id\" = $1 [123]\n// Get single user with id = 123.\n// query SELECT \"users\".\"id\", \"users\".\"role_id\", \"users\".\"name\" FROM \"users\" WHERE \"users\".\"id\" = $1 [123]\n// Get multiple users with names starting with 'John '.\n// query SELECT \"users\".\"id\", \"users\".\"role_id\", \"users\".\"name\" FROM \"users\" WHERE \"users\".\"name\" LIKE $1 [John %]\n// Get multiple users with id != 123.\n// query SELECT \"users\".\"id\", \"users\".\"role_id\", \"users\".\"name\" FROM \"users\" WHERE \"users\".\"id\" \u003c\u003e $1 [123]\n// Get all users.\n// query SELECT \"users\".\"id\", \"users\".\"role_id\", \"users\".\"name\" FROM \"users\" []\n// Get users with role 'admin'.\n// query SELECT \"users\".\"id\", \"users\".\"role_id\", \"users\".\"name\" FROM \"users\" LEFT JOIN \"roles\" ON \"roles\".\"id\" = \"users\".\"role_id\" WHERE \"roles\".\"name\" = $1 [admin]\n```\n\n## Omitting Zero Values\n\nWhen building `WHERE` conditions from row structure it is often needed skip empty fields from condition. \n\nBehavior with empty fields (zero values) can be controlled via `omitempty` field tag flag and `sqluct.IgnoreOmitEmpty`,\n`sqluct.SkipZeroValues` options.\n\nPlease check example below to learn about behavior differences.\n\n```go\nvar s sqluct.Storage\n\ntype Product struct {\n    ID    int    `db:\"id,omitempty\"`\n    Name  string `db:\"name,omitempty\"`\n    Price int    `db:\"price\"`\n}\n\nquery, args, err := s.SelectStmt(\"products\", Product{}).Where(s.WhereEq(Product{\n    ID:    123,\n    Price: 0,\n})).ToSql()\nfmt.Println(query, args, err)\n// This query skips `name` in where condition for its zero value and `omitempty` flag.\n//   SELECT id, name, price FROM products WHERE id = $1 AND price = $2 [123 0] \u003cnil\u003e\n\nquery, args, err = s.SelectStmt(\"products\", Product{}).Where(s.WhereEq(Product{\n    ID:    123,\n    Price: 0,\n}, sqluct.IgnoreOmitEmpty)).ToSql()\nfmt.Println(query, args, err)\n// This query adds `name` in where condition because IgnoreOmitEmpty is applied and `omitempty` flag is ignored.\n//   SELECT id, name, price FROM products WHERE id = $1 AND name = $2 AND price = $3 [123  0] \u003cnil\u003e\n\nquery, args, err = s.SelectStmt(\"products\", Product{}).Where(s.WhereEq(Product{\n    ID:    123,\n    Price: 0,\n}, sqluct.SkipZeroValues)).ToSql()\nfmt.Println(query, args, err)\n// This query adds skips both price and name from where condition because SkipZeroValues option is applied.\n//   SELECT id, name, price FROM products WHERE id = $1 [123] \u003cnil\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbool64%2Fsqluct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbool64%2Fsqluct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbool64%2Fsqluct/lists"}