SQL builder and query library for golang

Overview
  __ _  ___   __ _ _   _
 / _` |/ _ \ / _` | | | |
| (_| | (_) | (_| | |_| |
 \__, |\___/ \__, |\__,_|
 |___/          |_|

GitHub tag Test GoDoc codecov Go Report Card

goqu is an expressive SQL builder and executor

If you are upgrading from an older version please read the Migrating Between Versions docs.

Installation

If using go modules.

go get -u github.com/doug-martin/goqu/v9

If you are not using go modules...

NOTE You should still be able to use this package if you are using go version >v1.10 but, you will need to drop the version from the package. import "github.com/doug-martin/goqu/v9 -> import "github.com/doug-martin/goqu"

go get -u github.com/doug-martin/goqu

Migrating Between Versions

Features

goqu comes with many features but here are a few of the more notable ones

  • Query Builder
  • Parameter interpolation (e.g SELECT * FROM "items" WHERE "id" = ? -> SELECT * FROM "items" WHERE "id" = 1)
  • Built from the ground up with multiple dialects in mind
  • Insert, Multi Insert, Update, and Delete support
  • Scanning of rows to struct[s] or primitive value[s]

While goqu may support the scanning of rows into structs it is not intended to be used as an ORM if you are looking for common ORM features like associations, or hooks I would recommend looking at some of the great ORM libraries such as:

Why?

We tried a few other sql builders but each was a thin wrapper around sql fragments that we found error prone. goqu was built with the following goals in mind:

  • Make the generation of SQL easy and enjoyable
  • Create an expressive DSL that would find common errors with SQL at compile time.
  • Provide a DSL that accounts for the common SQL expressions, NOT every nuance for each database.
  • Provide developers the ability to:
    • Use SQL when desired
    • Easily scan results into primitive values and structs
    • Use the native sql.Db methods when desired

Docs

  • Dialect - Introduction to different dialects (mysql, postgres, sqlite3, sqlserver etc)
  • Expressions - Introduction to goqu expressions and common examples.
  • Select Dataset - Docs and examples about creating and executing SELECT sql statements.
  • Insert Dataset - Docs and examples about creating and executing INSERT sql statements.
  • Update Dataset - Docs and examples about creating and executing UPDATE sql statements.
  • Delete Dataset - Docs and examples about creating and executing DELETE sql statements.
  • Prepared Statements - Docs about interpolation and prepared statements in goqu.
  • Database - Docs and examples of using a Database to execute queries in goqu
  • Working with time.Time - Docs on how to use alternate time locations.

Quick Examples

Select

See the select dataset docs for more in depth examples

sql, _, _ := goqu.From("test").ToSQL()
fmt.Println(sql)

Output:

SELECT * FROM "test"
sql, _, _ := goqu.From("test").Where(goqu.Ex{
	"d": []string{"a", "b", "c"},
}).ToSQL()
fmt.Println(sql)

Output:

SELECT * FROM "test" WHERE ("d" IN ('a', 'b', 'c'))

Insert

See the insert dataset docs for more in depth examples

ds := goqu.Insert("user").
	Cols("first_name", "last_name").
	Vals(
		goqu.Vals{"Greg", "Farley"},
		goqu.Vals{"Jimmy", "Stewart"},
		goqu.Vals{"Jeff", "Jeffers"},
	)
insertSQL, args, _ := ds.ToSQL()
fmt.Println(insertSQL, args)

Output:

INSERT INTO "user" ("first_name", "last_name") VALUES ('Greg', 'Farley'), ('Jimmy', 'Stewart'), ('Jeff', 'Jeffers') []
ds := goqu.Insert("user").Rows(
	goqu.Record{"first_name": "Greg", "last_name": "Farley"},
	goqu.Record{"first_name": "Jimmy", "last_name": "Stewart"},
	goqu.Record{"first_name": "Jeff", "last_name": "Jeffers"},
)
insertSQL, args, _ := ds.ToSQL()
fmt.Println(insertSQL, args)

Output:

INSERT INTO "user" ("first_name", "last_name") VALUES ('Greg', 'Farley'), ('Jimmy', 'Stewart'), ('Jeff', 'Jeffers') []
type User struct {
	FirstName string `db:"first_name"`
	LastName  string `db:"last_name"`
}
ds := goqu.Insert("user").Rows(
	User{FirstName: "Greg", LastName: "Farley"},
	User{FirstName: "Jimmy", LastName: "Stewart"},
	User{FirstName: "Jeff", LastName: "Jeffers"},
)
insertSQL, args, _ := ds.ToSQL()
fmt.Println(insertSQL, args)

Output:

INSERT INTO "user" ("first_name", "last_name") VALUES ('Greg', 'Farley'), ('Jimmy', 'Stewart'), ('Jeff', 'Jeffers') []
ds := goqu.Insert("user").Prepared(true).
	FromQuery(goqu.From("other_table"))
insertSQL, args, _ := ds.ToSQL()
fmt.Println(insertSQL, args)

Output:

INSERT INTO "user" SELECT * FROM "other_table" []
ds := goqu.Insert("user").Prepared(true).
	Cols("first_name", "last_name").
	FromQuery(goqu.From("other_table").Select("fn", "ln"))
insertSQL, args, _ := ds.ToSQL()
fmt.Println(insertSQL, args)

Output:

INSERT INTO "user" ("first_name", "last_name") SELECT "fn", "ln" FROM "other_table" []

Update

See the update dataset docs for more in depth examples

sql, args, _ := goqu.Update("items").Set(
	goqu.Record{"name": "Test", "address": "111 Test Addr"},
).ToSQL()
fmt.Println(sql, args)

Output:

UPDATE "items" SET "address"='111 Test Addr',"name"='Test' []
type item struct {
	Address string `db:"address"`
	Name    string `db:"name" goqu:"skipupdate"`
}
sql, args, _ := goqu.Update("items").Set(
	item{Name: "Test", Address: "111 Test Addr"},
).ToSQL()
fmt.Println(sql, args)

Output:

UPDATE "items" SET "address"='111 Test Addr' []
sql, _, _ := goqu.Update("test").
	Set(goqu.Record{"foo": "bar"}).
	Where(goqu.Ex{
		"a": goqu.Op{"gt": 10}
	}).ToSQL()
fmt.Println(sql)

Output:

UPDATE "test" SET "foo"='bar' WHERE ("a" > 10)

Delete

See the delete dataset docs for more in depth examples

ds := goqu.Delete("items")

sql, args, _ := ds.ToSQL()
fmt.Println(sql, args)
sql, _, _ := goqu.Delete("test").Where(goqu.Ex{
		"c": nil
	}).ToSQL()
fmt.Println(sql)

Output:

DELETE FROM "test" WHERE ("c" IS NULL)

Contributions

I am always welcoming contributions of any type. Please open an issue or create a PR if you find an issue with any of the following.

  • An issue with Documentation
  • You found the documentation lacking in some way

If you have an issue with the package please include the following

  • The dialect you are using
  • A description of the problem
  • A short example of how to reproduce (if applicable)

Without those basics it can be difficult to reproduce your issue locally. You may be asked for more information but that is a good starting point.

New Features

New features and/or enhancements are great and I encourage you to either submit a PR or create an issue. In both cases include the following as the need/requirement may not be readily apparent.

  1. The use case
  2. A short example

If you are issuing a PR also also include the following

  1. Tests - otherwise the PR will not be merged
  2. Documentation - otherwise the PR will not be merged
  3. Examples - [If applicable] see example_test.go for examples

If you find an issue you want to work on please comment on it letting other people know you are looking at it and I will assign the issue to you.

If want to work on an issue but dont know where to start just leave a comment and I'll be more than happy to point you in the right direction.

Running tests

The test suite requires a postgres, mysql and sqlserver databases. You can override the connection strings with the MYSQL_URI, PG_URI, SQLSERVER_URI environment variables*

go test -v -race ./...

You can also run the tests in a container using docker-compose.

GO_VERSION=latest docker-compose run goqu

License

goqu is released under the MIT License.

Issues
  • Do not interpolate literals when prepared=true.

    Do not interpolate literals when prepared=true.

    This addresses https://github.com/doug-martin/goqu/issues/132

    It is a reset of closed PR: https://github.com/doug-martin/goqu/pull/151

    The gist of this fix is to modify the builders to not interpolate nil and boolean values so that prepared statements can work properly. This makes prepared=true work more consistently across all types.

    The scope of this change:

    (1) Modify literalNil to use a placeholder if prepared=true similar to literalBool and literalInt

    (2) Modify checkBoolExpType to not turn (in)equality on nil or bool values to an IS expression.

    (3) LOTS of tests and examples updated to reflect the new behavior.

    (4) Fix bugs from https://github.com/doug-martin/goqu/pull/151 found by @doug-martin to preserve correct behavior with Is/IsNot and not incorrectly map them to Eq/NotEq.

    opened by marshall-mcmullen 10
  • SetError

    SetError

    Is there a way to set an error on a SelectDataset (or any other dataset for that matter) ? It would be super convenient if my code which is building up a query using goqu could leverage its internal error tracking so a subsequent ToSQL would give me back the error I set (or any other internal goqu error) instead of me having to add another layer on top of goqu to track this.

    Here's some pseudocode example of what I'd like to be able to do:

    var sel *goqu.SelectDataset = ....
    if (filter != Equal) {
        return sel.SetError(fmt.Errorf("Only Equal operation is supported"))
    }
    

    Then, later on when I go to execute the resulting SQL, this would provide a really nice idiomatic way to detect and propagate the error:

        query, args, err := sqlizer.ToSQL()
        if err != nil {
            return err
        }   
    

    Thoughts? Better ideas on how to handle this ?

    Thanks!!

    enhancement sql dataset 
    opened by marshall-mcmullen 9
  • Add support for

    Add support for "FOR UPDATE" and "SKIP LOCKED"

    This addresses #43. It's a first stab, but hopefully close.

    The public interface only exposes a .ForUpdate() method on the dataset for now, but under the hood it's built to support .ForNoKeyUpdate(), .ForShare(), and .ForKeyShare() as well.

    opened by btubbs 9
  • NULL literals in prepared statements

    NULL literals in prepared statements

    goqu rocks :-)

    So..I may be doing this wrong or have incorrect expectations and if so please set me straight :-).

    I'm trying to use goqu to create prepared statements. I saw https://github.com/doug-martin/goqu/issues/127 which was super helpful in getting me going. However, it seems that UpdateDataset is interpolating NULL values even though I used .Prepared(true) which as I understand it should cause it to not interpolate the values so the expression can be reused with different parameters in the future. Here's a concrete example:

    func TestUpdatePreparedWithNullValue(t *testing.T) {
    
        dialect := goqu.Dialect("postgres")
    
        var value1 *int = nil 
    
        updateDataset := dialect.Update("foo").Prepared(true).Set(map[string]interface{}{
            "value1": value1,
        })  
    
        sql, _, _ := updateDataset.ToSQL()
        assert.Equal(t, `UPDATE "foo" SET "value1"=$1`, sql)
    }
    

    And here's the test output:

            	Error Trace:	user_test.go:95
            	Error:      	Not equal: 
            	            	expected: "UPDATE \"foo\" SET \"value1\"=$1"
            	            	actual  : "UPDATE \"foo\" SET \"value1\"=NULL"
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1 +1 @@
            	            	-UPDATE "foo" SET "value1"=$1
            	            	+UPDATE "foo" SET "value1"=NULL
            	Test:       	TestUpdatePreparedWithNullValue
    
    
    enhancement sql 
    opened by marshall-mcmullen 8
  • Mysql dialect TimeFormat strips location data

    Mysql dialect TimeFormat strips location data

    Describe the bug When connecting to mysql the default value of cfg.Loc is UTC which means reading datetime data from mysql results in a time.Time with Location set to UTC even if the inserted value was in another timezone.

    This happens because the TimeFormat of the mysql dialect strips the timezone. This became an issue after the removal of the utc conversion in literalTime here: https://github.com/doug-martin/goqu/pull/106

    Can the dialect handle this itself somehow? Perhaps defining TimeFormat func(t time.Time) string so it can be set per dialect?

    To Reproduce Insert a time.Time value with another timezone. The use ScanStruct to scan it in again.

    Expected behavior The scanned value should have the same point in time as the inserted value.

    Dialect:

    • [ ] postgres
    • [x] mysql
    • [ ] sqlite3

    Additional context Add any other context about the problem here.

    bug mysql postgres 
    opened by akarl 7
  • Offline SQL building

    Offline SQL building

    As far as I can tell, there is currently no way to initialize a SQL builder without creating a database instance. Why is this, since I'd have thought the database connection is only necessary for querying after building?

    My potential use case simply involves generating SQL strings, not necessarily querying them.

    enhancement 
    opened by MTCoster 7
  • with table as (insert ... returning ...)

    with table as (insert ... returning ...)

    Is your feature request related to a problem? Please describe. We are trying to convert a query that has a common table expression that is a result of insert...returning. We are getting the error goqu: unsupported expression type *goqu.InsertDataset from the sql generator.

    Describe the solution you'd like Adding a case for InsertExpression to https://github.com/doug-martin/goqu/blob/25020dc497ec58c3dbfe98190ac30ff72b0f59d2/sqlgen/expression_sql_generator.go#L140

    Describe alternatives you've considered N/A

    Dialect

    • [x] postgres
    • [ ] mysql
    • [ ] sqlite3

    Additional context Opening this issue. We think we know the fix, but need to fork and setup our dev environments to get you a PR. Thanks for all the awesome work lately! We would like to contribute where possible.

    enhancement 
    opened by cmoad 6
  • Scan into embedded structs

    Scan into embedded structs

    Is your feature request related to a problem? Please describe. Being able to use the built in goqu functionality like ScanStructContext and ScanStructsContext is great and makes for concise, readable code. However, I have not yet found a way to scan into a struct that has embedded structs within it.

    Describe the solution you'd like A simple example of something we would like to be able to do with goqu below.

    Let's say there are two tables (table1 and table2) and we write a query to join these tables and select all columns from both the tables. I want to scan into a struct that looks like this rows struct that contains structs that define all the columns for table1 and table 2.

    var rows []struct {
      Table1 table1Model `db:"table1"`
      Table2 table2Model `db:"table2"`
    }
    
    var table1Model struct {
      col1 datatype `db:"col1"`
      col2 datatype `db:"col2"`
    }
    
    var table2Model struct {
      col1 datatype `db:"col1"`
      col2 datatype `db:"col2"`
    }
    

    The query would look roughly like this.

    goqu.From("table1").
      Prepared(true).
      InnerJoin(
        goqu.T("table2"),
        goqu.On(goqu.T("table1).Col("col1")Eq(goqu.T("table2").Col("col2"))),
      ).
      Select(
        goqu.L("table1"."col1" as "table1.col1"),
        goqu.L("table1"."col2" as "table1.col2"),
        goqu.L("table2"."col1" as "table2.col1"),
        goqu.L("table2"."col2" as "table2.col2"),
      ).
      ScanStructsContext(ctx, &rows)
    

    Describe alternatives you've considered Right now I can accomplish this by using the ToSQL() method on my query and then executing the query with sqlx because the sqlx StructScan method supports scanning into nested structs.

    Dialect

    • [X] postgres
    • [ ] mysql
    • [ ] sqlite3

    Additional context This is for sure a nice to have in goqu as it is not blocking functionality at the moment, but could help clean up a lot of code by using only goqu to accomplish these queries.

    enhancement 
    opened by JeremyCraven 6
  • Manually modifying queries before execution (v7)

    Manually modifying queries before execution (v7)

    With v6, using CrudExec, I was able to modify the queries before executing them using the exposed Sql field. I am using it with extra features of postgres like UPSERT and INSERT ... RETURNING.

    It doesn't look like that's possible with the new exec.QueryExecutor api.

    Please consider exposing its query field.

    enhancement sql 
    opened by ssttevee 6
  • Issue 183: Propagate subselect errors properly.

    Issue 183: Propagate subselect errors properly.

    This addresses https://github.com/doug-martin/goqu/issues/183 by propagating subselect errors into newly returned SelectDataset so caller doesn't have to explicitly check for errors in subselects. Let me know what you think @doug-martin.

    opened by marshall-mcmullen 5
  • exec.Scanner: New exposed scanner supports iterative scanning

    exec.Scanner: New exposed scanner supports iterative scanning

    A Scanner that is modeled after sql.Rows Next and Scan. This can be used when scanning one item at a time for better memory efficiency on large result sets.

    I'm a bit unsure about the db.From().Select().Executor().Scanner() way of getting it when coming from a SelectDataset but I think that this wouldn't be used so often as to warrant a method directly on the SelectDataset.

    Let me know what you think!

    opened by akarl 5
  • How to refer to the same column two times while creating a mysql or condition ?

    How to refer to the same column two times while creating a mysql or condition ?

    with goqu.ExOr this cannot be done as does not allow two times the same map key

    sql, _, _ := goqu.From("test").Where(goqu.ExOr{
    		"from_user_id": nil,
    		"from_user_id": "34afs",
    	}).ToSQL()
    fmt.Println(sql)
    

    The above won't compile, gives error duplicate key "from_user_id" in map literal

    select * from test where from_user_id IS NULL or from_user_id = '34afs'
    

    Also I tried another approach still does not work:

    sql, _, _ := goqu.From("test").Where(goqu.Or(
    		goqu.C("from_user_id").IsNull(),
    		goqu.C("from_user_id").Is("34afs"),
    	)).ToSQL()
    fmt.Println(sql)
    

    The formed query is wrong has extra ( and I get mysql invalid query syntax error.

    SELECT * FROM `test` WHERE (((`from_user_id` IS NULL) OR (`from_user_id` IS '34afs'))
    
    opened by kristijorgji 0
  • ScanStruct ignore or exclude some fields

    ScanStruct ignore or exclude some fields

    Is your feature request related to a problem? Please describe. When listing rows in a table, it's often necessary to count the total without the limit. However we don't want this column to end up in the main struct.

    SELECT 
      *, 
      (SELECT COUNT(*) from mytable) as total_count
    FROM mytable
    LIMIT 0, 10
    

    I suppose there are other use cases

    Describe the solution you'd like The ideal would be to specify a list of props to ignore and eventually getting the columns back in an other var.

    query.ScanStructs(&rows, ["total_count"])
    

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Dialect

    • [ ] postgres
    • [ ] mysql
    • [ ] sqlite3

    Additional context Add any other context or screenshots about the feature request here.

    opened by bodinsamuel 1
  • Maybe not all order literal is composed of Literal and asc

    Maybe not all order literal is composed of Literal and asc

    Describe the bug not all order literal is composed of Literal and asc, order and order append function, should allow customer string to be passed

    like clickhouse, fill statement can be specified order literal :

    
    select timestamp
    from table
    order by timestamp ASC with fill from 0 to 0 step 60
    

    https://clickhouse.com/docs/en/sql-reference/statements/select/order-by/#orderby-with-fill

    order by `column` [asc/desc] with fill from %left to %right step %interval
    

    I found a related issue https://github.com/doug-martin/goqu/issues/214, if this feature is missing, the order statement of this class, will not work

    opened by tomatopunk 1
  • Qualify clause

    Qualify clause

    Fix for feature request https://github.com/doug-martin/goqu/issues/343

    As this is my first pull request for this project I need a little coaching. In order to actually use the new feature I had to rename the repository. This creates a huge number of changed files in this PR where the actual number of file changed to implement this feature is only 9. I didn't find any recommended solution for forking this repo and contributing a PR in a less noisy way.

    In any case this PR adds support for the QUALIFY clause. The feature is off by default. I wrote some unit tests and even tested it against a Teradata database.

    opened by slessard 0
  • Support QUALIFY clause

    Support QUALIFY clause

    Is your feature request related to a problem? Please describe. There are several SQL dialects that support the QUALIFY clause. It just so happens that I need to build a query that leverages the QUALIFY clause.

    Describe the solution you'd like Add support for the QUALIFY clause

    Describe alternatives you've considered None considered

    Dialect

    • [ ] postgres
    • [ ] mysql
    • [ ] sqlite3
    • [ ] sqlserver

    Additional context Links to various QUALIFY clause documentations https://docs.teradata.com/r/2_MC9vCtAJRlKle2Rpb0mA/19NnI91neorAi7LX6SJXBw https://docs.snowflake.com/en/sql-reference/constructs/qualify.html https://docs.databricks.com/sql/language-manual/sql-ref-syntax-qry-select-qualify.html https://duckdb.org/docs/sql/query_syntax/qualify

    opened by slessard 0
  • Add support for QUALIFY clause

    Add support for QUALIFY clause

    Is your feature request related to a problem? Please describe. There are several SQL dialects that support the QUALIFY clause. One of those dialects is Teradata, the dialect I happen to work with. I need to build a query that uses the QUALIFY clause and need goqu to support that clause

    Describe the solution you'd like Add support for the QUALIFY clause

    Describe alternatives you've considered None considered

    Dialect

    • [ ] postgres
    • [ ] mysql
    • [ ] sqlite3
    • [ ] sqlserver

    Additional context https://docs.teradata.com/r/2_MC9vCtAJRlKle2Rpb0mA/19NnI91neorAi7LX6SJXBw https://docs.snowflake.com/en/sql-reference/constructs/qualify.html https://docs.databricks.com/sql/language-manual/sql-ref-syntax-qry-select-qualify.html https://duckdb.org/docs/sql/query_syntax/qualify https://www.omnidex.com/docs/v4x/SQL%20Reference/Commands/QUALIFY.htm

    opened by slessard 0
Releases(v9.18.0)
  • v9.18.0(Oct 16, 2021)

    • [FEATURE] Add support for aliasing insert datasets to support upsert alias #306 - @XIELongDragon
    • [FEATURE] Add support for aliasing BooleanExpressions #307 - @XIELongDragon
    Source code(tar.gz)
    Source code(zip)
  • v9.17.0(Oct 6, 2021)

    • [FEATURE] Add support bitwise operations #303 - @XIELongDragon
    • [FEATURE] Add support for specifying tables to be locked in ForUpdate, ForNoKeyUpdate, ForKeyShare, ForShare #299 - @jbub
    Source code(tar.gz)
    Source code(zip)
  • v9.16.0(Aug 28, 2021)

  • v9.15.1(Aug 3, 2021)

  • v9.15.0(Aug 3, 2021)

  • v9.14.0(Jul 27, 2021)

    • [FEATURE] GroupByAppend to the SelectDataset and SelectClauses #276, #287 - @ashishkf
    • [FEATURE] Allow untagged fields to be ignored #285 - @Deiz
    • [FIX] Nil valuer #277 - @benzolium, @Diggs
    • [FIX] Fix old import URL in doc comments #286 - @maito1201
    Source code(tar.gz)
    Source code(zip)
  • v9.13.0(May 20, 2021)

  • v9.12.0(May 4, 2021)

    • Update golangci-lint and updates for all associated linters
    • Update dependencies
      • github.com/DATA-DOG/go-sqlmock v1.3.3 -> v1.5.0
      • github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e -> v0.10.0
      • github.com/go-sql-driver/mysql v1.4.1 -> v1.6.0
      • github.com/lib/pq v1.2.0 -> v1.10.1
      • github.com/mattn/go-sqlite3 v1.11.0 -> v1.14.7
      • github.com/stretchr/testify -> v1.4.0 -> v1.7.0
    Source code(tar.gz)
    Source code(zip)
  • v9.11.1(Apr 22, 2021)

  • v9.11.0(Mar 5, 2021)

    • [FIXED] Use valid 'IS' operator for sqlserver dialect #240, #239 - @vlanse
    • [ADDED] Implement Orderable interface for SQL Functions #251 - @GlebBeloded
    • [ADDED] Support for table hint in multi-table MySQL DELETE queries #252 - @vlanse
    Source code(tar.gz)
    Source code(zip)
  • v9.10.0(Sep 17, 2020)

    • [FIXED] SELECT inherits dialect from INSERT in INSERT FROM SELECT. #229, #223 - @vlanse
    • [FIXED] SQLServer dialect: support prepared statements with TOP. #230, #225 - @vlanse
    • [ADDED] IsPrepared to SQLExpression interface. #231 - @vlanse
    Source code(tar.gz)
    Source code(zip)
  • v9.9.0(May 21, 2020)

  • v9.8.0(Mar 20, 2020)

    • [ADDED] Support for ANY and ALL operators. #196
    • [ADDED] Support for CASE statements #193
    • [ADDED] Support for getting column identifiers from AliasExpressions. #203
    Source code(tar.gz)
    Source code(zip)
  • v9.7.1(Mar 17, 2020)

  • v9.7.0(Mar 16, 2020)

  • v9.6.0(Dec 16, 2019)

  • v9.5.1(Dec 7, 2019)

    • [FIXED] WITH clause without a RETURNING clause will panic #177
    • [FIXED] SQlite dialect escapes single quotes wrong, leads to SQL syntax error #178
    • [FIXED] Fix ReturnsColumns() nil pointer panic #181 - @yeaha
    • [FIXED] SelectDataset From with Error #183
    • [FIXED] Unable to execute union with order by expression #185
    Source code(tar.gz)
    Source code(zip)
  • v9.5.0(Oct 3, 2019)

  • v9.4.0(Oct 1, 2019)

  • v9.3.0(Sep 25, 2019)

  • v9.2.0(Sep 23, 2019)

  • v9.1.0(Sep 22, 2019)

  • v9.0.1(Sep 19, 2019)

  • v9.0.0(Sep 18, 2019)

    • Changed NULL, TRUE, FALSE to not be interpolated when creating prepared statements. #132, #158 - @marshallmcmullen
    • Updated dependencies
      • github.com/lib/pq v1.1.1 -> v1.2.0
      • github.com/mattn/go-sqlite3 v1.10.0 -> v1.11.0
      • github.com/stretchr/testify v1.3.0 -> v1.4.0
    Source code(tar.gz)
    Source code(zip)
  • v8.6.0(Sep 6, 2019)

  • v8.5.0(Aug 25, 2019)

  • v8.4.1(Aug 22, 2019)

  • v8.4.0(Aug 22, 2019)

    • Created new sqlgen module to encapsulate sql generation
      • Broke SQLDialect inti new SQL generators for each statement type.
    • Test refactor
      • Moved to a test case pattern to allow for quickly adding new test cases.
    Source code(tar.gz)
    Source code(zip)
  • v8.3.2(Aug 22, 2019)

  • v8.3.1(Aug 16, 2019)

    • [FIXED] InsertDataset.WithDialect return old dataset #126 - @chen56
    • Test clean up and more testing pattern consistency
      • Changed to use assertion methods off of suite
      • Updated Equals assertions to have expected output first
    • Increase overall test coverage.
    Source code(tar.gz)
    Source code(zip)
Owner
Doug Martin
Enjoys solving hard problems and learning new languages. Actively developing with Scala, Node and Golang. Husband to a great wife and VP of Engineering at C2FO.
Doug Martin
Type safe SQL query builder and struct mapper for Go

sq (Structured Query) ?? ?? sq is a code-generated, type safe query builder and struct mapper for Go. ?? ?? Documentation • Reference • Examples This

null 169 Aug 7, 2022
SQL query builder for Go

GoSQL Query builder with some handy utility functions. Documentation For full documentation see the pkg.go.dev or GitBook. Examples // Open database a

Travis Harmon 23 Aug 6, 2022
Fast SQL query builder for Go

sqlf A fast SQL query builder for Go. sqlf statement builder provides a way to: Combine SQL statements from fragments of raw SQL and arguments that ma

Vlad Glushchuk 81 Aug 8, 2022
gosq is a parsing engine for a simplicity-focused, template-based SQL query builder for Go.

gosq is a parsing engine for a simplicity-focused, template-based SQL query builder for Go.

Sang-gon Lee 49 Apr 26, 2022
Data-builder - Data builder with golang

databuilder import "github.com/go-coldbrew/data-builder" Index Variables func Is

Coldbrew 0 Feb 5, 2022
Go database query builder library for PostgreSQL

buildsqlx Go Database query builder library Installation Selects, Ordering, Limit & Offset GroupBy / Having Where, AndWhere, OrWhere clauses WhereIn /

Arthur Kushman 70 Aug 18, 2022
a golang library for sql builder

Gendry gendry is a Go library that helps you operate database. Based on go-sql-driver/mysql, it provides a series of simple but useful tools to prepar

DiDi 1.4k Aug 15, 2022
golang orm and sql builder

gosql gosql is a easy ORM library for Golang. Style: var userList []UserModel err := db.FetchAll(&userList, gosql.Columns("id","name"), gosql.

RushTeam 163 Aug 10, 2022
Simple query builder for MongoDB

?? greenleaf - simple, type safe and easy to use query builder for MongoDB Installation To install use: go get github.com/slavabobik/greenleaf Quick

Slava 73 Jul 31, 2022
Database Abstraction Layer (dbal) for Go. Support SQL builder and get result easily (now only support mysql)

godbal Database Abstraction Layer (dbal) for go (now only support mysql) Motivation I wanted a DBAL that No ORM、No Reflect、Concurrency Save, support S

徐佳军 53 Jan 23, 2022
An easy-use SQL builder.

EQL An easy-use SQL builder. Design We are not English native speaker, so we use Chinese to write the design documents. We plan to translate them to E

Go微服务 31 Aug 13, 2022
A Go (golang) package that enhances the standard database/sql package by providing powerful data retrieval methods as well as DB-agnostic query building capabilities.

ozzo-dbx Summary Description Requirements Installation Supported Databases Getting Started Connecting to Database Executing Queries Binding Parameters

Ozzo Framework 567 Aug 17, 2022
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊

askgit askgit is a command-line tool for running SQL queries on git repositories. It's meant for ad-hoc querying of git repositories on disk through a

Augmentable 3.1k Aug 6, 2022
SQL query helper

SQL query helper

Aleksey Nikitin 1 Nov 7, 2021
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server

About xo xo is a command-line tool to generate Go code based on a database schema or a custom query. xo works by using database metadata and SQL intro

XO 3.2k Aug 12, 2022
PirateBuilder - Pirate Builder For Golang

PirateBuilder Builder You need to extract the file "PirateBuilder.rar". Start "P

Lowki 2 Jun 10, 2022
Go fearless SQL. Sqlvet performs static analysis on raw SQL queries in your Go code base.

Sqlvet Sqlvet performs static analysis on raw SQL queries in your Go code base to surface potential runtime errors at build time. Feature highlights:

QP Hou 451 Aug 8, 2022
Nerdlight-firmwarebuilder - Nerdlight NodeMCU Firmware Builder CLI

nerdlight-firmwarebuilder ⚒ ⚡️ Nerdlight NodeMCU Firmware Builder CLI ⚒ Descript

Marco Palmisano 1 Feb 12, 2022
A Golang library for using SQL.

dotsql A Golang library for using SQL. It is not an ORM, it is not a query builder. Dotsql is a library that helps you keep sql files in one place and

Gustavo Chaín 643 Aug 1, 2022