{"id":37180693,"url":"https://github.com/adel-hadadi/ququery","last_synced_at":"2026-01-14T21:00:03.423Z","repository":{"id":250927457,"uuid":"835883497","full_name":"adel-hadadi/ququery","owner":"adel-hadadi","description":"Ququery is simple and readable SQL query builder for golang","archived":false,"fork":false,"pushed_at":"2024-09-18T21:09:59.000Z","size":40,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-27T12:33:44.108Z","etag":null,"topics":["golang","mysql","postgresql","query","sql"],"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/adel-hadadi.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}},"created_at":"2024-07-30T18:03:16.000Z","updated_at":"2024-09-19T03:52:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb147bf8-1a42-4d8d-bb3e-151a44b6e793","html_url":"https://github.com/adel-hadadi/ququery","commit_stats":null,"previous_names":["adel-hadadi/ququery"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/adel-hadadi/ququery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adel-hadadi%2Fququery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adel-hadadi%2Fququery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adel-hadadi%2Fququery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adel-hadadi%2Fququery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adel-hadadi","download_url":"https://codeload.github.com/adel-hadadi/ququery/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adel-hadadi%2Fququery/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["golang","mysql","postgresql","query","sql"],"created_at":"2026-01-14T21:00:02.718Z","updated_at":"2026-01-14T21:00:03.414Z","avatar_url":"https://github.com/adel-hadadi.png","language":"Go","readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/adel-hadadi/ququery)](https://goreportcard.com/report/github.com/adel-hadadi/ququery)\n[![codecov](https://codecov.io/github/adel-hadadi/ququery/graph/badge.svg?token=IkdEDjVmb4)](https://codecov.io/github/adel-hadadi/ququery)\n\n# QuQuery: Golang SQL Builder\n\n```\n ██████╗ ██╗   ██╗ ██████╗ ██╗   ██╗███████╗██████╗ ██╗   ██╗\n██╔═══██╗██║   ██║██╔═══██╗██║   ██║██╔════╝██╔══██╗╚██╗ ██╔╝\n██║   ██║██║   ██║██║   ██║██║   ██║█████╗  ██████╔╝ ╚████╔╝\n██║▄▄ ██║██║   ██║██║▄▄ ██║██║   ██║██╔══╝  ██╔══██╗  ╚██╔╝\n╚██████╔╝╚██████╔╝╚██████╔╝╚██████╔╝███████╗██║  ██║   ██║\n ╚══▀▀═╝  ╚═════╝  ╚══▀▀═╝  ╚═════╝ ╚══════╝╚═╝  ╚═╝   ╚═╝\n\n\n```\n\n## About\n\nQuQuery is simple and efficient SQL databases query builder that provide zero dependency and zero type reflection\nin your code base to make repositories more readable for first look.\n\n## Why i make `Ququery` package\n\nWhen I was learning Golang, I noticed that many people coding in Golang for the first time were using GORM. However, after a short period of using GORM, I found myself dealing with convoluted code that I couldn't understand, and it often didn't work as expected.\n\nI searched for other solutions and discovered that in many large companies and projects, programmers prefer to use pure SQL queries with the standard database/sql package. This approach avoids several issues commonly encountered with GORM:\n\n1. **Performance Overhead**:\n   GORM introduces an additional layer of abstraction which can result in performance overhead compared to writing raw SQL queries. This can be significant in high-performance applications.\n\n2. **Complex Queries**:\n   For complex queries involving multiple joins, subqueries, and custom SQL, GORM's abstraction can become cumbersome and harder to manage, often requiring raw SQL anyway.\n\n3. **Debugging Difficulties**:\n   Debugging GORM issues can be challenging because it abstracts away the SQL, making it harder to understand what exact queries are being generated and executed.\n\n4. **Code Complexity** :\n   Over time, as projects grow, the GORM code can become complex and harder to maintain, especially if it's not used consistently across the codebase.\n\nAfter a long time of writing SQL queries, my coworkers and I grew tired of writing repetitive queries. To solve this issue, I decided to create `ququery`—a query builder for Golang. This tool aims to simplify the process of building SQL queries, making your code more readable and maintainable, while avoiding the aforementioned problems with GORM.\n\n## Installation And Usage\n\nFor installing ququery in your project should run below command in root of project.\n\n```shel\ngo get github.com/adel-hadadi/ququery@latest\n```\n\nEvery database operation such as (`UPDATE`, `INSERT`, `DELETE`, `SELECT`) in ququery have specific methods and they can be different from other one so let's explain each operation methods one by one.\n\n## Select Statements\n\n### Specifying a Select Clause\n\nYou may not always want to select all columns from database table.\nUsing the `Columns` method you can specify each column that you want to fetch from database.\n\n```go\nquery := ququery.Select(\"table_name\").Columns(\"id\", \"name\", \"email\").Query()\n\nlog.Println(query) // query =\u003e SELECT id, name, email FROM table_name\n```\n\nFor situations that you want to fetch all columns you can call `Select` method without `Columns`.\n\n## Joins\n\nThe query builder also be used to add join clauses to your queries.\nTo perform a basic inner join, you may use the `Join` method on a query builder instance.\nThe first arguments passed to `Join` method is the name of the table you need to join to,\nwhile the second argument specify the column constraints for the join.\nYou may even join multiple tables in a single query:\n\n```go\nquery := ququery.Select(\"users\").\n    Join(\"posts\", \"posts.user_id = users.id\").\n    Query()\n\nlog.Println(query) // query =\u003e SELECT * FROM users INNER JOIN posts ON posts.user_id = users.id\n```\n\n### Left join / Right join\n\nif you would like to perform `left join` or `right join` instead of an `inner join`,\nuse `LeftJoin` or `RightJoin` methods. This methods have the same signature as the\n`Join` method:\n\n```go\nleftJoin := ququery.Select(\"users\").LeftJoin(\"posts\", \"posts.user_id = users.id\").Query()\nlog.Println(leftJoin) // query =\u003e SELECT * FROM users LEFT JOIN posts ON posts.user_id = users.id\n\nrightJoin := ququery.Select(\"users\").RightJoin(\"posts\", \"posts.user_id = users.id\").Query()\nlog.Println(rightJoin) // query =\u003e SELECT * FROM users RIGHT JOIN posts ON posts.user_id = users.id\n```\n\n### With\n\nAlso if you want to load a simple belongs to relations you can use `With` method.\nThis method take a list of entities and then automatically load relations:\n\n```go\nquery := ququery.Select(\"users\").With(\"role\", \"wallet\").Query()\nlog.Println(query) // query =\u003e SELECT * FROM users LEFT JOIN roles ON roles.id = user.role_id LEFT JOIN wallets ON wallets.id = users.wallet_id\n```\n\n## Basic Where Clauses\n\n### Where Clauses\n\nYou may use the query builder's `Where` method to add \"where\" clauses to the query.\nThe most basic call to the `Where` method requires two arguments. The first argument\nis the name of the column. The second argument is an operator, which can be any of\nthe database's supported operators.\n\nFor example, the following query retrieves users where the value of the votes column\nis equal to $1 and the value of the age column is greater than $2:\n\n```go\nquery := ququery.Select(\"users\").\n    Where(\"votes\", \"=\").\n    Where(\"age\", \"\u003e\").\n    Query()\n\nlog.Println(query) // query =\u003e SELECT * FROM users WHERE votes = $1 AND age \u003e $2\n```\n\nFor convenience, if you want to verify that a column is `=` to a given value, you may call `Where` method with just column name.\n`Ququery` will assume you would like to use the `=` operator:\n\n```go\nquery := ququery.Select(\"users\").\n    Where(\"votes\").\n    Query()\n\nlog.Pritln(query) // query =\u003e SELECT * FROM users WHERE votes = $1\n```\n\n## Or Where Clauses\n\nWhen chaining together calls to the query builder's `Where` method, the \"where\" clauses will be joined together using the `AND` operator. However, you may use the `OrWhere` method to join a clause to the query using the `OR` operator. The `OrWhere` method accepts the same arguments as the `Where` method:\n\n```go\nquery := ququery.Select(\"users\").\n    Where(\"votes\").\n    OrWhere(\"name\")\n    Query()\n\nlog.Pritln(query) // query =\u003e SELECT * FROM users WHERE votes = $1 OR name = $2\n```\n\nIf you need to group multiple where clauses together you can use `WhereGroup` method:\n\n```go\nquery := ququery.Select(\"users\").\n    Where(\"votes\").\n    WhereGroup(func(subQuery MultiWhere) string {\n        return subQuery.Where(\"name\").\n            OrWhere(\"votes\", \"\u003e\").\n            Query()\n    }).\n    Query()\n\nlog.Pritln(query) // query =\u003e SELECT * FROM users WHERE votes = $1 OR name = $2\n```\n\n## Additional Where Clause\n\n### WhereLike / OrWhereLike\n\nThe `WhereLike` method allows you to add \"LIKE\" clauses to query for\npattern matching. These methods provide a database-agnostic way\nperforming string matching queries, with the ability to toggle\ncase-sensitivity. By default, string matching is case-insensitive:\n\n```go\nquery := ququery.Select(\"users\").WhereLike(\"name\").Query()\nlog.Println(query) // query =\u003e SELECT * FROM users WHERE name LIKE $1\n```\n\nThe `OrWhereLike` method allows you to add an \"or\"A clause with a LIKE\ncondition:\n\n```go\nquery := ququer.Select(\"users\").\n    Where(\"votes\", \"\u003e\").\n    OrWhereLike(\"name\").\n    Query()\n\nlog.Println(query) // query =\u003e SELECT * FROM users WHERE votes \u003e $1 OR WHERE name LIKE $2\n```\n\n### WhereNull / WhereNotNull / OrWhereNull / OrWhereNotNull\n\nThe `WhereNull` method verifies that the value of the given column is `NULL`:\n\n```go\nquery := ququery.Select(\"users\").WhereNull(\"updated_at\").Query()\nlog.Println(query) // query =\u003e SELECT * FROM users WHERE updated_at IS NULL\n```\n\nThe `WhereNotNull` method verifies that the column's value is not `NULL`:\n\n```go\nquery := ququery.Select(\"users\").WhereNotNull(\"updated_at\").Query()\nlog.Println(query) // query =\u003e SELECT * FROM users WHERE updated_at IS NOT NULL\n```\n\n# Ordering, Grouping, Limit and offset\n\n## Ordering\n\n### The `OrderBy` Method\n\nThe `OrderBy` method allows you to sort the results of the query by a given column. The First argument accepted by the `OrderBy` method should be the column you wish to sort by, while the second argument determines the direction of the sort and may not either `asc` or `desc`:\n\n```go\nquery := ququery.Select(\"users\").OrderBy(\"name\", \"desc\").Query()\nlog.Println(query) // query =\u003e SELECT * FROM users ORDER BY name DESC\n```\n\n## Limit and Offset\n\nYou may use the `Limit` and `Offset` methods to limit the number of results returned from the query or to skip a given number of results in the query:\n\n```go\nquery := ququery.Select(\"users\").Limit().Offset().Query()\nlog.Println(query) // query =\u003e SELECT * FROM users LIMIT $1 OFFSET $2\n```\n\n# Insert Statements\n\nThe query builder also provides an `Insert` method that may be used to insert records into database table. The `Insert` method accepts a list of column names.\n\n```go\nquery := ququery.Insert(\"users\").Into(\"email\", \"votes\").Query()\nlog.Println(query) // query =\u003e INSERT INTO users (email, votes) VALUES ($1, $2)\n```\n\n# Update Statements\n\nIn addition to inserting records into the database, the query builder can also update existing records using the `Update` method. The `Update` method, like the `Insert` method, accepts a list of columns that should be updated:\n\n```go\nquery := ququery.Update(\"users\").Where(\"id\").Set(\"email\", \"email_verified\").Query()\nlog.Println(query) // query =\u003e UPDATE users SET email = $1, email_verified = $2 WHERE id = $3\n```\n\n# Delete Statements\n\nThe query builder's `Delete` method may be used to delete records from the table:\n\n```go\nquery := ququery.Delete(\"users\").Where(\"votes\", \"\u003e\").Query()\nlog.Println(query) // query =\u003e DELETE FROM users WHERE votes \u003e $1\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadel-hadadi%2Fququery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadel-hadadi%2Fququery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadel-hadadi%2Fququery/lists"}