Skip to content

Commit 4df9241

Browse files
committed
Move to go modules
- Add documentation about modules - Add documentation about v4 - Bump version - Update changelog
1 parent e076d64 commit 4df9241

Some content is hidden

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

58 files changed

+443
-2753
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6-
## Unreleased
6+
## [v4.0.0] - 2020-04-26
7+
8+
**NOTE:** Your database drivers must be rebuilt upon moving to this release
79

810
### Added
911

12+
- Add a `--add-soft-deletes` that changes the templates to use soft deletion
13+
(thanks @namco1992)
1014
- Add a `--no-back-referencing` flag to disable setting backreferences in
1115
relationship helpers and eager loading. (thanks @namco1992)
1216
- Add not in helpers (thanks @RichardLindhout)
1317

1418
### Changed
1519

20+
- Changed dependency scheme to go modules
21+
- Changed randomize/strmangle to be external dependencies to avoid module
22+
cycles with the null package.
1623
- Changed the way comparisons work for keying caches which dramatically speeds
1724
up cache lookups (thanks @zikaeroh)
1825

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2017 Volatile Technologies Inc. All rights reserved.
1+
Copyright (c) 2020 Volatile Technologies Inc. All rights reserved.
22

33
Redistribution and use in source and binary forms, with or without
44
modification, are permitted provided that the following conditions are

README.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ or some other migration tool to manage this part of the database's life-cycle.
1919

2020
v3 has been released, please upgrade when possible, v2 is on life support only now.
2121

22+
# Note on v3 vs v4
23+
24+
v4 is identical virtually identical to v3 (it has 1 or 2 more features) but
25+
was turned into modules.
26+
2227
## Why another ORM
2328

2429
While attempting to migrate a legacy Rails database, we realized how much ActiveRecord benefited us in terms of development velocity.
@@ -111,6 +116,7 @@ Table of Contents
111116
- Strongly typed querying (usually no converting or binding to pointers)
112117
- Hooks (Before/After Create/Select/Update/Delete/Upsert)
113118
- Automatic CreatedAt/UpdatedAt
119+
- Automatic DeletedAt
114120
- Table and column whitelist/blacklist
115121
- Relationships/Associations
116122
- Eager loading (recursive)
@@ -399,18 +405,22 @@ sqlboiler psql
399405
Flags:
400406
--add-global-variants Enable generation for global variants
401407
--add-panic-variants Enable generation for panic variants
408+
--add-soft-deletes Enable soft deletion by updating deleted_at timestamp
402409
-c, --config string Filename of config file to override default lookup
403410
-d, --debug Debug mode prints stack traces on error
404411
-h, --help help for sqlboiler
405412
--no-auto-timestamps Disable automatic timestamps for created_at/updated_at
413+
--no-back-referencing Disable back referencing in the loaded relationship structs
406414
--no-context Disable context.Context usage in the generated code
415+
--no-driver-templates Disable parsing of templates defined by the database driver
407416
--no-hooks Disable hooks feature for your models
408417
--no-rows-affected Disable rows affected in the generated API
409418
--no-tests Disable generated go test files
410419
-o, --output string The name of the folder to output to (default "models")
411420
-p, --pkgname string The name you wish to assign to your generated package (default "models")
412-
--struct-tag-casing string Decides the casing for go structure tag names. camel or snake (default "snake")
421+
--struct-tag-casing string Decides the casing for go structure tag names. camel, title or snake (default snake) (default "snake")
413422
-t, --tag strings Struct tags to be included on your models in addition to json, yaml, toml
423+
--tag-ignore strings List of column names that should have tags values set to '-' (ignored during parsing)
414424
--templates strings A templates directory, overrides the bindata'd template folders in sqlboiler
415425
--version Print the version
416426
--wipe Delete the output folder (rm -rf) before generation to ensure sanity
@@ -840,6 +850,10 @@ The most common causes of problems and panics are:
840850
field in Go so sqlboiler assumes you do not want to insert that field and you want the default
841851
value from the database. Use a whitelist/greylist to add that field to the list of fields
842852
to insert.
853+
- decimal library showing errors like: `pq: encode: unknown type types.NullDecimal`
854+
is a result of a too-new and broken version of the github.com/ericlargergren/decimal
855+
package, use the following version in your go.mod:
856+
github.com/ericlagergren/decimal v0.0.0-20181231230500-73749d4874d5
843857

