Skip to content

Commit

Permalink
v9.7.1
Browse files Browse the repository at this point in the history
* Fix all formatting for golangci-lint
* Move to golangci-lint github action
  • Loading branch information
doug-martin committed Mar 17, 2020
1 parent 5edc406 commit 0b21ed8
Show file tree
Hide file tree
Showing 45 changed files with 178 additions and 241 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v1
- name: Run golangci-lint
uses: actions-contrib/golangci-lint@v1
- name: Test
env:
GO_VERSION: ${{ matrix.go_version }}
Expand Down
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v9.7.1

* Fix all formatting for golangci-lint
* Move to golangci-lint github action

# v9.7.0

* [ADDED] Support for sqlserver dialect [#197](https://github.com/doug-martin/goqu/issues/197),[#205](https://github.com/doug-martin/goqu/issues/205) - [@vlanse](https://github.com/vlanse)
Expand Down
1 change: 0 additions & 1 deletion database_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func ExampleDatabase_ExecContext() {
}

func ExampleDatabase_From() {

db := getDb()
var names []string

Expand Down
2 changes: 1 addition & 1 deletion database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (dtml *dbTestMockLogger) Printf(format string, v ...interface{}) {
dtml.Messages = append(dtml.Messages, fmt.Sprintf(format, v...))
}

func (dtml *dbTestMockLogger) Reset(format string, v ...interface{}) {
func (dtml *dbTestMockLogger) Reset() {
dtml.Messages = dtml.Messages[0:0]
}

Expand Down
1 change: 0 additions & 1 deletion delete_dataset_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func ExampleDeleteDataset_Executor_returning() {
}

func ExampleDeleteDataset_With() {

sql, _, _ := goqu.Delete("test").
With("check_vals(val)", goqu.From().Select(goqu.L("123"))).
Where(goqu.C("val").Eq(goqu.From("check_vals").Select("val"))).
Expand Down
1 change: 0 additions & 1 deletion delete_dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ func (dds *deleteDatasetSuite) TestExecutor() {
}

func (dds *deleteDatasetSuite) TestSetError() {

err1 := errors.New("error #1")
err2 := errors.New("error #2")
err3 := errors.New("error #3")
Expand Down
2 changes: 0 additions & 2 deletions dialect/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/doug-martin/goqu/v9"
"github.com/doug-martin/goqu/v9/dialect/mysql"
_ "github.com/doug-martin/goqu/v9/dialect/mysql"
_ "github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/suite"
)
Expand Down Expand Up @@ -388,7 +387,6 @@ func (mt *mysqlTest) TestInsertReturning() {
e := entry{Int: 10, Float: 1.000000, String: "1.000000", Time: now, Bool: true, Bytes: []byte("1.000000")}
_, err := ds.Insert().Rows(e).Returning(goqu.Star()).Executor().ScanStruct(&e)
mt.Error(err)

}

func (mt *mysqlTest) TestUpdate() {
Expand Down
1 change: 0 additions & 1 deletion dialect/sqlite3/sqlite3_dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func (sds *sqlite3DialectSuite) TestBooleanOperations() {
sql, _, err = ds.Where(goqu.C("a").NotILike(regexp.MustCompile("(a|b)"))).ToSQL()
sds.NoError(err)
sds.Equal("SELECT * FROM `test` WHERE (`a` NOT REGEXP '(a|b)')", sql)

}

func TestDatasetAdapterSuite(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion dialect/sqlite3/sqlite3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ func (st *sqlite3Suite) TestInsert_returning() {
e := entry{Int: 10, Float: 1.000000, String: "1.000000", Time: now, Bool: true, Bytes: []byte("1.000000")}
_, err := ds.Insert().Rows(e).Returning(goqu.Star()).Executor().ScanStruct(&e)
st.Error(err)

}

func (st *sqlite3Suite) TestUpdate() {
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
- "POSTGRES_HOST_AUTH_METHOD=trust"
expose:
- "5432"
ports:
- "5432:5432"

mysql:
image: "mysql:${MYSQL_VERSION}"
Expand All @@ -17,6 +19,8 @@ services:
- "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
expose:
- "3306"
ports:
- "3306:3306"

sqlserver:
image: "mcr.microsoft.com/mssql/server:${SQLSERVER_VERSION}"
Expand All @@ -25,6 +29,8 @@ services:
- "SA_PASSWORD=qwe123QWE"
expose:
- "1433"
ports:
- "1433:1433"

goqu:
image: "golang:${GO_VERSION}"
Expand Down
5 changes: 1 addition & 4 deletions exec/query_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (qes *queryExecutorSuite) TestWithError() {
}

func (qes *queryExecutorSuite) TestToSQL() {

db, _, err := sqlmock.New()
qes.NoError(err)

Expand All @@ -71,7 +70,6 @@ func (qes *queryExecutorSuite) TestToSQL() {
qes.NoError(err)
qes.Equal(`SELECT * FROM "items"`, query)
qes.Empty(args)

}

func (qes *queryExecutorSuite) TestScanStructs_withTaggedFields() {
Expand Down Expand Up @@ -160,7 +158,7 @@ func (qes *queryExecutorSuite) TestScanStructs_withPointerFields() {

func (qes *queryExecutorSuite) TestScanStructs_withPrivateFields() {
type StructWithPrivateTags struct {
private string // nolint:structcheck,unused
private string // nolint:structcheck,unused // need for test
Address string `db:"address"`
Name string `db:"name"`
}
Expand Down Expand Up @@ -1015,7 +1013,6 @@ func (qes *queryExecutorSuite) TestScanStruct_taggedStructs() {
Age: testAge2,
},
}, item)

}

func (qes *queryExecutorSuite) TestScanVals() {
Expand Down
1 change: 0 additions & 1 deletion exp/col.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func NewColumnListExpression(vals ...interface{}) ColumnListExpression {
} else {
panic(fmt.Sprintf("Cannot created expression from %+v", val))
}

}
}
return columnList{columns: cols}
Expand Down
2 changes: 1 addition & 1 deletion exp/exp_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func createOredExpressionFromMap(lhs IdentifierExpression, op Op) ([]Expression,
return ors, nil
}

// nolint:gocyclo
// nolint:gocyclo // not complex just long
func createExpressionFromOp(lhs IdentifierExpression, opKey string, op Op) (exp Expression, err error) {
switch strings.ToLower(opKey) {
case EqOp.String():
Expand Down
36 changes: 24 additions & 12 deletions exp/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,32 @@ func (sfe sqlFunctionExpression) Clone() Expression {
return sqlFunctionExpression{name: sfe.name, args: sfe.args}
}

func (sfe sqlFunctionExpression) Expression() Expression { return sfe }
func (sfe sqlFunctionExpression) Args() []interface{} { return sfe.args }
func (sfe sqlFunctionExpression) Name() string { return sfe.name }
func (sfe sqlFunctionExpression) As(val interface{}) AliasedExpression { return aliased(sfe, val) }
func (sfe sqlFunctionExpression) Eq(val interface{}) BooleanExpression { return eq(sfe, val) }
func (sfe sqlFunctionExpression) Neq(val interface{}) BooleanExpression { return neq(sfe, val) }
func (sfe sqlFunctionExpression) Gt(val interface{}) BooleanExpression { return gt(sfe, val) }
func (sfe sqlFunctionExpression) Gte(val interface{}) BooleanExpression { return gte(sfe, val) }
func (sfe sqlFunctionExpression) Lt(val interface{}) BooleanExpression { return lt(sfe, val) }
func (sfe sqlFunctionExpression) Lte(val interface{}) BooleanExpression { return lte(sfe, val) }
func (sfe sqlFunctionExpression) Between(val RangeVal) RangeExpression { return between(sfe, val) }
func (sfe sqlFunctionExpression) NotBetween(val RangeVal) RangeExpression { return notBetween(sfe, val) }
func (sfe sqlFunctionExpression) Expression() Expression { return sfe }

func (sfe sqlFunctionExpression) Args() []interface{} { return sfe.args }

func (sfe sqlFunctionExpression) Name() string { return sfe.name }

func (sfe sqlFunctionExpression) As(val interface{}) AliasedExpression { return aliased(sfe, val) }

func (sfe sqlFunctionExpression) Eq(val interface{}) BooleanExpression { return eq(sfe, val) }
func (sfe sqlFunctionExpression) Neq(val interface{}) BooleanExpression { return neq(sfe, val) }

func (sfe sqlFunctionExpression) Gt(val interface{}) BooleanExpression { return gt(sfe, val) }
func (sfe sqlFunctionExpression) Gte(val interface{}) BooleanExpression { return gte(sfe, val) }
func (sfe sqlFunctionExpression) Lt(val interface{}) BooleanExpression { return lt(sfe, val) }
func (sfe sqlFunctionExpression) Lte(val interface{}) BooleanExpression { return lte(sfe, val) }

func (sfe sqlFunctionExpression) Between(val RangeVal) RangeExpression { return between(sfe, val) }

func (sfe sqlFunctionExpression) NotBetween(val RangeVal) RangeExpression {
return notBetween(sfe, val)
}

func (sfe sqlFunctionExpression) Like(val interface{}) BooleanExpression { return like(sfe, val) }
func (sfe sqlFunctionExpression) NotLike(val interface{}) BooleanExpression { return notLike(sfe, val) }
func (sfe sqlFunctionExpression) ILike(val interface{}) BooleanExpression { return iLike(sfe, val) }

func (sfe sqlFunctionExpression) NotILike(val interface{}) BooleanExpression {
return notILike(sfe, val)
}
Expand All @@ -46,6 +57,7 @@ func (sfe sqlFunctionExpression) RegexpILike(val interface{}) BooleanExpression
func (sfe sqlFunctionExpression) RegexpNotILike(val interface{}) BooleanExpression {
return regexpNotILike(sfe, val)
}

func (sfe sqlFunctionExpression) In(vals ...interface{}) BooleanExpression { return in(sfe, vals...) }
func (sfe sqlFunctionExpression) NotIn(vals ...interface{}) BooleanExpression {
return notIn(sfe, vals...)
Expand Down
1 change: 0 additions & 1 deletion exp/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func NewInsertExpression(rows ...interface{}) (insertExpression InsertExpression
if ae, ok := rows[0].(AppendableExpression); ok {
return &insert{from: ae}, nil
}

}
return newInsert(rows...)
}
Expand Down
1 change: 0 additions & 1 deletion exp/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ type (
// The table expressions (e.g. LEFT JOIN "my_table", ON (....))
table Expression
}
// todo fix this to use new interfaces
// Container for all joins within a dataset
conditionedJoin struct {
joinExpression
Expand Down
5 changes: 2 additions & 3 deletions exp/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func NewRecordFromStruct(i interface{}, forInsert, forUpdate bool) (r Record, er
return
}

func addFieldToRecord(r Record, val reflect.Value, f util.ColumnData) Record {
func addFieldToRecord(r Record, val reflect.Value, f util.ColumnData) {
v, isAvailable := util.SafeGetFieldByIndex(val, f.FieldIndex)
if !isAvailable {
return r
return
}
switch {
case f.DefaultIfEmpty && util.IsEmptyValue(v):
Expand All @@ -60,5 +60,4 @@ func addFieldToRecord(r Record, val reflect.Value, f util.ColumnData) Record {
default:
r[f.ColumnName] = reflect.Zero(f.GoType).Interface()
}
return r
}
8 changes: 0 additions & 8 deletions exp/select_clauses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (scs *selectClausesSuite) TestSetSelect() {

scs.Equal(NewColumnListExpression(Star()), c.Select())
scs.Equal(NewColumnListExpression("a"), c2.Select())

}

func (scs *selectClausesSuite) TestDistinct() {
Expand Down Expand Up @@ -141,7 +140,6 @@ func (scs *selectClausesSuite) TestSetAlias() {
}

func (scs *selectClausesSuite) TestJoins() {

jc := NewConditionedJoinExpression(
LeftJoinType,
NewIdentifierExpression("", "test", ""),
Expand Down Expand Up @@ -469,7 +467,6 @@ func (scs *selectClausesSuite) TestSetOffset() {
}

func (scs *selectClausesSuite) TestCompounds() {

ce := NewCompoundExpression(UnionCompoundType, newTestAppendableExpression("SELECT * FROM foo", []interface{}{}))

c := NewSelectClauses()
Expand All @@ -480,7 +477,6 @@ func (scs *selectClausesSuite) TestCompounds() {
scs.Equal([]CompoundExpression{ce}, c2.Compounds())
}
func (scs *selectClausesSuite) TestCompoundsAppend() {

ce := NewCompoundExpression(UnionCompoundType, newTestAppendableExpression("SELECT * FROM foo1", []interface{}{}))
ce2 := NewCompoundExpression(UnionCompoundType, newTestAppendableExpression("SELECT * FROM foo2", []interface{}{}))

Expand All @@ -493,7 +489,6 @@ func (scs *selectClausesSuite) TestCompoundsAppend() {
}

func (scs *selectClausesSuite) TestLock() {

l := NewLock(ForUpdate, Wait)

c := NewSelectClauses()
Expand All @@ -505,7 +500,6 @@ func (scs *selectClausesSuite) TestLock() {
}

func (scs *selectClausesSuite) TestSetLock() {

l := NewLock(ForUpdate, Wait)
l2 := NewLock(ForUpdate, NoWait)

Expand All @@ -518,7 +512,6 @@ func (scs *selectClausesSuite) TestSetLock() {
}

func (scs *selectClausesSuite) TestCommonTables() {

cte := NewCommonTableExpression(true, "test", newTestAppendableExpression(`SELECT * FROM "foo"`, []interface{}{}))

c := NewSelectClauses()
Expand All @@ -530,7 +523,6 @@ func (scs *selectClausesSuite) TestCommonTables() {
}

func (scs *selectClausesSuite) TestAddCommonTablesAppend() {

cte := NewCommonTableExpression(true, "test", testSQLExpression("test_cte"))
cte2 := NewCommonTableExpression(true, "test", testSQLExpression("test_cte2"))

Expand Down
5 changes: 0 additions & 5 deletions exp/update_clauses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ func (ucs *updateClausesSuite) TestSetLimit() {
}

func (ucs *updateClausesSuite) TestCommonTables() {

cte := NewCommonTableExpression(true, "test", newTestAppendableExpression(`SELECT * FROM "foo"`, []interface{}{}))

c := NewUpdateClauses()
Expand All @@ -252,7 +251,6 @@ func (ucs *updateClausesSuite) TestCommonTables() {
}

func (ucs *updateClausesSuite) TestAddCommonTablesAppend() {

cte := NewCommonTableExpression(true, "test", testSQLExpression("test_cte"))
cte2 := NewCommonTableExpression(true, "test", testSQLExpression("test_cte2"))

Expand All @@ -265,7 +263,6 @@ func (ucs *updateClausesSuite) TestAddCommonTablesAppend() {
}

func (ucs *updateClausesSuite) TestReturning() {

cl := NewColumnListExpression(NewIdentifierExpression("", "", "col"))

c := NewUpdateClauses()
Expand All @@ -277,7 +274,6 @@ func (ucs *updateClausesSuite) TestReturning() {
}

func (ucs *updateClausesSuite) TestHasReturning() {

cl := NewColumnListExpression(NewIdentifierExpression("", "", "col"))

c := NewUpdateClauses()
Expand All @@ -289,7 +285,6 @@ func (ucs *updateClausesSuite) TestHasReturning() {
}

func (ucs *updateClausesSuite) TestSetReturning() {

cl := NewColumnListExpression(NewIdentifierExpression("", "", "col"))
cl2 := NewColumnListExpression(NewIdentifierExpression("", "", "col2"))

Expand Down
Loading

0 comments on commit 0b21ed8

Please sign in to comment.