diff --git a/go.mod b/go.mod index d240e3e0..d3c37445 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,9 @@ -module github.com/elgris/sqrl +module github.com/parsyl/sqrl require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/testify v1.2.2 ) + +go 1.13 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" ) 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.