Skip to content

Commit 5edc406

Browse files
authored
Merge pull request #208 from doug-martin/v9.7.0
v9.7.0
2 parents 38a583f + 198a7ac commit 5edc406

81 files changed

Lines changed: 74910 additions & 39 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/go.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ on:
77
pull_request: # Specify a second event with pattern matching
88
jobs:
99
test:
10-
name: Test go - ${{ matrix.go_version }} mysql - ${{ matrix.db_versions.mysql_version}} postgres - ${{ matrix.db_versions.postgres_version}}
10+
name: Test go - ${{ matrix.go_version }} mysql - ${{ matrix.db_versions.mysql_version}} postgres - ${{ matrix.db_versions.postgres_version}} sqlserver- ${{ matrix.db_versions.sqlserver_version}}
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
1414
go_version: ["1.10", "1.11", "latest"]
1515
db_versions:
16-
- mysql_version: 5
17-
postgres_version: 9.6
18-
- mysql_version: 5
19-
postgres_version: "10.10"
20-
- mysql_version: 8
21-
postgres_version: 11.5
16+
- mysql_version: 5
17+
postgres_version: 9.6
18+
sqlserver_version: "2017-CU8-ubuntu"
19+
- mysql_version: 5
20+
postgres_version: "10.10"
21+
sqlserver_version: "2017-CU8-ubuntu"
22+
- mysql_version: 8
23+
postgres_version: 11.5
24+
sqlserver_version: "2017-CU8-ubuntu"
2225
steps:
2326
- name: checkout
2427
uses: actions/checkout@v1
@@ -27,7 +30,7 @@ jobs:
2730
GO_VERSION: ${{ matrix.go_version }}
2831
MYSQL_VERSION: ${{ matrix.db_versions.mysql_version }}
2932
POSTGRES_VERSION: ${{ matrix.db_versions.postgres_version }}
33+
SQLSERVER_VERSION: ${{ matrix.db_versions.sqlserver_version }}
3034
run: docker-compose run goqu-coverage
3135
- name: Upload coverage to Codecov
3236
uses: codecov/codecov-action@v1
33-

.golangci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ linters:
4545
- gochecknoglobals
4646
- gochecknoinits
4747
- dupl
48+
- gomnd
49+
- funlen
50+
- wsl
4851

4952
run:
5053
skip-dirs:
@@ -59,6 +62,6 @@ issues:
5962
# golangci.com configuration
6063
# https://github.com/golangci/golangci/wiki/Configuration
6164
service:
62-
golangci-lint-version: 1.15.x # use the fixed version to not introduce new linters unexpectedly
65+
golangci-lint-version: 1.23.x # use the fixed version to not introduce new linters unexpectedly
6366
prepare:
64-
- echo "here I can run custom commands, but no preparation needed for this repo"
67+
- echo "here I can run custom commands, but no preparation needed for this repo"

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v9.7.0
2+
3+
* [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)
4+
15
# v9.6.0
26