844858
For errors with other causes, it may be simple to debug yourself by looking at the generated code.
845859
Setting `boil.DebugMode` to `true` can help with this. You can change the output using `boil.DebugWriter` (defaults to `os.Stdout`).
@@ -976,6 +990,23 @@ before being sent to the database (if they were going to be sent).
976990
will be used. To set `created_at` to `null`, set `Valid` to false and `Time` to a non-zero value.
977991
* The `updated_at` column will always be set to `time.Now()`.
978992

993+
### Automatic DeletedAt (Soft Delete)
994+
995+
Soft deletes are a way of deleting records in a database for the average query
996+
without actually removing the data. This type of thing is important in certain
997+
scenarios where data retention is important. It is typically done by adding a
998+
`deleted` bool or a `deleted_at` timestamp to each table in the database
999+
that can be soft deleted and subsequent queries on that table should always
1000+
make sure that `deleted != true` or `deleted_at is null` to prevent showing
1001+
"deleted" data.
1002+
1003+
SQLBoiler uses the `deleted_at` variant to provide this functionality. If your
1004+
table has a nullable timestamp field named `deleted_at` it will be a candidate
1005+
for soft-deletion.
1006+
1007+
*NOTE*: As of writing soft-delete is opt-in via `--add-soft-deletes` and is
1008+
liable to change in future versions.
1009+
9791010
### Query Building
9801011

9811012
We generate "Starter" methods for you. These methods are named as the plural versions of your model,

boil/columns.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package boil
22

33
import (
4-
"github.com/volatiletech/sqlboiler/strmangle"
4+
"github.com/volatiletech/strmangle"
55
)
66

77
// Columns kinds

boilingcore/aliases.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package boilingcore
33
import (
44
"fmt"
55

6-
"github.com/volatiletech/sqlboiler/drivers"
7-
"github.com/volatiletech/sqlboiler/strmangle"
6+
"github.com/volatiletech/sqlboiler/v4/drivers"
7+
"github.com/volatiletech/strmangle"
88
)
99

