Skip to content

Commit c464414

Browse files
committed
Merge branch 'development'
2 parents aab726f + 3ef63dc commit c464414

Some content is hidden

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

51 files changed

+1806
-1013
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build:
1818
$(GO_BIN) build -v .
1919

2020
test:
21-
packr2
21+
# packr2
2222
$(GO_BIN) test -tags ${TAGS} ./...
2323

2424
ci-test:

SHOULDERS.md

Lines changed: 19 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,126 +5,64 @@ Pop does not try to reinvent the wheel! Instead, it uses the already great wheel
55
Thank you to the following **GIANTS**:
66

77

8-
* [github.com/blang/semver](https://godoc.org/github.com/blang/semver)
8+
* [github.com/cockroachdb/apd](https://godoc.org/github.com/cockroachdb/apd)
99

10-
* [github.com/cockroachdb/cockroach-go/crdb](https://godoc.org/github.com/cockroachdb/cockroach-go/crdb)
10+
* [github.com/cockroachdb/cockroach-go](https://godoc.org/github.com/cockroachdb/cockroach-go)
1111

1212
* [github.com/fatih/color](https://godoc.org/github.com/fatih/color)
1313

14-
* [github.com/fatih/structs](https://godoc.org/github.com/fatih/structs)
15-
1614
* [github.com/go-sql-driver/mysql](https://godoc.org/github.com/go-sql-driver/mysql)
1715

16+
* [github.com/gobuffalo/attrs](https://godoc.org/github.com/gobuffalo/attrs)
17+
1818
* [github.com/gobuffalo/envy](https://godoc.org/github.com/gobuffalo/envy)
1919

2020
* [github.com/gobuffalo/fizz](https://godoc.org/github.com/gobuffalo/fizz)
2121

22-
* [github.com/gobuffalo/fizz/translators](https://godoc.org/github.com/gobuffalo/fizz/translators)
23-
2422
* [github.com/gobuffalo/flect](https://godoc.org/github.com/gobuffalo/flect)
2523

26-
* [github.com/gobuffalo/flect/name](https://godoc.org/github.com/gobuffalo/flect/name)
27-
28-
* [github.com/gobuffalo/github_flavored_markdown](https://godoc.org/github.com/gobuffalo/github_flavored_markdown)
29-
30-
* [github.com/gobuffalo/github_flavored_markdown/internal/russross/blackfriday](https://godoc.org/github.com/gobuffalo/github_flavored_markdown/internal/russross/blackfriday)
24+
* [github.com/gobuffalo/genny](https://godoc.org/github.com/gobuffalo/genny)
3125

32-
* [github.com/gobuffalo/github_flavored_markdown/internal/shurcooL/highlight_diff](https://godoc.org/github.com/gobuffalo/github_flavored_markdown/internal/shurcooL/highlight_diff)
26+
* [github.com/gobuffalo/gogen](https://godoc.org/github.com/gobuffalo/gogen)
3327

34-
* [github.com/gobuffalo/github_flavored_markdown/internal/shurcooL/highlight_go](https://godoc.org/github.com/gobuffalo/github_flavored_markdown/internal/shurcooL/highlight_go)
35-
36-
* [github.com/gobuffalo/github_flavored_markdown/internal/shurcooL/octicon](https://godoc.org/github.com/gobuffalo/github_flavored_markdown/internal/shurcooL/octicon)
37-
38-
* [github.com/gobuffalo/github_flavored_markdown/internal/shurcooL/sanitized_anchor_name](https://godoc.org/github.com/gobuffalo/github_flavored_markdown/internal/shurcooL/sanitized_anchor_name)
39-
40-
* [github.com/gobuffalo/makr](https://godoc.org/github.com/gobuffalo/makr)
28+
* [github.com/gobuffalo/logger](https://godoc.org/github.com/gobuffalo/logger)
4129

4230
* [github.com/gobuffalo/nulls](https://godoc.org/github.com/gobuffalo/nulls)
4331

4432
* [github.com/gobuffalo/packd](https://godoc.org/github.com/gobuffalo/packd)
4533

46-
* [github.com/gobuffalo/plush](https://godoc.org/github.com/gobuffalo/plush)
47-
48-
* [github.com/gobuffalo/plush/ast](https://godoc.org/github.com/gobuffalo/plush/ast)
34+
* [github.com/gobuffalo/packr/v2](https://godoc.org/github.com/gobuffalo/packr/v2)
4935

50-
* [github.com/gobuffalo/plush/lexer](https://godoc.org/github.com/gobuffalo/plush/lexer)
51-
52-
* [github.com/gobuffalo/plush/parser](https://godoc.org/github.com/gobuffalo/plush/parser)
53-
54-
* [github.com/gobuffalo/plush/token](https://godoc.org/github.com/gobuffalo/plush/token)
55-
56-
* [github.com/gobuffalo/syncx](https://godoc.org/github.com/gobuffalo/syncx)
57-
58-
* [github.com/gobuffalo/tags](https://godoc.org/github.com/gobuffalo/tags)
59-
60-
* [github.com/gobuffalo/tags/form](https://godoc.org/github.com/gobuffalo/tags/form)
61-
62-
* [github.com/gobuffalo/tags/form/bootstrap](https://godoc.org/github.com/gobuffalo/tags/form/bootstrap)
63-
64-
* [github.com/gobuffalo/uuid](https://godoc.org/github.com/gobuffalo/uuid)
36+
* [github.com/gobuffalo/plush](https://godoc.org/github.com/gobuffalo/plush)
6537

6638
* [github.com/gobuffalo/validate](https://godoc.org/github.com/gobuffalo/validate)
6739

68-
* [github.com/gobuffalo/validate/validators](https://godoc.org/github.com/gobuffalo/validate/validators)
69-
70-
* [github.com/gobuffalo/x/defaults](https://godoc.org/github.com/gobuffalo/x/defaults)
71-
7240
* [github.com/gofrs/uuid](https://godoc.org/github.com/gofrs/uuid)
7341

74-
* [github.com/jackc/pgx](https://godoc.org/github.com/jackc/pgx)
75-
76-
* [github.com/jackc/pgx/chunkreader](https://godoc.org/github.com/jackc/pgx/chunkreader)
77-
78-
* [github.com/jackc/pgx/internal/sanitize](https://godoc.org/github.com/jackc/pgx/internal/sanitize)
79-
80-
* [github.com/jackc/pgx/pgio](https://godoc.org/github.com/jackc/pgx/pgio)
42+
* [github.com/jackc/fake](https://godoc.org/github.com/jackc/fake)
8143

82-
* [github.com/jackc/pgx/pgproto3](https://godoc.org/github.com/jackc/pgx/pgproto3)
83-
84-
* [github.com/jackc/pgx/pgtype](https://godoc.org/github.com/jackc/pgx/pgtype)
44+
* [github.com/jackc/pgx](https://godoc.org/github.com/jackc/pgx)
8545

8646
* [github.com/jmoiron/sqlx](https://godoc.org/github.com/jmoiron/sqlx)
8747

88-
* [github.com/jmoiron/sqlx/reflectx](https://godoc.org/github.com/jmoiron/sqlx/reflectx)
89-
90-
* [github.com/joho/godotenv](https://godoc.org/github.com/joho/godotenv)
91-
92-
* [github.com/kballard/go-shellquote](https://godoc.org/github.com/kballard/go-shellquote)
93-
9448
* [github.com/lib/pq](https://godoc.org/github.com/lib/pq)
9549

96-
* [github.com/lib/pq/oid](https://godoc.org/github.com/lib/pq/oid)
97-
98-
* [github.com/markbates/going/defaults](https://godoc.org/github.com/markbates/going/defaults)
99-
100-
* [github.com/markbates/going/randx](https://godoc.org/github.com/markbates/going/randx)
50+
* [github.com/mattn/go-colorable](https://godoc.org/github.com/mattn/go-colorable)
10151

102-
* [github.com/markbates/inflect](https://godoc.org/github.com/markbates/inflect)
52+
* [github.com/mattn/go-isatty](https://godoc.org/github.com/mattn/go-isatty)
10353

104-
* [github.com/markbates/oncer](https://godoc.org/github.com/markbates/oncer)
105-
106-
* [github.com/microcosm-cc/bluemonday](https://godoc.org/github.com/microcosm-cc/bluemonday)
54+
* [github.com/mattn/go-sqlite3](https://godoc.org/github.com/mattn/go-sqlite3)
10755

10856
* [github.com/pkg/errors](https://godoc.org/github.com/pkg/errors)
10957

110-
* [github.com/rogpeppe/go-internal/modfile](https://godoc.org/github.com/rogpeppe/go-internal/modfile)
111-
112-
* [github.com/rogpeppe/go-internal/module](https://godoc.org/github.com/rogpeppe/go-internal/module)
113-
114-
* [github.com/rogpeppe/go-internal/semver](https://godoc.org/github.com/rogpeppe/go-internal/semver)
115-
116-
* [github.com/serenize/snaker](https://godoc.org/github.com/serenize/snaker)
117-
118-
* [github.com/sergi/go-diff/diffmatchpatch](https://godoc.org/github.com/sergi/go-diff/diffmatchpatch)
119-
120-
* [github.com/sourcegraph/annotate](https://godoc.org/github.com/sourcegraph/annotate)
58+
* [github.com/satori/go.uuid](https://godoc.org/github.com/satori/go.uuid)
12159

122-
* [github.com/sourcegraph/syntaxhighlight](https://godoc.org/github.com/sourcegraph/syntaxhighlight)
60+
* [github.com/shopspring/decimal](https://godoc.org/github.com/shopspring/decimal)
12361

124-
* [golang.org/x/net/html](https://godoc.org/golang.org/x/net/html)
62+
* [github.com/spf13/cobra](https://godoc.org/github.com/spf13/cobra)
12563

126-
* [golang.org/x/net/html/atom](https://godoc.org/golang.org/x/net/html/atom)
64+
* [github.com/stretchr/testify](https://godoc.org/github.com/stretchr/testify)
12765

128-
* [golang.org/x/sync/errgroup](https://godoc.org/golang.org/x/sync/errgroup)
66+
* [golang.org/x/sync](https://godoc.org/golang.org/x/sync)
12967

13068
* [gopkg.in/yaml.v2](https://godoc.org/gopkg.in/yaml.v2)

azure-pipelines.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
strategy:
1111
matrix:
1212
# SQLite3
13-
go 1.12 (off) sqlite:
14-
go_version: "1.12"
13+
go 1.13 (off) sqlite:
14+
go_version: "1.13"
1515
GO111MODULE: "off"
1616
SODA_DIALECT: "sqlite"
1717
steps:
@@ -23,8 +23,8 @@ jobs:
2323
strategy:
2424
matrix:
2525
# SQLite3
26-
go 1.12 (off) sqlite:
27-
go_version: "1.12"
26+
go 1.13 (off) sqlite:
27+
go_version: "1.13"
2828
GO111MODULE: "off"
2929
SODA_DIALECT: "sqlite"
3030
steps:
@@ -36,9 +36,6 @@ jobs:
3636
strategy:
3737
matrix:
3838
# Postgres
39-
go 1.10 postgres:
40-
go_version: "1.10"
41-
SODA_DIALECT: "postgres"
4239
go 1.11 (off) postgres:
4340
go_version: "1.11.5"
4441
GO111MODULE: "off"
@@ -47,25 +44,29 @@ jobs:
4744
go_version: "1.12"
4845
GO111MODULE: "off"
4946
SODA_DIALECT: "postgres"
47+
go 1.13 (off) postgres:
48+
go_version: "1.13"
49+
GO111MODULE: "off"
50+
SODA_DIALECT: "postgres"
5051
# Cockroach
51-
go 1.12 (off) cockroach:
52-
go_version: "1.12"
52+
go 1.13 (off) cockroach:
53+
go_version: "1.13"
5354
GO111MODULE: "off"
5455
SODA_DIALECT: "cockroach"
5556
# Cockroach SSL
56-
go 1.12 (off) cockroach SSL:
57-
go_version: "1.12"
57+
go 1.13 (off) cockroach SSL:
58+
go_version: "1.13"
5859
GO111MODULE: "off"
5960
SODA_DIALECT: "cockroach_ssl"
6061
# MySQL
61-
go 1.12 (off) mysql:
62-
go_version: "1.12"
62+
go 1.13 (off) mysql:
63+
go_version: "1.13"
6364
GO111MODULE: "off"
6465
SODA_DIALECT: "mysql"
6566
MYSQL_PORT: "3307"
6667
# SQLite3
67-
go 1.12 (off) sqlite:
68-
go_version: "1.12"
68+
go 1.13 (off) sqlite:
69+
go_version: "1.13"
6970
GO111MODULE: "off"
7071
SODA_DIALECT: "sqlite"
7172
steps:

config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func LoadConfigFile() error {
4848
if err != nil {
4949
return err
5050
}
51+
defer f.Close()
5152
return LoadFrom(f)
5253
}
5354

connection.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ func (c *Connection) Open() error {
107107
if details.IdlePool != 0 {
108108
db.SetMaxIdleConns(details.IdlePool)
109109
}
110+
if details.ConnMaxLifetime > 0 {
111+
db.SetConnMaxLifetime(details.ConnMaxLifetime)
112+
}
110113
c.Store = &dB{db}
111114

112115
if d, ok := c.Dialect.(afterOpenable); ok {

connection_details.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ type ConnectionDetails struct {
4141
Pool int
4242
// Defaults to 2. See https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns
4343
IdlePool int
44-
Options map[string]string
44+
// Defaults to 0 "unlimited". See https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime
45+
ConnMaxLifetime time.Duration
46+
Options map[string]string
4547
// Query string encoded options from URL. Example: "sslmode=disable"
4648
RawOptions string
4749
}

connection_details_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func Test_ConnectionDetails_Finalize(t *testing.T) {
1010
r := require.New(t)
1111

1212
cd := &ConnectionDetails{
13-
URL: "postgres://user:pass@host:port/database",
13+
URL: "postgres://user:pass@host:1337/database",
1414
}
1515
err := cd.Finalize()
1616
r.NoError(err)
@@ -19,7 +19,7 @@ func Test_ConnectionDetails_Finalize(t *testing.T) {
1919
r.Equal("postgres", cd.Dialect)
2020
r.Equal("host", cd.Host)
2121
r.Equal("pass", cd.Password)
22-
r.Equal("port", cd.Port)
22+
r.Equal("1337", cd.Port)
2323
r.Equal("user", cd.User)
2424
}
2525

@@ -46,14 +46,14 @@ func Test_ConnectionDetails_Finalize_Cockroach(t *testing.T) {
4646
r := require.New(t)
4747
cd := &ConnectionDetails{
4848
Dialect: "cockroach",
49-
URL: "postgres://user:pass@host:port/database?sslmode=require&sslrootcert=certs/ca.crt&sslkey=certs/client.key&sslcert=certs/client.crt",
49+
URL: "postgres://user:pass@host:1337/database?sslmode=require&sslrootcert=certs/ca.crt&sslkey=certs/client.key&sslcert=certs/client.crt",
5050
}
5151
err := cd.Finalize()
5252
r.NoError(err)
5353
r.Equal("cockroach", cd.Dialect)
5454
r.Equal("database", cd.Database)
5555
r.Equal("host", cd.Host)
56-
r.Equal("port", cd.Port)
56+
r.Equal("1337", cd.Port)
5757
r.Equal("user", cd.User)
5858
r.Equal("pass", cd.Password)
5959
}

dialect.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,37 @@ import (
77
"github.com/gobuffalo/pop/columns"
88
)
99

10+
type crudable interface {
11+
SelectOne(store, *Model, Query) error
12+
SelectMany(store, *Model, Query) error
13+
Create(store, *Model, columns.Columns) error
14+
Update(store, *Model, columns.Columns) error
15+
Destroy(store, *Model) error
16+
}
17+
18+
type fizzable interface {
19+
FizzTranslator() fizz.Translator
20+
}
21+
22+
type quotable interface {
23+
Quote(key string) string
24+
}
25+
1026
type dialect interface {
27+
crudable
28+
fizzable
29+
quotable
1130
Name() string
1231
URL() string
1332
MigrationURL() string
1433
Details() *ConnectionDetails
1534
TranslateSQL(string) string
16-
Create(store, *Model, columns.Columns) error
17-
Update(store, *Model, columns.Columns) error
18-
Destroy(store, *Model) error
19-
SelectOne(store, *Model, Query) error
20-
SelectMany(store, *Model, Query) error
2135
CreateDB() error
2236
DropDB() error
2337
DumpSchema(io.Writer) error
2438
LoadSchema(io.Reader) error
25-
FizzTranslator() fizz.Translator
2639
Lock(func() error) error
2740
TruncateAll(*Connection) error
28-
Quote(key string) string
2941
}
3042

3143
type afterOpenable interface {

dialect_cockroach_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ func Test_Cockroach_URL_Raw(t *testing.T) {
1111
r := require.New(t)
1212
cd := &ConnectionDetails{
1313
Dialect: "cockroach",
14-
URL: "scheme://user:pass@host:port/database?option1=value1",
14+
URL: "scheme://user:pass@host:1337/database?option1=value1",
1515
}
1616
err := cd.Finalize()
1717
r.NoError(err)
1818
m := &cockroach{commonDialect: commonDialect{ConnectionDetails: cd}}
19-
r.Equal("scheme://user:pass@host:port/database?option1=value1", m.URL())
20-
r.Equal("postgres://user:pass@host:port/?option1=value1", m.urlWithoutDb())
19+
r.Equal("scheme://user:pass@host:1337/database?option1=value1", m.URL())
20+
r.Equal("postgres://user:pass@host:1337/?option1=value1", m.urlWithoutDb())
2121
}
2222

2323
func Test_Cockroach_URL_Build(t *testing.T) {

dialect_common.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ func (commonDialect) Quote(key string) string {
3434
return fmt.Sprintf(`"%s"`, key)
3535
}
3636

37-
type quoter interface {
38-
Quote(key string) string
39-
}
40-
41-
func genericCreate(s store, model *Model, cols columns.Columns, quoter quoter) error {
37+
func genericCreate(s store, model *Model, cols columns.Columns, quoter quotable) error {
4238
keyType := model.PrimaryKeyType()
4339
switch keyType {
4440
case "int", "int64":
@@ -90,7 +86,7 @@ func genericCreate(s store, model *Model, cols columns.Columns, quoter quoter) e
9086
return errors.Errorf("can not use %s as a primary key type!", keyType)
9187
}
9288

93-
func genericUpdate(s store, model *Model, cols columns.Columns, quoter quoter) error {
89+
func genericUpdate(s store, model *Model, cols columns.Columns, quoter quotable) error {
9490
stmt := fmt.Sprintf("UPDATE %s SET %s WHERE %s", quoter.Quote(model.TableName()), cols.Writeable().QuotedUpdateString(quoter), model.whereNamedID())
9591
log(logging.SQL, stmt, model.ID())
9692
_, err := s.NamedExec(stmt, model.Value)
@@ -100,7 +96,7 @@ func genericUpdate(s store, model *Model, cols columns.Columns, quoter quoter) e
10096
return nil
10197
}
10298

103-
func genericDestroy(s store, model *Model, quoter quoter) error {
99+
func genericDestroy(s store, model *Model, quoter quotable) error {
104100
stmt := fmt.Sprintf("DELETE FROM %s WHERE %s", quoter.Quote(model.TableName()), model.whereID())
105101
_, err := genericExec(s, stmt, model.ID())
106102
if err != nil {

0 commit comments

Comments
 (0)