2019-08-08 17:51:20 +02:00
|
|
|
package postgres
|
|
|
|
|
|
|
|
|
|
import (
|
2021-08-30 15:09:09 +03:00
|
|
|
"fmt"
|
2019-08-08 17:51:20 +02:00
|
|
|
"io/ioutil"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
|
|
|
|
"reflect"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2021-08-30 15:09:09 +03:00
|
|
|
"github.com/go-jet/jet/v2/generator/postgres"
|
|
|
|
|
"github.com/go-jet/jet/v2/internal/testutils"
|
|
|
|
|
"github.com/go-jet/jet/v2/tests/dbconfig"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
2020-06-27 18:48:19 +02:00
|
|
|
"github.com/go-jet/jet/v2/tests/.gentestdata/jetdb/dvds/model"
|
2019-08-08 17:51:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestGeneratedModel(t *testing.T) {
|
|
|
|
|
actor := model.Actor{}
|
|
|
|
|
|
2020-05-09 11:00:22 +02:00
|
|
|
require.Equal(t, reflect.TypeOf(actor.ActorID).String(), "int32")
|
2019-08-08 17:51:20 +02:00
|
|
|
actorIDField, ok := reflect.TypeOf(actor).FieldByName("ActorID")
|
2020-05-09 11:00:22 +02:00
|
|
|
require.True(t, ok)
|
|
|
|
|
require.Equal(t, actorIDField.Tag.Get("sql"), "primary_key")
|
|
|
|
|
require.Equal(t, reflect.TypeOf(actor.FirstName).String(), "string")
|
|
|
|
|
require.Equal(t, reflect.TypeOf(actor.LastName).String(), "string")
|
|
|
|
|
require.Equal(t, reflect.TypeOf(actor.LastUpdate).String(), "time.Time")
|
2019-08-08 17:51:20 +02:00
|
|
|
|
|
|
|
|
filmActor := model.FilmActor{}
|
|
|
|
|
|
2020-05-09 11:00:22 +02:00
|
|
|
require.Equal(t, reflect.TypeOf(filmActor.FilmID).String(), "int16")
|
2019-08-08 17:51:20 +02:00
|
|
|
filmIDField, ok := reflect.TypeOf(filmActor).FieldByName("FilmID")
|
2020-05-09 11:00:22 +02:00
|
|
|
require.True(t, ok)
|
|
|
|
|
require.Equal(t, filmIDField.Tag.Get("sql"), "primary_key")
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2020-05-09 11:00:22 +02:00
|
|
|
require.Equal(t, reflect.TypeOf(filmActor.ActorID).String(), "int16")
|
2019-08-08 17:51:20 +02:00
|
|
|
actorIDField, ok = reflect.TypeOf(filmActor).FieldByName("ActorID")
|
2020-05-09 11:00:22 +02:00
|
|
|
require.True(t, ok)
|
|
|
|
|
require.Equal(t, filmIDField.Tag.Get("sql"), "primary_key")
|
2019-08-08 17:51:20 +02:00
|
|
|
|
|
|
|
|
staff := model.Staff{}
|
|
|
|
|
|
2020-05-09 11:00:22 +02:00
|
|
|
require.Equal(t, reflect.TypeOf(staff.Email).String(), "*string")
|
|
|
|
|
require.Equal(t, reflect.TypeOf(staff.Picture).String(), "*[]uint8")
|
2019-08-08 17:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const genTestDir2 = "./.gentestdata2"
|
|
|
|
|
|
|
|
|
|
func TestCmdGenerator(t *testing.T) {
|
2021-01-24 16:47:06 +01:00
|
|
|
err := os.RemoveAll(genTestDir2)
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2019-08-14 12:50:31 +02:00
|
|
|
cmd := exec.Command("jet", "-source=PostgreSQL", "-dbname=jetdb", "-host=localhost", "-port=5432",
|
2019-08-08 17:51:20 +02:00
|
|
|
"-user=jet", "-password=jet", "-schema=dvds", "-path="+genTestDir2)
|
2019-08-14 12:50:31 +02:00
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
|
cmd.Stdout = os.Stdout
|
2019-08-08 17:51:20 +02:00
|
|
|
|
|
|
|
|
err = cmd.Run()
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2019-08-08 17:51:20 +02:00
|
|
|
|
|
|
|
|
assertGeneratedFiles(t)
|
|
|
|
|
|
|
|
|
|
err = os.RemoveAll(genTestDir2)
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2021-08-30 15:09:09 +03:00
|
|
|
|
|
|
|
|
// Check that connection via DSN works
|
|
|
|
|
dsn := fmt.Sprintf("postgresql://%s:%s@%s:%d/%s?sslmode=disable",
|
|
|
|
|
dbconfig.PgUser,
|
|
|
|
|
dbconfig.PgPassword,
|
|
|
|
|
dbconfig.PgHost,
|
|
|
|
|
dbconfig.PgPort,
|
|
|
|
|
"jetdb",
|
|
|
|
|
)
|
|
|
|
|
cmd = exec.Command("jet", "-dsn="+dsn, "-schema=dvds", "-path="+genTestDir2)
|
|
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
|
cmd.Stdout = os.Stdout
|
|
|
|
|
|
|
|
|
|
err = cmd.Run()
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
assertGeneratedFiles(t)
|
|
|
|
|
|
|
|
|
|
err = os.RemoveAll(genTestDir2)
|
|
|
|
|
require.NoError(t, err)
|
2019-08-08 17:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGenerator(t *testing.T) {
|
|
|
|
|
|
2019-09-20 19:24:54 +02:00
|
|
|
for i := 0; i < 3; i++ {
|
|
|
|
|
err := postgres.Generate(genTestDir2, postgres.DBConnection{
|
2021-07-27 17:39:21 +02:00
|
|
|
Host: dbconfig.PgHost,
|
|
|
|
|
Port: dbconfig.PgPort,
|
|
|
|
|
User: dbconfig.PgUser,
|
|
|
|
|
Password: dbconfig.PgPassword,
|
2019-09-20 19:24:54 +02:00
|
|
|
SslMode: "disable",
|
|
|
|
|
Params: "",
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2021-07-27 17:39:21 +02:00
|
|
|
DBName: dbconfig.PgDBName,
|
2019-09-20 19:24:54 +02:00
|
|
|
SchemaName: "dvds",
|
|
|
|
|
})
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2019-09-20 19:24:54 +02:00
|
|
|
assertGeneratedFiles(t)
|
|
|
|
|
}
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2021-08-30 15:09:09 +03:00
|
|
|
for i := 0; i < 3; i++ {
|
|
|
|
|
dsn := fmt.Sprintf("postgresql://%[1]s:%[2]s@%[3]s:%[4]d/%[5]s?sslmode=disable",
|
|
|
|
|
dbconfig.PgUser,
|
|
|
|
|
dbconfig.PgPassword,
|
|
|
|
|
dbconfig.PgHost,
|
|
|
|
|
dbconfig.PgPort,
|
|
|
|
|
dbconfig.PgDBName,
|
|
|
|
|
)
|
|
|
|
|
err := postgres.GenerateDSN(dsn, "dvds", genTestDir2)
|
|
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
assertGeneratedFiles(t)
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-20 19:24:54 +02:00
|
|
|
err := os.RemoveAll(genTestDir2)
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2019-08-08 17:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func assertGeneratedFiles(t *testing.T) {
|
|
|
|
|
// Table SQL Builder files
|
|
|
|
|
tableSQLBuilderFiles, err := ioutil.ReadDir("./.gentestdata2/jetdb/dvds/table")
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2019-09-20 12:53:52 +02:00
|
|
|
testutils.AssertFileNamesEqual(t, tableSQLBuilderFiles, "actor.go", "address.go", "category.go", "city.go", "country.go",
|
2019-08-08 17:51:20 +02:00
|
|
|
"customer.go", "film.go", "film_actor.go", "film_category.go", "inventory.go", "language.go",
|
|
|
|
|
"payment.go", "rental.go", "staff.go", "store.go")
|
|
|
|
|
|
2020-04-13 10:18:14 +02:00
|
|
|
testutils.AssertFileContent(t, "./.gentestdata2/jetdb/dvds/table/actor.go", actorSQLBuilderFile)
|
2019-09-20 12:53:52 +02:00
|
|
|
|
|
|
|
|
// View SQL Builder files
|
|
|
|
|
viewSQLBuilderFiles, err := ioutil.ReadDir("./.gentestdata2/jetdb/dvds/view")
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2019-09-20 12:53:52 +02:00
|
|
|
|
|
|
|
|
testutils.AssertFileNamesEqual(t, viewSQLBuilderFiles, "actor_info.go", "film_list.go", "nicer_but_slower_film_list.go",
|
|
|
|
|
"sales_by_film_category.go", "customer_list.go", "sales_by_store.go", "staff_list.go")
|
|
|
|
|
|
2020-04-13 10:18:14 +02:00
|
|
|
testutils.AssertFileContent(t, "./.gentestdata2/jetdb/dvds/view/actor_info.go", actorInfoSQLBuilderFile)
|
2019-08-08 17:51:20 +02:00
|
|
|
|
|
|
|
|
// Enums SQL Builder files
|
|
|
|
|
enumFiles, err := ioutil.ReadDir("./.gentestdata2/jetdb/dvds/enum")
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2019-09-20 12:53:52 +02:00
|
|
|
testutils.AssertFileNamesEqual(t, enumFiles, "mpaa_rating.go")
|
2020-04-13 10:18:14 +02:00
|
|
|
testutils.AssertFileContent(t, "./.gentestdata2/jetdb/dvds/enum/mpaa_rating.go", mpaaRatingEnumFile)
|
2019-08-08 17:51:20 +02:00
|
|
|
|
|
|
|
|
// Model files
|
|
|
|
|
modelFiles, err := ioutil.ReadDir("./.gentestdata2/jetdb/dvds/model")
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2019-09-20 12:53:52 +02:00
|
|
|
testutils.AssertFileNamesEqual(t, modelFiles, "actor.go", "address.go", "category.go", "city.go", "country.go",
|
2019-08-08 17:51:20 +02:00
|
|
|
"customer.go", "film.go", "film_actor.go", "film_category.go", "inventory.go", "language.go",
|
2019-09-20 12:53:52 +02:00
|
|
|
"payment.go", "rental.go", "staff.go", "store.go", "mpaa_rating.go",
|
|
|
|
|
"actor_info.go", "film_list.go", "nicer_but_slower_film_list.go", "sales_by_film_category.go",
|
|
|
|
|
"customer_list.go", "sales_by_store.go", "staff_list.go")
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2020-04-13 10:18:14 +02:00
|
|
|
testutils.AssertFileContent(t, "./.gentestdata2/jetdb/dvds/model/actor.go", actorModelFile)
|
2019-08-08 17:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mpaaRatingEnumFile = `
|
2020-04-13 10:18:14 +02:00
|
|
|
//
|
|
|
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
|
|
|
//
|
|
|
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
|
|
|
// and will be lost if the code is regenerated
|
|
|
|
|
//
|
|
|
|
|
|
2019-08-08 17:51:20 +02:00
|
|
|
package enum
|
|
|
|
|
|
2020-06-27 18:48:19 +02:00
|
|
|
import "github.com/go-jet/jet/v2/postgres"
|
2019-08-08 17:51:20 +02:00
|
|
|
|
|
|
|
|
var MpaaRating = &struct {
|
|
|
|
|
G postgres.StringExpression
|
|
|
|
|
Pg postgres.StringExpression
|
|
|
|
|
Pg13 postgres.StringExpression
|
|
|
|
|
R postgres.StringExpression
|
|
|
|
|
Nc17 postgres.StringExpression
|
|
|
|
|
}{
|
|
|
|
|
G: postgres.NewEnumValue("G"),
|
|
|
|
|
Pg: postgres.NewEnumValue("PG"),
|
|
|
|
|
Pg13: postgres.NewEnumValue("PG-13"),
|
|
|
|
|
R: postgres.NewEnumValue("R"),
|
|
|
|
|
Nc17: postgres.NewEnumValue("NC-17"),
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
var actorSQLBuilderFile = `
|
2020-04-13 10:18:14 +02:00
|
|
|
//
|
|
|
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
|
|
|
//
|
|
|
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
|
|
|
// and will be lost if the code is regenerated
|
|
|
|
|
//
|
|
|
|
|
|
2019-08-08 17:51:20 +02:00
|
|
|
package table
|
|
|
|
|
|
|
|
|
|
import (
|
2020-06-27 18:48:19 +02:00
|
|
|
"github.com/go-jet/jet/v2/postgres"
|
2019-08-08 17:51:20 +02:00
|
|
|
)
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
var Actor = newActorTable("dvds", "actor", "")
|
2019-08-08 17:51:20 +02:00
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
type actorTable struct {
|
2019-08-08 17:51:20 +02:00
|
|
|
postgres.Table
|
|
|
|
|
|
|
|
|
|
//Columns
|
|
|
|
|
ActorID postgres.ColumnInteger
|
|
|
|
|
FirstName postgres.ColumnString
|
|
|
|
|
LastName postgres.ColumnString
|
|
|
|
|
LastUpdate postgres.ColumnTimestamp
|
|
|
|
|
|
2019-09-26 12:31:03 +02:00
|
|
|
AllColumns postgres.ColumnList
|
|
|
|
|
MutableColumns postgres.ColumnList
|
2019-08-08 17:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
type ActorTable struct {
|
|
|
|
|
actorTable
|
|
|
|
|
|
|
|
|
|
EXCLUDED actorTable
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 21:30:57 +02:00
|
|
|
// AS creates new ActorTable with assigned alias
|
2021-03-21 17:17:44 +01:00
|
|
|
func (a ActorTable) AS(alias string) *ActorTable {
|
|
|
|
|
return newActorTable(a.SchemaName(), a.TableName(), alias)
|
2019-08-08 17:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
// Schema creates new ActorTable with assigned schema name
|
|
|
|
|
func (a ActorTable) FromSchema(schemaName string) *ActorTable {
|
|
|
|
|
return newActorTable(schemaName, a.TableName(), a.Alias())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newActorTable(schemaName, tableName, alias string) *ActorTable {
|
2020-04-12 18:53:57 +02:00
|
|
|
return &ActorTable{
|
2021-03-21 17:17:44 +01:00
|
|
|
actorTable: newActorTableImpl(schemaName, tableName, alias),
|
|
|
|
|
EXCLUDED: newActorTableImpl("", "excluded", ""),
|
2020-04-12 18:53:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
func newActorTableImpl(schemaName, tableName, alias string) actorTable {
|
2019-08-08 17:51:20 +02:00
|
|
|
var (
|
|
|
|
|
ActorIDColumn = postgres.IntegerColumn("actor_id")
|
|
|
|
|
FirstNameColumn = postgres.StringColumn("first_name")
|
|
|
|
|
LastNameColumn = postgres.StringColumn("last_name")
|
|
|
|
|
LastUpdateColumn = postgres.TimestampColumn("last_update")
|
2020-04-12 18:53:57 +02:00
|
|
|
allColumns = postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn}
|
|
|
|
|
mutableColumns = postgres.ColumnList{FirstNameColumn, LastNameColumn, LastUpdateColumn}
|
2019-08-08 17:51:20 +02:00
|
|
|
)
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
return actorTable{
|
2021-03-21 17:17:44 +01:00
|
|
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
2019-08-08 17:51:20 +02:00
|
|
|
|
|
|
|
|
//Columns
|
|
|
|
|
ActorID: ActorIDColumn,
|
|
|
|
|
FirstName: FirstNameColumn,
|
|
|
|
|
LastName: LastNameColumn,
|
|
|
|
|
LastUpdate: LastUpdateColumn,
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
AllColumns: allColumns,
|
|
|
|
|
MutableColumns: mutableColumns,
|
2019-08-08 17:51:20 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
var actorModelFile = `
|
2020-04-13 10:18:14 +02:00
|
|
|
//
|
|
|
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
|
|
|
//
|
|
|
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
|
|
|
// and will be lost if the code is regenerated
|
|
|
|
|
//
|
|
|
|
|
|
2019-08-08 17:51:20 +02:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Actor struct {
|
|
|
|
|
ActorID int32 ` + "`sql:\"primary_key\"`" + `
|
|
|
|
|
FirstName string
|
|
|
|
|
LastName string
|
|
|
|
|
LastUpdate time.Time
|
|
|
|
|
}
|
|
|
|
|
`
|
2019-09-20 12:53:52 +02:00
|
|
|
|
|
|
|
|
var actorInfoSQLBuilderFile = `
|
2020-04-13 10:18:14 +02:00
|
|
|
//
|
|
|
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
|
|
|
//
|
|
|
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
|
|
|
// and will be lost if the code is regenerated
|
|
|
|
|
//
|
|
|
|
|
|
2019-09-20 12:53:52 +02:00
|
|
|
package view
|
|
|
|
|
|
|
|
|
|
import (
|
2020-06-27 18:48:19 +02:00
|
|
|
"github.com/go-jet/jet/v2/postgres"
|
2019-09-20 12:53:52 +02:00
|
|
|
)
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
var ActorInfo = newActorInfoTable("dvds", "actor_info", "")
|
2019-09-20 12:53:52 +02:00
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
type actorInfoTable struct {
|
2019-09-20 12:53:52 +02:00
|
|
|
postgres.Table
|
|
|
|
|
|
|
|
|
|
//Columns
|
|
|
|
|
ActorID postgres.ColumnInteger
|
|
|
|
|
FirstName postgres.ColumnString
|
|
|
|
|
LastName postgres.ColumnString
|
|
|
|
|
FilmInfo postgres.ColumnString
|
|
|
|
|
|
2019-09-26 12:31:03 +02:00
|
|
|
AllColumns postgres.ColumnList
|
|
|
|
|
MutableColumns postgres.ColumnList
|
2019-09-20 12:53:52 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
type ActorInfoTable struct {
|
|
|
|
|
actorInfoTable
|
|
|
|
|
|
|
|
|
|
EXCLUDED actorInfoTable
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 21:30:57 +02:00
|
|
|
// AS creates new ActorInfoTable with assigned alias
|
2021-03-21 17:17:44 +01:00
|
|
|
func (a ActorInfoTable) AS(alias string) *ActorInfoTable {
|
|
|
|
|
return newActorInfoTable(a.SchemaName(), a.TableName(), alias)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Schema creates new ActorInfoTable with assigned schema name
|
|
|
|
|
func (a ActorInfoTable) FromSchema(schemaName string) *ActorInfoTable {
|
|
|
|
|
return newActorInfoTable(schemaName, a.TableName(), a.Alias())
|
2019-09-20 12:53:52 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
func newActorInfoTable(schemaName, tableName, alias string) *ActorInfoTable {
|
2020-04-12 18:53:57 +02:00
|
|
|
return &ActorInfoTable{
|
2021-03-21 17:17:44 +01:00
|
|
|
actorInfoTable: newActorInfoTableImpl(schemaName, tableName, alias),
|
|
|
|
|
EXCLUDED: newActorInfoTableImpl("", "excluded", ""),
|
2020-04-12 18:53:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
func newActorInfoTableImpl(schemaName, tableName, alias string) actorInfoTable {
|
2019-09-20 12:53:52 +02:00
|
|
|
var (
|
|
|
|
|
ActorIDColumn = postgres.IntegerColumn("actor_id")
|
|
|
|
|
FirstNameColumn = postgres.StringColumn("first_name")
|
|
|
|
|
LastNameColumn = postgres.StringColumn("last_name")
|
|
|
|
|
FilmInfoColumn = postgres.StringColumn("film_info")
|
2020-04-12 18:53:57 +02:00
|
|
|
allColumns = postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn}
|
|
|
|
|
mutableColumns = postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn}
|
2019-09-20 12:53:52 +02:00
|
|
|
)
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
return actorInfoTable{
|
2021-03-21 17:17:44 +01:00
|
|
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
2019-09-20 12:53:52 +02:00
|
|
|
|
|
|
|
|
//Columns
|
|
|
|
|
ActorID: ActorIDColumn,
|
|
|
|
|
FirstName: FirstNameColumn,
|
|
|
|
|
LastName: LastNameColumn,
|
|
|
|
|
FilmInfo: FilmInfoColumn,
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
AllColumns: allColumns,
|
|
|
|
|
MutableColumns: mutableColumns,
|
2019-09-20 12:53:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
2020-02-09 18:37:48 +01:00
|
|
|
|
|
|
|
|
func TestGeneratedAllTypesSQLBuilderFiles(t *testing.T) {
|
|
|
|
|
enumDir := testRoot + ".gentestdata/jetdb/test_sample/enum/"
|
|
|
|
|
modelDir := testRoot + ".gentestdata/jetdb/test_sample/model/"
|
|
|
|
|
tableDir := testRoot + ".gentestdata/jetdb/test_sample/table/"
|
|
|
|
|
|
|
|
|
|
enumFiles, err := ioutil.ReadDir(enumDir)
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2020-02-09 18:37:48 +01:00
|
|
|
|
2020-02-15 11:20:51 +01:00
|
|
|
testutils.AssertFileNamesEqual(t, enumFiles, "mood.go", "level.go")
|
2020-04-13 10:18:14 +02:00
|
|
|
testutils.AssertFileContent(t, enumDir+"mood.go", moodEnumContent)
|
|
|
|
|
testutils.AssertFileContent(t, enumDir+"level.go", levelEnumContent)
|
2020-02-09 18:37:48 +01:00
|
|
|
|
|
|
|
|
modelFiles, err := ioutil.ReadDir(modelDir)
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2020-02-09 18:37:48 +01:00
|
|
|
|
|
|
|
|
testutils.AssertFileNamesEqual(t, modelFiles, "all_types.go", "all_types_view.go", "employee.go", "link.go",
|
2021-05-09 16:37:16 +02:00
|
|
|
"mood.go", "person.go", "person_phone.go", "weird_names_table.go", "level.go", "user.go", "floats.go")
|
2020-02-09 18:37:48 +01:00
|
|
|
|
2020-04-13 10:18:14 +02:00
|
|
|
testutils.AssertFileContent(t, modelDir+"all_types.go", allTypesModelContent)
|
2020-02-09 18:37:48 +01:00
|
|
|
|
|
|
|
|
tableFiles, err := ioutil.ReadDir(tableDir)
|
2020-05-09 11:00:22 +02:00
|
|
|
require.NoError(t, err)
|
2020-02-09 18:37:48 +01:00
|
|
|
|
|
|
|
|
testutils.AssertFileNamesEqual(t, tableFiles, "all_types.go", "employee.go", "link.go",
|
2021-05-09 16:37:16 +02:00
|
|
|
"person.go", "person_phone.go", "weird_names_table.go", "user.go", "floats.go")
|
2020-02-09 18:37:48 +01:00
|
|
|
|
2020-04-13 10:18:14 +02:00
|
|
|
testutils.AssertFileContent(t, tableDir+"all_types.go", allTypesTableContent)
|
2020-02-09 18:37:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var moodEnumContent = `
|
2020-04-13 10:18:14 +02:00
|
|
|
//
|
|
|
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
|
|
|
//
|
|
|
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
|
|
|
// and will be lost if the code is regenerated
|
|
|
|
|
//
|
|
|
|
|
|
2020-02-09 18:37:48 +01:00
|
|
|
package enum
|
|
|
|
|
|
2020-06-27 18:48:19 +02:00
|
|
|
import "github.com/go-jet/jet/v2/postgres"
|
2020-02-09 18:37:48 +01:00
|
|
|
|
|
|
|
|
var Mood = &struct {
|
|
|
|
|
Sad postgres.StringExpression
|
|
|
|
|
Ok postgres.StringExpression
|
|
|
|
|
Happy postgres.StringExpression
|
|
|
|
|
}{
|
|
|
|
|
Sad: postgres.NewEnumValue("sad"),
|
|
|
|
|
Ok: postgres.NewEnumValue("ok"),
|
|
|
|
|
Happy: postgres.NewEnumValue("happy"),
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
2020-02-15 11:20:51 +01:00
|
|
|
var levelEnumContent = `
|
2020-04-13 10:18:14 +02:00
|
|
|
//
|
|
|
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
|
|
|
//
|
|
|
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
|
|
|
// and will be lost if the code is regenerated
|
|
|
|
|
//
|
|
|
|
|
|
2020-02-15 11:20:51 +01:00
|
|
|
package enum
|
|
|
|
|
|
2020-06-27 18:48:19 +02:00
|
|
|
import "github.com/go-jet/jet/v2/postgres"
|
2020-02-15 11:20:51 +01:00
|
|
|
|
|
|
|
|
var Level = &struct {
|
|
|
|
|
Level1 postgres.StringExpression
|
|
|
|
|
Level2 postgres.StringExpression
|
|
|
|
|
Level3 postgres.StringExpression
|
|
|
|
|
Level4 postgres.StringExpression
|
|
|
|
|
Level5 postgres.StringExpression
|
|
|
|
|
}{
|
|
|
|
|
Level1: postgres.NewEnumValue("1"),
|
|
|
|
|
Level2: postgres.NewEnumValue("2"),
|
|
|
|
|
Level3: postgres.NewEnumValue("3"),
|
|
|
|
|
Level4: postgres.NewEnumValue("4"),
|
|
|
|
|
Level5: postgres.NewEnumValue("5"),
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
2020-02-09 18:37:48 +01:00
|
|
|
var allTypesModelContent = `
|
2020-04-13 10:18:14 +02:00
|
|
|
//
|
|
|
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
|
|
|
//
|
|
|
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
|
|
|
// and will be lost if the code is regenerated
|
|
|
|
|
//
|
|
|
|
|
|
2020-02-09 18:37:48 +01:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type AllTypes struct {
|
|
|
|
|
SmallIntPtr *int16
|
|
|
|
|
SmallInt int16
|
|
|
|
|
IntegerPtr *int32
|
|
|
|
|
Integer int32
|
|
|
|
|
BigIntPtr *int64
|
|
|
|
|
BigInt int64
|
|
|
|
|
DecimalPtr *float64
|
|
|
|
|
Decimal float64
|
|
|
|
|
NumericPtr *float64
|
|
|
|
|
Numeric float64
|
|
|
|
|
RealPtr *float32
|
|
|
|
|
Real float32
|
|
|
|
|
DoublePrecisionPtr *float64
|
|
|
|
|
DoublePrecision float64
|
|
|
|
|
Smallserial int16
|
|
|
|
|
Serial int32
|
|
|
|
|
Bigserial int64
|
|
|
|
|
VarCharPtr *string
|
|
|
|
|
VarChar string
|
|
|
|
|
CharPtr *string
|
|
|
|
|
Char string
|
|
|
|
|
TextPtr *string
|
|
|
|
|
Text string
|
|
|
|
|
ByteaPtr *[]byte
|
|
|
|
|
Bytea []byte
|
|
|
|
|
TimestampzPtr *time.Time
|
|
|
|
|
Timestampz time.Time
|
|
|
|
|
TimestampPtr *time.Time
|
|
|
|
|
Timestamp time.Time
|
|
|
|
|
DatePtr *time.Time
|
|
|
|
|
Date time.Time
|
|
|
|
|
TimezPtr *time.Time
|
|
|
|
|
Timez time.Time
|
|
|
|
|
TimePtr *time.Time
|
|
|
|
|
Time time.Time
|
|
|
|
|
IntervalPtr *string
|
|
|
|
|
Interval string
|
|
|
|
|
BooleanPtr *bool
|
|
|
|
|
Boolean bool
|
|
|
|
|
PointPtr *string
|
|
|
|
|
BitPtr *string
|
|
|
|
|
Bit string
|
|
|
|
|
BitVaryingPtr *string
|
|
|
|
|
BitVarying string
|
|
|
|
|
TsvectorPtr *string
|
|
|
|
|
Tsvector string
|
|
|
|
|
UUIDPtr *uuid.UUID
|
|
|
|
|
UUID uuid.UUID
|
|
|
|
|
XMLPtr *string
|
|
|
|
|
XML string
|
|
|
|
|
JSONPtr *string
|
|
|
|
|
JSON string
|
|
|
|
|
JsonbPtr *string
|
|
|
|
|
Jsonb string
|
|
|
|
|
IntegerArrayPtr *string
|
|
|
|
|
IntegerArray string
|
|
|
|
|
TextArrayPtr *string
|
|
|
|
|
TextArray string
|
|
|
|
|
JsonbArray string
|
|
|
|
|
TextMultiDimArrayPtr *string
|
|
|
|
|
TextMultiDimArray string
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
var allTypesTableContent = `
|
2020-04-13 10:18:14 +02:00
|
|
|
//
|
|
|
|
|
// Code generated by go-jet DO NOT EDIT.
|
|
|
|
|
//
|
|
|
|
|
// WARNING: Changes to this file may cause incorrect behavior
|
|
|
|
|
// and will be lost if the code is regenerated
|
|
|
|
|
//
|
|
|
|
|
|
2020-02-09 18:37:48 +01:00
|
|
|
package table
|
|
|
|
|
|
|
|
|
|
import (
|
2020-06-27 18:48:19 +02:00
|
|
|
"github.com/go-jet/jet/v2/postgres"
|
2020-02-09 18:37:48 +01:00
|
|
|
)
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
var AllTypes = newAllTypesTable("test_sample", "all_types", "")
|
2020-02-09 18:37:48 +01:00
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
type allTypesTable struct {
|
2020-02-09 18:37:48 +01:00
|
|
|
postgres.Table
|
|
|
|
|
|
|
|
|
|
//Columns
|
|
|
|
|
SmallIntPtr postgres.ColumnInteger
|
|
|
|
|
SmallInt postgres.ColumnInteger
|
|
|
|
|
IntegerPtr postgres.ColumnInteger
|
|
|
|
|
Integer postgres.ColumnInteger
|
|
|
|
|
BigIntPtr postgres.ColumnInteger
|
|
|
|
|
BigInt postgres.ColumnInteger
|
|
|
|
|
DecimalPtr postgres.ColumnFloat
|
|
|
|
|
Decimal postgres.ColumnFloat
|
|
|
|
|
NumericPtr postgres.ColumnFloat
|
|
|
|
|
Numeric postgres.ColumnFloat
|
|
|
|
|
RealPtr postgres.ColumnFloat
|
|
|
|
|
Real postgres.ColumnFloat
|
|
|
|
|
DoublePrecisionPtr postgres.ColumnFloat
|
|
|
|
|
DoublePrecision postgres.ColumnFloat
|
|
|
|
|
Smallserial postgres.ColumnInteger
|
|
|
|
|
Serial postgres.ColumnInteger
|
|
|
|
|
Bigserial postgres.ColumnInteger
|
|
|
|
|
VarCharPtr postgres.ColumnString
|
|
|
|
|
VarChar postgres.ColumnString
|
|
|
|
|
CharPtr postgres.ColumnString
|
|
|
|
|
Char postgres.ColumnString
|
|
|
|
|
TextPtr postgres.ColumnString
|
|
|
|
|
Text postgres.ColumnString
|
|
|
|
|
ByteaPtr postgres.ColumnString
|
|
|
|
|
Bytea postgres.ColumnString
|
|
|
|
|
TimestampzPtr postgres.ColumnTimestampz
|
|
|
|
|
Timestampz postgres.ColumnTimestampz
|
|
|
|
|
TimestampPtr postgres.ColumnTimestamp
|
|
|
|
|
Timestamp postgres.ColumnTimestamp
|
|
|
|
|
DatePtr postgres.ColumnDate
|
|
|
|
|
Date postgres.ColumnDate
|
|
|
|
|
TimezPtr postgres.ColumnTimez
|
|
|
|
|
Timez postgres.ColumnTimez
|
|
|
|
|
TimePtr postgres.ColumnTime
|
|
|
|
|
Time postgres.ColumnTime
|
|
|
|
|
IntervalPtr postgres.ColumnInterval
|
|
|
|
|
Interval postgres.ColumnInterval
|
|
|
|
|
BooleanPtr postgres.ColumnBool
|
|
|
|
|
Boolean postgres.ColumnBool
|
|
|
|
|
PointPtr postgres.ColumnString
|
|
|
|
|
BitPtr postgres.ColumnString
|
|
|
|
|
Bit postgres.ColumnString
|
|
|
|
|
BitVaryingPtr postgres.ColumnString
|
|
|
|
|
BitVarying postgres.ColumnString
|
|
|
|
|
TsvectorPtr postgres.ColumnString
|
|
|
|
|
Tsvector postgres.ColumnString
|
|
|
|
|
UUIDPtr postgres.ColumnString
|
|
|
|
|
UUID postgres.ColumnString
|
|
|
|
|
XMLPtr postgres.ColumnString
|
|
|
|
|
XML postgres.ColumnString
|
|
|
|
|
JSONPtr postgres.ColumnString
|
|
|
|
|
JSON postgres.ColumnString
|
|
|
|
|
JsonbPtr postgres.ColumnString
|
|
|
|
|
Jsonb postgres.ColumnString
|
|
|
|
|
IntegerArrayPtr postgres.ColumnString
|
|
|
|
|
IntegerArray postgres.ColumnString
|
|
|
|
|
TextArrayPtr postgres.ColumnString
|
|
|
|
|
TextArray postgres.ColumnString
|
|
|
|
|
JsonbArray postgres.ColumnString
|
|
|
|
|
TextMultiDimArrayPtr postgres.ColumnString
|
|
|
|
|
TextMultiDimArray postgres.ColumnString
|
|
|
|
|
|
|
|
|
|
AllColumns postgres.ColumnList
|
|
|
|
|
MutableColumns postgres.ColumnList
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
type AllTypesTable struct {
|
|
|
|
|
allTypesTable
|
|
|
|
|
|
|
|
|
|
EXCLUDED allTypesTable
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 21:30:57 +02:00
|
|
|
// AS creates new AllTypesTable with assigned alias
|
2021-03-21 17:17:44 +01:00
|
|
|
func (a AllTypesTable) AS(alias string) *AllTypesTable {
|
|
|
|
|
return newAllTypesTable(a.SchemaName(), a.TableName(), alias)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Schema creates new AllTypesTable with assigned schema name
|
|
|
|
|
func (a AllTypesTable) FromSchema(schemaName string) *AllTypesTable {
|
|
|
|
|
return newAllTypesTable(schemaName, a.TableName(), a.Alias())
|
2020-02-09 18:37:48 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
func newAllTypesTable(schemaName, tableName, alias string) *AllTypesTable {
|
2020-04-12 18:53:57 +02:00
|
|
|
return &AllTypesTable{
|
2021-03-21 17:17:44 +01:00
|
|
|
allTypesTable: newAllTypesTableImpl(schemaName, tableName, alias),
|
|
|
|
|
EXCLUDED: newAllTypesTableImpl("", "excluded", ""),
|
2020-04-12 18:53:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-21 17:17:44 +01:00
|
|
|
func newAllTypesTableImpl(schemaName, tableName, alias string) allTypesTable {
|
2020-02-09 18:37:48 +01:00
|
|
|
var (
|
|
|
|
|
SmallIntPtrColumn = postgres.IntegerColumn("small_int_ptr")
|
|
|
|
|
SmallIntColumn = postgres.IntegerColumn("small_int")
|
|
|
|
|
IntegerPtrColumn = postgres.IntegerColumn("integer_ptr")
|
|
|
|
|
IntegerColumn = postgres.IntegerColumn("integer")
|
|
|
|
|
BigIntPtrColumn = postgres.IntegerColumn("big_int_ptr")
|
|
|
|
|
BigIntColumn = postgres.IntegerColumn("big_int")
|
|
|
|
|
DecimalPtrColumn = postgres.FloatColumn("decimal_ptr")
|
|
|
|
|
DecimalColumn = postgres.FloatColumn("decimal")
|
|
|
|
|
NumericPtrColumn = postgres.FloatColumn("numeric_ptr")
|
|
|
|
|
NumericColumn = postgres.FloatColumn("numeric")
|
|
|
|
|
RealPtrColumn = postgres.FloatColumn("real_ptr")
|
|
|
|
|
RealColumn = postgres.FloatColumn("real")
|
|
|
|
|
DoublePrecisionPtrColumn = postgres.FloatColumn("double_precision_ptr")
|
|
|
|
|
DoublePrecisionColumn = postgres.FloatColumn("double_precision")
|
|
|
|
|
SmallserialColumn = postgres.IntegerColumn("smallserial")
|
|
|
|
|
SerialColumn = postgres.IntegerColumn("serial")
|
|
|
|
|
BigserialColumn = postgres.IntegerColumn("bigserial")
|
|
|
|
|
VarCharPtrColumn = postgres.StringColumn("var_char_ptr")
|
|
|
|
|
VarCharColumn = postgres.StringColumn("var_char")
|
|
|
|
|
CharPtrColumn = postgres.StringColumn("char_ptr")
|
|
|
|
|
CharColumn = postgres.StringColumn("char")
|
|
|
|
|
TextPtrColumn = postgres.StringColumn("text_ptr")
|
|
|
|
|
TextColumn = postgres.StringColumn("text")
|
|
|
|
|
ByteaPtrColumn = postgres.StringColumn("bytea_ptr")
|
|
|
|
|
ByteaColumn = postgres.StringColumn("bytea")
|
|
|
|
|
TimestampzPtrColumn = postgres.TimestampzColumn("timestampz_ptr")
|
|
|
|
|
TimestampzColumn = postgres.TimestampzColumn("timestampz")
|
|
|
|
|
TimestampPtrColumn = postgres.TimestampColumn("timestamp_ptr")
|
|
|
|
|
TimestampColumn = postgres.TimestampColumn("timestamp")
|
|
|
|
|
DatePtrColumn = postgres.DateColumn("date_ptr")
|
|
|
|
|
DateColumn = postgres.DateColumn("date")
|
|
|
|
|
TimezPtrColumn = postgres.TimezColumn("timez_ptr")
|
|
|
|
|
TimezColumn = postgres.TimezColumn("timez")
|
|
|
|
|
TimePtrColumn = postgres.TimeColumn("time_ptr")
|
|
|
|
|
TimeColumn = postgres.TimeColumn("time")
|
|
|
|
|
IntervalPtrColumn = postgres.IntervalColumn("interval_ptr")
|
|
|
|
|
IntervalColumn = postgres.IntervalColumn("interval")
|
|
|
|
|
BooleanPtrColumn = postgres.BoolColumn("boolean_ptr")
|
|
|
|
|
BooleanColumn = postgres.BoolColumn("boolean")
|
|
|
|
|
PointPtrColumn = postgres.StringColumn("point_ptr")
|
|
|
|
|
BitPtrColumn = postgres.StringColumn("bit_ptr")
|
|
|
|
|
BitColumn = postgres.StringColumn("bit")
|
|
|
|
|
BitVaryingPtrColumn = postgres.StringColumn("bit_varying_ptr")
|
|
|
|
|
BitVaryingColumn = postgres.StringColumn("bit_varying")
|
|
|
|
|
TsvectorPtrColumn = postgres.StringColumn("tsvector_ptr")
|
|
|
|
|
TsvectorColumn = postgres.StringColumn("tsvector")
|
|
|
|
|
UUIDPtrColumn = postgres.StringColumn("uuid_ptr")
|
|
|
|
|
UUIDColumn = postgres.StringColumn("uuid")
|
|
|
|
|
XMLPtrColumn = postgres.StringColumn("xml_ptr")
|
|
|
|
|
XMLColumn = postgres.StringColumn("xml")
|
|
|
|
|
JSONPtrColumn = postgres.StringColumn("json_ptr")
|
|
|
|
|
JSONColumn = postgres.StringColumn("json")
|
|
|
|
|
JsonbPtrColumn = postgres.StringColumn("jsonb_ptr")
|
|
|
|
|
JsonbColumn = postgres.StringColumn("jsonb")
|
|
|
|
|
IntegerArrayPtrColumn = postgres.StringColumn("integer_array_ptr")
|
|
|
|
|
IntegerArrayColumn = postgres.StringColumn("integer_array")
|
|
|
|
|
TextArrayPtrColumn = postgres.StringColumn("text_array_ptr")
|
|
|
|
|
TextArrayColumn = postgres.StringColumn("text_array")
|
|
|
|
|
JsonbArrayColumn = postgres.StringColumn("jsonb_array")
|
|
|
|
|
TextMultiDimArrayPtrColumn = postgres.StringColumn("text_multi_dim_array_ptr")
|
|
|
|
|
TextMultiDimArrayColumn = postgres.StringColumn("text_multi_dim_array")
|
2020-04-12 18:53:57 +02:00
|
|
|
allColumns = postgres.ColumnList{SmallIntPtrColumn, SmallIntColumn, IntegerPtrColumn, IntegerColumn, BigIntPtrColumn, BigIntColumn, DecimalPtrColumn, DecimalColumn, NumericPtrColumn, NumericColumn, RealPtrColumn, RealColumn, DoublePrecisionPtrColumn, DoublePrecisionColumn, SmallserialColumn, SerialColumn, BigserialColumn, VarCharPtrColumn, VarCharColumn, CharPtrColumn, CharColumn, TextPtrColumn, TextColumn, ByteaPtrColumn, ByteaColumn, TimestampzPtrColumn, TimestampzColumn, TimestampPtrColumn, TimestampColumn, DatePtrColumn, DateColumn, TimezPtrColumn, TimezColumn, TimePtrColumn, TimeColumn, IntervalPtrColumn, IntervalColumn, BooleanPtrColumn, BooleanColumn, PointPtrColumn, BitPtrColumn, BitColumn, BitVaryingPtrColumn, BitVaryingColumn, TsvectorPtrColumn, TsvectorColumn, UUIDPtrColumn, UUIDColumn, XMLPtrColumn, XMLColumn, JSONPtrColumn, JSONColumn, JsonbPtrColumn, JsonbColumn, IntegerArrayPtrColumn, IntegerArrayColumn, TextArrayPtrColumn, TextArrayColumn, JsonbArrayColumn, TextMultiDimArrayPtrColumn, TextMultiDimArrayColumn}
|
|
|
|
|
mutableColumns = postgres.ColumnList{SmallIntPtrColumn, SmallIntColumn, IntegerPtrColumn, IntegerColumn, BigIntPtrColumn, BigIntColumn, DecimalPtrColumn, DecimalColumn, NumericPtrColumn, NumericColumn, RealPtrColumn, RealColumn, DoublePrecisionPtrColumn, DoublePrecisionColumn, SmallserialColumn, SerialColumn, BigserialColumn, VarCharPtrColumn, VarCharColumn, CharPtrColumn, CharColumn, TextPtrColumn, TextColumn, ByteaPtrColumn, ByteaColumn, TimestampzPtrColumn, TimestampzColumn, TimestampPtrColumn, TimestampColumn, DatePtrColumn, DateColumn, TimezPtrColumn, TimezColumn, TimePtrColumn, TimeColumn, IntervalPtrColumn, IntervalColumn, BooleanPtrColumn, BooleanColumn, PointPtrColumn, BitPtrColumn, BitColumn, BitVaryingPtrColumn, BitVaryingColumn, TsvectorPtrColumn, TsvectorColumn, UUIDPtrColumn, UUIDColumn, XMLPtrColumn, XMLColumn, JSONPtrColumn, JSONColumn, JsonbPtrColumn, JsonbColumn, IntegerArrayPtrColumn, IntegerArrayColumn, TextArrayPtrColumn, TextArrayColumn, JsonbArrayColumn, TextMultiDimArrayPtrColumn, TextMultiDimArrayColumn}
|
2020-02-09 18:37:48 +01:00
|
|
|
)
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
return allTypesTable{
|
2021-03-21 17:17:44 +01:00
|
|
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
2020-02-09 18:37:48 +01:00
|
|
|
|
|
|
|
|
//Columns
|
|
|
|
|
SmallIntPtr: SmallIntPtrColumn,
|
|
|
|
|
SmallInt: SmallIntColumn,
|
|
|
|
|
IntegerPtr: IntegerPtrColumn,
|
|
|
|
|
Integer: IntegerColumn,
|
|
|
|
|
BigIntPtr: BigIntPtrColumn,
|
|
|
|
|
BigInt: BigIntColumn,
|
|
|
|
|
DecimalPtr: DecimalPtrColumn,
|
|
|
|
|
Decimal: DecimalColumn,
|
|
|
|
|
NumericPtr: NumericPtrColumn,
|
|
|
|
|
Numeric: NumericColumn,
|
|
|
|
|
RealPtr: RealPtrColumn,
|
|
|
|
|
Real: RealColumn,
|
|
|
|
|
DoublePrecisionPtr: DoublePrecisionPtrColumn,
|
|
|
|
|
DoublePrecision: DoublePrecisionColumn,
|
|
|
|
|
Smallserial: SmallserialColumn,
|
|
|
|
|
Serial: SerialColumn,
|
|
|
|
|
Bigserial: BigserialColumn,
|
|
|
|
|
VarCharPtr: VarCharPtrColumn,
|
|
|
|
|
VarChar: VarCharColumn,
|
|
|
|
|
CharPtr: CharPtrColumn,
|
|
|
|
|
Char: CharColumn,
|
|
|
|
|
TextPtr: TextPtrColumn,
|
|
|
|
|
Text: TextColumn,
|
|
|
|
|
ByteaPtr: ByteaPtrColumn,
|
|
|
|
|
Bytea: ByteaColumn,
|
|
|
|
|
TimestampzPtr: TimestampzPtrColumn,
|
|
|
|
|
Timestampz: TimestampzColumn,
|
|
|
|
|
TimestampPtr: TimestampPtrColumn,
|
|
|
|
|
Timestamp: TimestampColumn,
|
|
|
|
|
DatePtr: DatePtrColumn,
|
|
|
|
|
Date: DateColumn,
|
|
|
|
|
TimezPtr: TimezPtrColumn,
|
|
|
|
|
Timez: TimezColumn,
|
|
|
|
|
TimePtr: TimePtrColumn,
|
|
|
|
|
Time: TimeColumn,
|
|
|
|
|
IntervalPtr: IntervalPtrColumn,
|
|
|
|
|
Interval: IntervalColumn,
|
|
|
|
|
BooleanPtr: BooleanPtrColumn,
|
|
|
|
|
Boolean: BooleanColumn,
|
|
|
|
|
PointPtr: PointPtrColumn,
|
|
|
|
|
BitPtr: BitPtrColumn,
|
|
|
|
|
Bit: BitColumn,
|
|
|
|
|
BitVaryingPtr: BitVaryingPtrColumn,
|
|
|
|
|
BitVarying: BitVaryingColumn,
|
|
|
|
|
TsvectorPtr: TsvectorPtrColumn,
|
|
|
|
|
Tsvector: TsvectorColumn,
|
|
|
|
|
UUIDPtr: UUIDPtrColumn,
|
|
|
|
|
UUID: UUIDColumn,
|
|
|
|
|
XMLPtr: XMLPtrColumn,
|
|
|
|
|
XML: XMLColumn,
|
|
|
|
|
JSONPtr: JSONPtrColumn,
|
|
|
|
|
JSON: JSONColumn,
|
|
|
|
|
JsonbPtr: JsonbPtrColumn,
|
|
|
|
|
Jsonb: JsonbColumn,
|
|
|
|
|
IntegerArrayPtr: IntegerArrayPtrColumn,
|
|
|
|
|
IntegerArray: IntegerArrayColumn,
|
|
|
|
|
TextArrayPtr: TextArrayPtrColumn,
|
|
|
|
|
TextArray: TextArrayColumn,
|
|
|
|
|
JsonbArray: JsonbArrayColumn,
|
|
|
|
|
TextMultiDimArrayPtr: TextMultiDimArrayPtrColumn,
|
|
|
|
|
TextMultiDimArray: TextMultiDimArrayColumn,
|
|
|
|
|
|
2020-04-12 18:53:57 +02:00
|
|
|
AllColumns: allColumns,
|
|
|
|
|
MutableColumns: mutableColumns,
|
2020-02-09 18:37:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|