1010
// Aliases defines aliases for the generation run
@@ -42,7 +42,7 @@ func FillAliases(a *Aliases, tables []drivers.Table) {
4242

4343
for _, t := range tables {
4444
if t.IsJoinTable {
45-
jt, ok := a.Tables[t.Name];
45+
jt, ok := a.Tables[t.Name]
4646
if !ok {
4747
a.Tables[t.Name] = TableAlias{Relationships: make(map[string]RelationshipAlias)}
4848
} else if jt.Relationships == nil {

boilingcore/aliases_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"reflect"
55
"testing"
66

7-
"github.com/volatiletech/sqlboiler/drivers"
7+
"github.com/volatiletech/sqlboiler/v4/drivers"
88
)
99

1010
func TestAliasesTables(t *testing.T) {

boilingcore/boilingcore.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212
"strings"
1313

1414
"github.com/friendsofgo/errors"
15-
"github.com/volatiletech/sqlboiler/drivers"
16-
"github.com/volatiletech/sqlboiler/importers"
17-
"github.com/volatiletech/sqlboiler/strmangle"
18-
"github.com/volatiletech/sqlboiler/templatebin"
15+
"github.com/volatiletech/sqlboiler/v4/drivers"
16+
"github.com/volatiletech/sqlboiler/v4/importers"
17+
"github.com/volatiletech/sqlboiler/v4/templatebin"
18+
"github.com/volatiletech/strmangle"
1919
)
2020

2121
const (

boilingcore/boilingcore_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212
"strconv"
1313
"testing"
1414

15-
"github.com/volatiletech/sqlboiler/importers"
15+
"github.com/volatiletech/sqlboiler/v4/importers"
1616

17-
"github.com/volatiletech/sqlboiler/drivers"
18-
_ "github.com/volatiletech/sqlboiler/drivers/mocks"
17+
"github.com/volatiletech/sqlboiler/v4/drivers"
18+
_ "github.com/volatiletech/sqlboiler/v4/drivers/mocks"
1919
)
2020

2121
var state *State

boilingcore/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"strings"
66

77
"github.com/spf13/cast"
8-
"github.com/volatiletech/sqlboiler/drivers"
9-
"github.com/volatiletech/sqlboiler/importers"
8+
"github.com/volatiletech/sqlboiler/v4/drivers"
9+
"github.com/volatiletech/sqlboiler/v4/importers"
1010
)
1111

1212
// Config for the running of the commands

boilingcore/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package boilingcore
33
import (
44
"testing"
55

6-
"github.com/volatiletech/sqlboiler/drivers"
6+
"github.com/volatiletech/sqlboiler/v4/drivers"
77
)
88

99
func TestConfig_OutputDirDepth(t *testing.T) {

boilingcore/output.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"text/template"
1515

1616
"github.com/friendsofgo/errors"
17-
"github.com/volatiletech/sqlboiler/importers"
17+
"github.com/volatiletech/sqlboiler/v4/importers"
1818
)
1919

2020
var (

boilingcore/templates.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
"text/template"
1313

1414
"github.com/friendsofgo/errors"
15-
"github.com/volatiletech/sqlboiler/drivers"
16-
"github.com/volatiletech/sqlboiler/strmangle"
17-
"github.com/volatiletech/sqlboiler/templatebin"
15+
"github.com/volatiletech/sqlboiler/v4/drivers"
16+
"github.com/volatiletech/sqlboiler/v4/templatebin"
17+
"github.com/volatiletech/strmangle"
1818
)
1919

2020
// templateData for sqlboiler templates

boilingcore/text_helpers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package boilingcore
33
import (
44
"strings"
55

6-
"github.com/volatiletech/sqlboiler/drivers"
7-
"github.com/volatiletech/sqlboiler/strmangle"
6+
"github.com/volatiletech/sqlboiler/v4/drivers"
7+
"github.com/volatiletech/strmangle"
88
)
99

1010
// txtNameToOne creates the local and foreign function names for

boilingcore/text_helpers_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package boilingcore
33
import (
44
"testing"
55

6-
"github.com/volatiletech/sqlboiler/drivers"
6+
"github.com/volatiletech/sqlboiler/v4/drivers"
77
)
88

99
func TestTxtNameToOne(t *testing.T) {

drivers/binary_driver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"os/exec"
99

1010
"github.com/friendsofgo/errors"
11-
"github.com/volatiletech/sqlboiler/importers"
11+
"github.com/volatiletech/sqlboiler/v4/importers"
1212
)
1313

1414
type binaryDriver string

drivers/column.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package drivers
33
import (
44
"strings"
55

6-
"github.com/volatiletech/sqlboiler/strmangle"
6+
"github.com/volatiletech/strmangle"
77
)
88

99
// Column holds information about a database column.

drivers/interface.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"sort"
77

88
"github.com/friendsofgo/errors"
9-
"github.com/volatiletech/sqlboiler/importers"
10-
"github.com/volatiletech/sqlboiler/strmangle"
9+
"github.com/volatiletech/sqlboiler/v4/importers"
10+
"github.com/volatiletech/strmangle"
1111
)
1212

1313
// These constants are used in the config map passed into the driver

drivers/interface_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package drivers
33
import (
44
"testing"
55

6-
"github.com/volatiletech/sqlboiler/strmangle"
6+
"github.com/volatiletech/strmangle"
77
)
88

99
type testMockDriver struct{}

drivers/mocks/mock.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package mocks
22

33
import (
4-
"github.com/volatiletech/sqlboiler/drivers"
5-
"github.com/volatiletech/sqlboiler/importers"
6-
"github.com/volatiletech/sqlboiler/strmangle"
4+
"github.com/volatiletech/sqlboiler/v4/drivers"
5+
"github.com/volatiletech/sqlboiler/v4/importers"
6+
"github.com/volatiletech/strmangle"
77
)
88

99
func init() {
@@ -23,16 +23,16 @@ func (m *MockDriver) Imports() (importers.Collection, error) {
2323
return importers.Collection{
2424
BasedOnType: importers.Map{
2525
"null.Int": {
26-
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
26+
ThirdParty: importers.List{`"github.com/volatiletech/null/v8"`},
2727
},
2828
"null.String": {
29-
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
29+
ThirdParty: importers.List{`"github.com/volatiletech/null/v8"`},
3030
},
3131
"null.Time": {
32-
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
32+
ThirdParty: importers.List{`"github.com/volatiletech/null/v8"`},
3333
},
3434
"null.Bytes": {
35-
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
35+
ThirdParty: importers.List{`"github.com/volatiletech/null/v8"`},
3636
},
3737

3838
"time.Time": {

drivers/registration_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package drivers
33
import (
44
"testing"
55

6-
"github.com/volatiletech/sqlboiler/importers"
6+
"github.com/volatiletech/sqlboiler/v4/importers"
77
)
88

99
type testRegistrationDriver struct{}

0 commit comments

Comments
 (0)