Package structure refactor.

This commit is contained in:
go-jet 2019-08-03 14:10:47 +02:00
parent 3d8e872336
commit 23fd973699
125 changed files with 2401 additions and 1818 deletions

View file

@ -2,8 +2,8 @@ package mysql
import (
"context"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/mysql"
"github.com/go-jet/jet/tests/.gentestdata/mysql/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/mysql/test_sample/table"
"gotest.tools/assert"

View file

@ -2,8 +2,8 @@ package mysql
import (
"context"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/mysql"
"github.com/go-jet/jet/tests/.gentestdata/mysql/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/mysql/test_sample/table"
"gotest.tools/assert"
@ -123,7 +123,7 @@ func TestUpdateWithModelDataAndPredefinedColumnList(t *testing.T) {
Name: "DuckDuckGo",
}
updateColumnList := ColumnList{Link.Description, Link.Name, Link.URL}
updateColumnList := ColumnList(Link.Description, Link.Name, Link.URL)
stmt := Link.
UPDATE(updateColumnList).

View file

@ -2,9 +2,9 @@ package postgres
import (
"fmt"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
"github.com/go-jet/jet/postgres"
. "github.com/go-jet/jet/postgres"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
"github.com/go-jet/jet/tests/testdata/common"

View file

@ -2,8 +2,8 @@ package postgres
import (
"context"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/postgres"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/chinook/model"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/chinook/table"
"gotest.tools/assert"

View file

@ -2,8 +2,8 @@ package postgres
import (
"context"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/postgres"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
"gotest.tools/assert"

View file

@ -2,8 +2,8 @@ package postgres
import (
"context"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/postgres"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
"gotest.tools/assert"
@ -24,7 +24,7 @@ RETURNING link.id AS "link.id",
link.name AS "link.name",
link.description AS "link.description";
`
Link.ID.Name()
insertQuery := Link.INSERT(Link.ID, Link.URL, Link.Name, Link.Description).
VALUES(100, "http://www.postgresqltutorial.com", "PostgreSQL Tutorial", DEFAULT).
VALUES(101, "http://www.google.com", "Google", DEFAULT).

View file

@ -7,7 +7,7 @@ import (
"testing"
"time"
. "github.com/go-jet/jet"
. "github.com/go-jet/jet/postgres"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/dvds/table"
)
@ -15,7 +15,7 @@ func TestLockTable(t *testing.T) {
expectedSQL := `
LOCK TABLE dvds.address IN`
var testData = []TableLockMode{
var testData = []string{
LOCK_ACCESS_SHARE,
LOCK_ROW_SHARE,
LOCK_ROW_EXCLUSIVE,

View file

@ -66,7 +66,12 @@ func TestGeneratedModel(t *testing.T) {
const genTestDir2 = "./.gentestdata2"
func TestCmdGenerator(t *testing.T) {
err := os.RemoveAll(genTestDir2)
goInstallJet := exec.Command("sh", "-c", "go install github.com/go-jet/jet/cmd/jet")
goInstallJet.Stderr = os.Stderr
err := goInstallJet.Run()
assert.NilError(t, err)
err = os.RemoveAll(genTestDir2)
assert.NilError(t, err)
cmd := exec.Command("jet", "-dbname=jetdb", "-host=localhost", "-port=5432",
@ -163,20 +168,20 @@ func assertFileNameEqual(t *testing.T, fileInfos []os.FileInfo, fileNames ...str
var mpaaRatingEnumFile = `
package enum
import "github.com/go-jet/jet"
import "github.com/go-jet/jet/postgres"
var MpaaRating = &struct {
G jet.StringExpression
Pg jet.StringExpression
Pg13 jet.StringExpression
R jet.StringExpression
Nc17 jet.StringExpression
G postgres.StringExpression
Pg postgres.StringExpression
Pg13 postgres.StringExpression
R postgres.StringExpression
Nc17 postgres.StringExpression
}{
G: jet.NewEnumValue("G"),
Pg: jet.NewEnumValue("PG"),
Pg13: jet.NewEnumValue("PG-13"),
R: jet.NewEnumValue("R"),
Nc17: jet.NewEnumValue("NC-17"),
G: postgres.NewEnumValue("G"),
Pg: postgres.NewEnumValue("PG"),
Pg13: postgres.NewEnumValue("PG-13"),
R: postgres.NewEnumValue("R"),
Nc17: postgres.NewEnumValue("NC-17"),
}
`
@ -184,14 +189,13 @@ var actorSQLBuilderFile = `
package table
import (
"github.com/go-jet/jet"
"github.com/go-jet/jet/postgres"
)
var Actor = newActorTable()
type ActorTable struct {
jet.Table
postgres.Table
//Columns
ActorID postgres.ColumnInteger
@ -199,8 +203,8 @@ type ActorTable struct {
LastName postgres.ColumnString
LastUpdate postgres.ColumnTimestamp
AllColumns jet.ColumnList
MutableColumns jet.ColumnList
AllColumns postgres.IColumnList
MutableColumns postgres.IColumnList
}
// creates new ActorTable with assigned alias
@ -221,7 +225,7 @@ func newActorTable() *ActorTable {
)
return &ActorTable{
Table: jet.NewTable(jet.PostgreSQL, "dvds", "actor", ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn),
Table: postgres.NewTable("dvds", "actor", ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn),
//Columns
ActorID: ActorIDColumn,
@ -229,8 +233,8 @@ func newActorTable() *ActorTable {
LastName: LastNameColumn,
LastUpdate: LastUpdateColumn,
AllColumns: jet.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn},
MutableColumns: jet.ColumnList{FirstNameColumn, LastNameColumn, LastUpdateColumn},
AllColumns: postgres.ColumnList(ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn),
MutableColumns: postgres.ColumnList(FirstNameColumn, LastNameColumn, LastUpdateColumn),
}
}
`

View file

@ -1,8 +1,8 @@
package postgres
import (
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/postgres"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
"github.com/google/uuid"

View file

@ -1,8 +1,8 @@
package postgres
import (
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/postgres"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/dvds/model"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/dvds/table"
"github.com/google/uuid"

View file

@ -1,7 +1,6 @@
package postgres
import (
"github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/postgres"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/dvds/enum"
@ -1268,7 +1267,7 @@ func TestAllSetOperators(t *testing.T) {
select1 := Payment.SELECT(Payment.AllColumns).WHERE(Payment.PaymentID.GT_EQ(Int(17600)).AND(Payment.PaymentID.LT(Int(17610))))
select2 := Payment.SELECT(Payment.AllColumns).WHERE(Payment.PaymentID.GT_EQ(Int(17620)).AND(Payment.PaymentID.LT(Int(17630))))
type setOperator func(lhs, rhs jet.SelectStatement, selects ...jet.SelectStatement) jet.SelectStatement
type setOperator func(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
operators := []setOperator{
UNION,
UNION_ALL,

View file

@ -2,8 +2,8 @@ package postgres
import (
"context"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/postgres"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
"gotest.tools/assert"
@ -191,7 +191,7 @@ func TestUpdateWithModelDataAndPredefinedColumnList(t *testing.T) {
Name: "DuckDuckGo",
}
updateColumnList := ColumnList{Link.Description, Link.Name, Link.URL}
updateColumnList := ColumnList(Link.Description, Link.Name, Link.URL)
stmt := Link.
UPDATE(updateColumnList).

View file

@ -1,7 +1,7 @@
package postgres
import (
"github.com/go-jet/jet"
"github.com/go-jet/jet/internal/jet"
"github.com/go-jet/jet/internal/testutils"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/dvds/model"
"github.com/google/uuid"