37
* [ADDED] Support for Lateral queries [#182](https://github.com/doug-martin/goqu/issues/182)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
phony:
44

55
lint:
6-
docker run --rm -v ${CURDIR}:/app -w /app golangci/golangci-lint:v1.21.0 golangci-lint run -v
6+
docker run --rm -v ${CURDIR}:/app -w /app golangci/golangci-lint:v1.23.8 golangci-lint run -v

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ We tried a few other sql builders but each was a thin wrapper around sql fragmen
6464

6565
## Docs
6666

67-
* [Dialect](./docs/dialect.md) - Introduction to different dialects (`mysql`, `postgres`, `sqlite3` etc)
67+
* [Dialect](./docs/dialect.md) - Introduction to different dialects (`mysql`, `postgres`, `sqlite3`, `sqlserver` etc)
6868
* [Expressions](./docs/expressions.md) - Introduction to `goqu` expressions and common examples.
6969
* [Select Dataset](./docs/selecting.md) - Docs and examples about creating and executing SELECT sql statements.
7070
* [Insert Dataset](./docs/inserting.md) - Docs and examples about creating and executing INSERT sql statements.
@@ -288,7 +288,7 @@ If you find an issue you want to work on please comment on it letting other peop
288288
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.
289289

290290
### Running tests
291-
The test suite requires a postgres and mysql database. You can override the mysql/postgres connection strings with the [`MYSQL_URI` and `PG_URI` environment variables](https://github.com/doug-martin/goqu/blob/2fe3349/docker-compose.yml#L26)*
291+
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](https://github.com/doug-martin/goqu/blob/2fe3349/docker-compose.yml#L26)*
292292

293293
```sh
294294
go test -v -race ./...

dialect/mysql/mysql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func DialectOptions() *goqu.SQLDialectOptions {
2323

2424
opts.UseFromClauseForMultipleUpdateTables = false
2525

26-
opts.PlaceHolderRune = '?'
26+
opts.PlaceHolderFragment = []byte("?")
2727
opts.IncludePlaceholderNum = false
2828
opts.QuoteRune = '`'
2929
opts.DefaultValuesFragment = []byte("")

dialect/postgres/postgres.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
func DialectOptions() *goqu.SQLDialectOptions {
88
do := goqu.DefaultDialectOptions()
9-
do.PlaceHolderRune = '$'
9+
do.PlaceHolderFragment = []byte("$")
1010
do.IncludePlaceholderNum = true
1111
return do
1212
}

dialect/sqlite3/sqlite3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func DialectOptions() *goqu.SQLDialectOptions {
2222
opts.SupportsWindowFunction = false
2323
opts.SupportsLateral = false
2424

25-
opts.PlaceHolderRune = '?'
25+
opts.PlaceHolderFragment = []byte("?")
2626
opts.IncludePlaceholderNum = false
2727
opts.QuoteRune = '`'
2828
opts.DefaultValuesFragment = []byte("")

dialect/sqlserver/sqlserver.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package sqlserver
2+
3+
import (
4+
"github.com/doug-martin/goqu/v9"
5+
"github.com/doug-martin/goqu/v9/exp"
6+
"github.com/doug-martin/goqu/v9/sqlgen"
7+
)
8+
9+
func DialectOptions() *goqu.SQLDialectOptions {
10+
opts := goqu.DefaultDialectOptions()
11+
12+
opts.UseLiteralIsBools = false
13+
14+
opts.SupportsReturn = false
15+
opts.SupportsOrderByOnUpdate = false
16+
opts.SupportsLimitOnUpdate = false
17+
opts.SupportsLimitOnDelete = false
18+
opts.SupportsOrderByOnDelete = true
19+
opts.SupportsConflictUpdateWhere = false
20+
opts.SupportsInsertIgnoreSyntax = false
21+
opts.SupportsConflictTarget = false
22+
opts.SupportsWithCTE = false
23+
opts.SupportsWithCTERecursive = false
24+
opts.SupportsDistinctOn = false
25+
opts.SupportsWindowFunction = false
26+
27+
opts.PlaceHolderFragment = []byte("@p")
28+
opts.LimitFragment = []byte(" TOP ")
29+
opts.IncludePlaceholderNum = true
30+
opts.DefaultValuesFragment = []byte("")
31+
opts.True = []byte("1")
32+
opts.False = []byte("0")
33+
opts.TimeFormat = "2006-01-02 15:04:05"
34+
opts.BooleanOperatorLookup = map[exp.BooleanOperation][]byte{
35+
exp.EqOp: []byte("="),
36+
exp.NeqOp: []byte("!="),
37+
exp.GtOp: []byte(">"),
38+
exp.GteOp: []byte(">="),
39+
exp.LtOp: []byte("<"),
40+
exp.LteOp: []byte("<="),
41+
exp.InOp: []byte("IN"),
42+
exp.NotInOp: []byte("NOT IN"),
43+
exp.IsOp: []byte("="),
44+
exp.IsNotOp: []byte("IS NOT"),
45+
exp.LikeOp: []byte("LIKE"),
46+
exp.NotLikeOp: []byte("NOT LIKE"),
47+
exp.ILikeOp: []byte("LIKE"),
48+
exp.NotILikeOp: []byte("NOT LIKE"),
49+
exp.RegexpLikeOp: []byte("REGEXP BINARY"),
50+
exp.RegexpNotLikeOp: []byte("NOT REGEXP BINARY"),
51+
exp.RegexpILikeOp: []byte("REGEXP"),
52+
exp.RegexpNotILikeOp: []byte("NOT REGEXP"),
53+
}
54+
55+
opts.FetchFragment = []byte(" FETCH FIRST ")
56+
57+
opts.SelectSQLOrder = []sqlgen.SQLFragmentType{
58+
sqlgen.CommonTableSQLFragment,
59+
sqlgen.SelectWithLimitSQLFragment,
60+
sqlgen.FromSQLFragment,
61+
sqlgen.JoinSQLFragment,
62+
sqlgen.WhereSQLFragment,
63+
sqlgen.GroupBySQLFragment,
64+
sqlgen.HavingSQLFragment,
65+
sqlgen.WindowSQLFragment,
66+
sqlgen.CompoundsSQLFragment,
67+
sqlgen.OrderWithOffsetFetchSQLFragment,
68+
sqlgen.ForSQLFragment,
69+
}
70+
71+
opts.EscapedRunes = map[rune][]byte{
72+
'\'': []byte("\\'"),
73+
'"': []byte("\\\""),
74+
'\\': []byte("\\\\"),
75+
'\n': []byte("\\n"),
76+
'\r': []byte("\\r"),
77+
0: []byte("\\x00"),
78+
0x1a: []byte("\\x1a"),
79+
}
80+
81+
opts.ConflictFragment = []byte("")
82+
opts.ConflictDoUpdateFragment = []byte("")
83+
opts.ConflictDoNothingFragment = []byte("")
84+
85+
return opts
86+
}
87+
88+
func init() {
89+
goqu.RegisterDialect("sqlserver", DialectOptions())
90+
}

0 commit comments

Comments
 (0)