From e65d4b2a29c6f957c148d58be51f2386a55c23c6 Mon Sep 17 00:00:00 2001 From: Craig Swank Date: Wed, 18 Dec 2019 13:28:10 -0700 Subject: [PATCH 1/3] Grabbed the lastest changes from git@github.com:elgris/sqrl.git --- go.mod | 3 +++ go.sum | 2 ++ insert.go | 10 ++++++++++ pg/array.go | 2 +- pg/array_test.go | 4 ++-- pg/json.go | 2 +- pg/json_test.go | 4 ++-- 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index d240e3e0..42df04a6 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,9 @@ module github.com/elgris/sqrl require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/parsyl/sqrl v0.1.1 github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/testify v1.2.2 ) + +go 1.13 diff --git a/go.sum b/go.sum index e03ee77d..844db7b2 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/parsyl/sqrl v0.1.1 h1:Ra+UPGdC+6cZ8q5QAyg6uT1YFMoshJB/YYemm2GqzP4= +github.com/parsyl/sqrl v0.1.1/go.mod h1:c9+CEefYyDsx+UNKtJGQONwmenbaCnEbfRumyEQFLMM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= diff --git a/insert.go b/insert.go index a0bbbede..2f6f3f9f 100644 --- a/insert.go +++ b/insert.go @@ -277,6 +277,16 @@ func (b *InsertBuilder) SetMap(clauses map[string]interface{}) *InsertBuilder { return b } +// AppendColumn adds a new column to the insert query. NOTE: you problaby +// don't want to use this for muti-row inserts. +func (b *InsertBuilder) AppendColumn(name string, value interface{}) *InsertBuilder { + b.columns = append(b.columns, name) + for i, vals := range b.values { + b.values[i] = append(vals, value) + } + return b +} + // Select set Select clause for insert query // If Values and Select are used, then Select has higher priority func (b *InsertBuilder) Select(sb *SelectBuilder) *InsertBuilder { diff --git a/pg/array.go b/pg/array.go index 8442851b..3f090402 100644 --- a/pg/array.go +++ b/pg/array.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/elgris/sqrl" + "github.com/parsyl/sqrl" ) // Array converts value into Postgres Array diff --git a/pg/array_test.go b/pg/array_test.go index 33b0497a..51e10252 100644 --- a/pg/array_test.go +++ b/pg/array_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - "github.com/elgris/sqrl" - "github.com/elgris/sqrl/pg" + "github.com/parsyl/sqrl" + "github.com/parsyl/sqrl/pg" "github.com/stretchr/testify/assert" ) diff --git a/pg/json.go b/pg/json.go index 7aa414e6..dce945c4 100644 --- a/pg/json.go +++ b/pg/json.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/elgris/sqrl" + "github.com/parsyl/sqrl" ) // JSONB converts value into Postgres JSONB diff --git a/pg/json_test.go b/pg/json_test.go index 4c5eb2cb..1ae78056 100644 --- a/pg/json_test.go +++ b/pg/json_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - "github.com/elgris/sqrl" - "github.com/elgris/sqrl/pg" + "github.com/parsyl/sqrl" + "github.com/parsyl/sqrl/pg" "github.com/stretchr/testify/assert" ) From d58d7d568a7389e3dab9bbb5b4a4eea3fea461a8 Mon Sep 17 00:00:00 2001 From: Craig Swank Date: Wed, 18 Dec 2019 13:33:05 -0700 Subject: [PATCH 2/3] fix modules --- go.mod | 3 +-- go.sum | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 42df04a6..d3c37445 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,7 @@ -module github.com/elgris/sqrl +module github.com/parsyl/sqrl require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/parsyl/sqrl v0.1.1 github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/testify v1.2.2 ) diff --git a/go.sum b/go.sum index 844db7b2..e03ee77d 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/parsyl/sqrl v0.1.1 h1:Ra+UPGdC+6cZ8q5QAyg6uT1YFMoshJB/YYemm2GqzP4= -github.com/parsyl/sqrl v0.1.1/go.mod h1:c9+CEefYyDsx+UNKtJGQONwmenbaCnEbfRumyEQFLMM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= From 039629663c102fbc1ac3104369e49072c68f0802 Mon Sep 17 00:00:00 2001 From: Craig Swank Date: Mon, 7 Jul 2025 06:26:46 -0600 Subject: [PATCH 3/3] cross join --- select.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/select.go b/select.go index de9fb736..6a1d44f4 100644 --- a/select.go +++ b/select.go @@ -225,7 +225,8 @@ func (b *SelectBuilder) Columns(columns ...string) *SelectBuilder { // Column adds a result column to the query. // Unlike Columns, Column accepts args which will be bound to placeholders in // the columns string, for example: -// Column("IF(col IN ("+Placeholders(3)+"), 1, 0) as col", 1, 2, 3) +// +// Column("IF(col IN ("+Placeholders(3)+"), 1, 0) as col", 1, 2, 3) func (b *SelectBuilder) Column(column interface{}, args ...interface{}) *SelectBuilder { b.columns = append(b.columns, newPart(column, args...)) @@ -271,6 +272,11 @@ func (b *SelectBuilder) RightJoin(join string, rest ...interface{}) *SelectBuild return b.JoinClause("RIGHT JOIN "+join, rest...) } +// CrossJoin adds a CROSS JOIN clause to the query. +func (b *SelectBuilder) CrossJoin(join string, rest ...interface{}) *SelectBuilder { + return b.JoinClause("CROSS JOIN "+join, rest...) +} + // Where adds an expression to the WHERE clause of the query. // // Expressions are ANDed together in the generated SQL.