Skip to content

Commit

Permalink
v4.11.0 (#379)
Browse files Browse the repository at this point in the history
* Back to development

* Add Timestamps() macro when generating fizz migrations (#365)

* Azure pipelines (#367)

* WIP Azure pipelines

* Fix typo

* Fix soda install script

* Fix binary name

* Fix tsoda call

* Build soda without modules

* Use Bash to install soda

* Fix pipeline

* Fix soda build

* Remove go module builds

* Fix soda install

* Install soda with go install

* Fix config parse test

* Do not create Docker default DBs

* Remove Travis

* Update badge in Readme

* Remove legacy Anko format fixer (#366)

It can still be called using soda fix command.

* removes errors.WithStack as its noisy and makes it harder to understand (#372)

* removes errors.WithStack as its noisy and makes it harder to understand

* fix packr file

* Add a fix for old fizz without Timestamps() (#373)

* WIP fix old auto-timestamp

* Use plush AST to rewrite fizz files

* Fix case when files are already using t.Timestamps()

* Fix Windows line breaks issue

* Add a mention in godocs about the behavior on slices for executors (#375)

Fixes #363.

* Fix "has_one" pointer association (#378)

* hasOneAssociation did not work with pointers

* Bump version

* Fix IdlePool option (#380)

The zero value was not the same as in the stdlib and could cause
perfs issues. This will now not call SetMaxIdleConns when IdlePool
is set to the zero value.

Fixes #376
  • Loading branch information
stanislas-m authored May 5, 2019
1 parent 9eeaaa1 commit 5a442f5
Show file tree
Hide file tree
Showing 74 changed files with 513 additions and 297 deletions.
133 changes: 0 additions & 133 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<p align="center">
<a href="https://godoc.org/github.com/gobuffalo/pop"><img src="https://godoc.org/github.com/gobuffalo/pop?status.svg" alt="GoDoc" /></a>
<a href="https://travis-ci.org/gobuffalo/pop"><img src="https://travis-ci.org/gobuffalo/pop.svg?branch=master" alt="Build Status" /></a>
<a href="https://dev.azure.com/stanislasmichalak/pop/_build/latest?definitionId=1&branchName=master"><img src="https://dev.azure.com/stanislasmichalak/pop/_apis/build/status/gobuffalo.pop?branchName=master" alt="Build Status" /></a>
</p>

# POP
Expand Down
3 changes: 3 additions & 0 deletions associations/has_one_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func hasOneAssociationBuilder(p associationParams) (Association, error) {
}

func (h *hasOneAssociation) Kind() reflect.Kind {
if h.ownedType.Kind() == reflect.Ptr {
return h.ownedType.Elem().Kind()
}
return h.ownedType.Kind()
}

Expand Down
18 changes: 18 additions & 0 deletions associations/has_one_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ type FooHasOne struct {
type barHasOne struct {
Title string `db:"title"`
FooHasOneID nulls.UUID `db:"foo_has_one_id"`
BazHasOneID nulls.UUID `db:"baz_id"`
}

type bazHasOne struct {
ID uuid.UUID `db:"id"`
BarHasOne *barHasOne `has_one:"barHasOne" fk_id:"baz_id"`
}

func Test_Has_One_Association(t *testing.T) {
Expand All @@ -44,6 +50,18 @@ func Test_Has_One_Association(t *testing.T) {
for index := range after {
a.Equal(nil, after[index].AfterInterface())
}

baz := bazHasOne{ID: id}

as, err = associations.ForStruct(&baz)

a.NoError(err)
a.Equal(len(as), 1)
a.Equal(reflect.Struct, as[0].Kind())

where, args = as[0].Constraint()
a.Equal("baz_id = ?", where)
a.Equal(id, args[0].(uuid.UUID))
}

func Test_Has_One_SetValue(t *testing.T) {
Expand Down
72 changes: 72 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
variables:
GOBIN: "$(GOPATH)/bin" # Go binaries path
GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path
modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code

jobs:
- job: Windows
pool:
vmImage: "vs2017-win2016"
strategy:
matrix:
# SQLite3
go 1.12 (off) sqlite:
go_version: "1.12"
GO111MODULE: "off"
SODA_DIALECT: "sqlite"
steps:
- template: azure-tests.yml

- job: macOS
pool:
vmImage: "macOS-10.13"
strategy:
matrix:
# SQLite3
go 1.12 (off) sqlite:
go_version: "1.12"
GO111MODULE: "off"
SODA_DIALECT: "sqlite"
steps:
- template: azure-tests.yml

- job: Linux
pool:
vmImage: "ubuntu-16.04"
strategy:
matrix:
# Postgres
go 1.10 postgres:
go_version: "1.10"
SODA_DIALECT: "postgres"
go 1.11 (off) postgres:
go_version: "1.11.5"
GO111MODULE: "off"
SODA_DIALECT: "postgres"
go 1.12 (off) postgres:
go_version: "1.12"
GO111MODULE: "off"
SODA_DIALECT: "postgres"
# Cockroach
go 1.12 (off) cockroach:
go_version: "1.12"
GO111MODULE: "off"
SODA_DIALECT: "cockroach"
# Cockroach SSL
go 1.12 (off) cockroach SSL:
go_version: "1.12"
GO111MODULE: "off"
SODA_DIALECT: "cockroach_ssl"
# MySQL
go 1.12 (off) mysql:
go_version: "1.12"
GO111MODULE: "off"
SODA_DIALECT: "mysql"
MYSQL_PORT: "3307"
# SQLite3
go 1.12 (off) sqlite:
go_version: "1.12"
GO111MODULE: "off"
SODA_DIALECT: "sqlite"
steps:
- template: azure-tests.yml
69 changes: 69 additions & 0 deletions azure-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
steps:
- task: GoTool@0
inputs:
version: $(go_version)
- task: Bash@3
inputs:
targetType: inline
script: |
mkdir -p "$(GOBIN)"
mkdir -p "$(GOPATH)/pkg"
mkdir -p "$(modulePath)"
shopt -s extglob
mv !(gopath) "$(modulePath)"
displayName: "Setup Go Workspace"
- task: Docker@1
displayName: Run postgres image
inputs:
command: run
imageName: postgres:9.6
ports: "5432:5432"
condition: and(succeeded(), eq(variables['SODA_DIALECT'], 'postgres'))
- task: Docker@1
displayName: Run mysql image
inputs:
command: run
imageName: mysql:5.7
ports: "3307:3306"
envVars: |
MYSQL_ROOT_PASSWORD=root
condition: and(succeeded(), eq(variables['SODA_DIALECT'], 'mysql'))
- task: Docker@1
displayName: Run cockroach image
inputs:
command: run
imageName: cockroachdb/cockroach:v1.1.1
ports: "26257:26257"
containerCommand: start --insecure
condition: and(succeeded(), eq(variables['SODA_DIALECT'], 'cockroach'))
- task: Bash@3
displayName: Install Cockroach SSL
inputs:
targetType: inline
script: |
cd $(modulePath)
mkdir -p crdb/certs
pushd crdb
wget -qO- https://binaries.cockroachdb.com/cockroach-v2.1.0.linux-amd64.tgz | tar zxv
mv cockroach-v2.1.0.linux-amd64/cockroach .
./cockroach cert create-ca --certs-dir certs --ca-key key
./cockroach cert create-client root --certs-dir certs --ca-key key
./cockroach cert create-node localhost 127.0.0.1 `hostname -s` `hostname -f` --certs-dir certs --ca-key key
./cockroach start --certs-dir certs --listen-addr localhost --port 26259 --http-port 8089 --background
popd
condition: and(succeeded(), eq(variables['SODA_DIALECT'], 'cockroach_ssl'))
- script: |
go get -t -v ./...
go install -v -tags sqlite ./soda
workingDirectory: "$(modulePath)"
displayName: "Install soda"
- script: |
$(GOBIN)/soda drop -e $(SODA_DIALECT)
$(GOBIN)/soda create -e $(SODA_DIALECT)
$(GOBIN)/soda migrate -e $(SODA_DIALECT)
workingDirectory: "$(modulePath)"
displayName: "Create DB & run migrations"
- script: |
go test -tags sqlite ./... -v
workingDirectory: "$(modulePath)"
displayName: "Tests"
3 changes: 1 addition & 2 deletions callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package pop
import (
"reflect"

"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
)

Expand All @@ -16,7 +15,7 @@ type AfterFindable interface {
func (m *Model) afterFind(c *Connection) error {
if x, ok := m.Value.(AfterFindable); ok {
if err := x.AfterFind(c); err != nil {
return errors.WithStack(err)
return err
}
}

Expand Down
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ func init() {
func LoadConfigFile() error {
path, err := findConfigPath()
if err != nil {
return errors.WithStack(err)
return err
}
Connections = map[string]*Connection{}
log(logging.Debug, "Loading config file from %s", path)
f, err := os.Open(path)
if err != nil {
return errors.WithStack(err)
return err
}
return LoadFrom(f)
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func ParseConfig(r io.Reader) (map[string]*ConnectionDetails, error) {
})
b, err := ioutil.ReadAll(r)
if err != nil {
return nil, errors.WithStack(err)
return nil, err
}
t, err := tmpl.Parse(string(b))
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Test_LoadsConnectionsFromConfig(t *testing.T) {
r := require.New(t)

conns := Connections
r.Equal(6, len(conns))
r.Equal(5, len(conns))
}

func Test_AddLookupPaths(t *testing.T) {
Expand All @@ -28,10 +28,10 @@ func Test_ParseConfig(t *testing.T) {
mysql:
dialect: "mysql"
database: "pop_test"
host: {{ envOr "MYSQL_HOST" "127.0.0.1" }}
port: {{ envOr "MYSQL_PORT" "3306" }}
user: {{ envOr "MYSQL_USER" "root" }}
password: {{ envOr "MYSQL_PASSWORD" "root" }}
host: "127.0.0.1"
port: "3306"
user: "root"
password: "root"
options:
readTimeout: 5s`)
conns, err := ParseConfig(config)
Expand Down
Loading

0 comments on commit 5a442f5

Please sign in to comment.