{"id":18872791,"url":"https://github.com/survivorbat/gorm-case","last_synced_at":"2026-05-01T18:31:59.130Z","repository":{"id":179145363,"uuid":"662080411","full_name":"survivorbat/gorm-case","owner":"survivorbat","description":"I wanted to have some case-insensitive where-queries and I often use maps for filtering, so I made this plugin to convert queries into that.","archived":false,"fork":false,"pushed_at":"2025-05-26T09:44:12.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-30T19:36:22.196Z","etag":null,"topics":["case-insensitive","database","go","go-orm","golang","gorm"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/survivorbat/gorm-case","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/survivorbat.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":"2023-07-04T10:06:24.000Z","updated_at":"2025-05-26T09:43:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c32d698-e40b-43ea-98e7-f2e66c20fc8e","html_url":"https://github.com/survivorbat/gorm-case","commit_stats":null,"previous_names":["survivorbat/gorm-case"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/survivorbat/gorm-case","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survivorbat%2Fgorm-case","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survivorbat%2Fgorm-case/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survivorbat%2Fgorm-case/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survivorbat%2Fgorm-case/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/survivorbat","download_url":"https://codeload.github.com/survivorbat/gorm-case/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survivorbat%2Fgorm-case/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32508900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["case-insensitive","database","go","go-orm","golang","gorm"],"created_at":"2024-11-08T05:32:17.816Z","updated_at":"2026-05-01T18:31:59.107Z","avatar_url":"https://github.com/survivorbat.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧳 Gorm Case Insensitivity Plugin\n\n[![Go package](https://github.com/survivorbat/gorm-case/actions/workflows/test.yaml/badge.svg)](https://github.com/survivorbat/gorm-case/actions/workflows/test.yaml)\n\nI wanted to have some case-insensitive where-queries and I often use maps for filtering, so I made this plugin to convert\nqueries into that.\n\nBy default, all queries are turned into case-insensitive queries, if you don't want this,\nyou have 2 options:\n\n- `TaggedOnly()`: Will only change queries on fields that have the `gormcase:\"true\"` tag\n- `SettingOnly()`: Will only change queries on `*gorm.DB` objects that have `.Set(\"gormcase\", true)` set.\n\nIf you want a particular query to not be case-insensitive, use `.Set(\"gormcase\", false)`. This works\nregardless of configuration.\n\n\n```go\npackage main\n\nimport (\n\tgormcase \"github.com/survivorbat/gorm-case\"\n\t\"gorm.io/driver/sqlite\"\n\t\"gorm.io/gorm\"\n)\n\n// Employee is the example for normal usage\ntype Employee struct {\n\tName string\n}\n\n// RestrictedEmployee is the example for gormcase.TaggedOnly()\ntype RestrictedEmployee struct {\n\t// Will be case-insensitive in queries\n\tName string `gormcase:\"true\"`\n\n\t// Will not be case-insensitive in queries\n\tJob string\n}\n\nfunc main() {\n\t// Normal usage\n\tdb, _ := gorm.Open(sqlite.Open(\"test.db\"), \u0026gorm.Config{})\n\tdb.Create(Employee{Name: \"jEsSiCa\"})\n\t\n\tfilters := map[string]any{\n\t\t\"name\": \"jessica\",\n\t}\n\n\tdb.Use(gormcase.New())\n\tdb.Model(\u0026Employee{}).Where(filters)\n\n\t// Only uses case-insensitive-queries for tagged fields\n\tdb, _ = gorm.Open(sqlite.Open(\"test.db\"), \u0026gorm.Config{})\n\tdb.Create(Employee{Name: \"jEsSiCa\", Job: \"dEvElOpEr\"})\n\n\tfilters := map[string]any{\n\t\t\"name\": \"jessica\",\n\t\t\"job\": \"dEvElOpEr\",\n\t}\n\n\tdb.Use(gormcase.New(gormcase.TaggedOnly()))\n\tdb.Model(\u0026RestrictedEmployee{}).Where(filters)\n}\n```\n\nIs automatically turned into a query that looks like this:\n\n```sql\nSELECT * FROM employees WHERE UPPER(name) = UPPER('jessica');\n```\n\n## 💡 Related Libraries\n\n- [deepgorm](https://github.com/survivorbat/gorm-deep-filtering) turns nested maps in WHERE-calls into subqueries\n- [gormqonvert](https://github.com/survivorbat/gorm-query-convert) turns WHERE-calls into different queries if certain tokens were found\n- [gormlike](https://github.com/survivorbat/gorm-like) turns WHERE-calls into LIkE queries if certain tokens were found\n- [gormtestutil](https://github.com/ing-bank/gormtestutil) provides easy utility methods for unit-testing with gorm\n\n## ⬇️ Installation\n\n`go get github.com/survivorbat/gorm-case`\n\n## 📋 Usage\n\n```go\npackage main\n\nimport (\n    \"github.com/survivorbat/gorm-case\"\n)\n\nfunc main() {\n\tdb, _ := gorm.Open(sqlite.Open(\"test.db\"), \u0026gorm.Config{})\n\tdb.Use(gormcase.New())\n}\n\n```\n\n## 🔭 Plans\n\nNot much here.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurvivorbat%2Fgorm-case","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurvivorbat%2Fgorm-case","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurvivorbat%2Fgorm-case/lists"}