Correct bits here and there from last commits

This commit is contained in:
Aaron L 2016-09-19 18:59:46 -07:00
parent 4a9e7a1b1a
commit 3474602ab5
6 changed files with 15 additions and 31 deletions

View file

@ -1066,10 +1066,7 @@ Please note that multi-dimensional Postgres ARRAY types are not supported at thi
#### Why aren't my time.Time or null.Time fields working in MySQL?
For MySQL if using the `github.com/go-sql-driver/mysql` driver, please activate
[time.Time parsing](https://github.com/go-sql-driver/mysql#timetime-support) when making your
MySQL database connection. SQLBoiler uses `time.Time` and `null.Time` to represent time in
it's models and without this enabled any models with `DATE`/`DATETIME` columns will not work.
You *must* use a DSN flag in MySQL connections, see: [Requirements](#requirements)
#### Where is the homepage?

View file

@ -3,8 +3,8 @@
{{- $dot := . -}}
{{- range .Table.ToOneRelationships -}}
{{- $txt := txtsFromOneToOne $dot.Tables $dot.Table . -}}
{{- $foreignNameSingular := $txt.ForeignTable.Name | singular | camelCase -}}
{{- $localNameSingular := $txt.LocalTable.Name | singular | camelCase -}}
{{- $varNameSingular := .Table | singular | camelCase -}}
{{- $foreignVarNameSingular := .ForeignTable | singular | camelCase -}}
func test{{$txt.LocalTable.NameGo}}OneToOne{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) {
tx := MustTx(boil.Begin())
defer tx.Rollback()
@ -13,10 +13,10 @@ func test{{$txt.LocalTable.NameGo}}OneToOne{{$txt.ForeignTable.NameGo}}_{{$txt.F
var local {{$txt.LocalTable.NameGo}}
seed := randomize.NewSeed()
if err := randomize.Struct(seed, &foreign, {{$foreignNameSingular}}DBTypes, true, {{$foreignNameSingular}}ColumnsWithDefault...); err != nil {
if err := randomize.Struct(seed, &foreign, {{$foreignVarNameSingular}}DBTypes, true, {{$foreignVarNameSingular}}ColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize {{$txt.ForeignTable.NameGo}} struct: %s", err)
}
if err := randomize.Struct(seed, &local, {{$localNameSingular}}DBTypes, true, {{$localNameSingular}}ColumnsWithDefault...); err != nil {
if err := randomize.Struct(seed, &local, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize {{$txt.LocalTable.NameGo}} struct: %s", err)
}

View file

@ -4,7 +4,7 @@
{{- $table := .Table }}
{{- range .Table.ToManyRelationships -}}
{{- $txt := txtsFromToMany $dot.Tables $table .}}
{{- $localNameSingular := $txt.LocalTable.Name | singular | camelCase -}}
{{- $varNameSingular := .Table | singular | camelCase -}}
func test{{$txt.LocalTable.NameGo}}ToMany{{$txt.Function.Name}}(t *testing.T) {
var err error
tx := MustTx(boil.Begin())
@ -14,7 +14,7 @@ func test{{$txt.LocalTable.NameGo}}ToMany{{$txt.Function.Name}}(t *testing.T) {
var b, c {{$txt.ForeignTable.NameGo}}
seed := randomize.NewSeed()
if err = randomize.Struct(seed, &a, {{$localNameSingular}}DBTypes, true, {{$localNameSingular}}ColumnsWithDefault...); err != nil {
if err = randomize.Struct(seed, &a, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize {{$txt.LocalTable.NameGo}} struct: %s", err)
}

View file

@ -3,8 +3,8 @@
{{- $dot := . -}}
{{- range .Table.FKeys -}}
{{- $txt := txtsFromFKey $dot.Tables $dot.Table . -}}
{{- $foreignNameSingular := $txt.ForeignTable.Name | singular | camelCase -}}
{{- $localNameSingular := $txt.LocalTable.Name | singular | camelCase -}}
{{- $varNameSingular := .Table | singular | camelCase -}}
{{- $foreignVarNameSingular := .ForeignTable | singular | camelCase -}}
func test{{$txt.LocalTable.NameGo}}ToOne{{$txt.ForeignTable.NameGo}}_{{$txt.Function.Name}}(t *testing.T) {
tx := MustTx(boil.Begin())
defer tx.Rollback()
@ -13,12 +13,12 @@ func test{{$txt.LocalTable.NameGo}}ToOne{{$txt.ForeignTable.NameGo}}_{{$txt.Func
var foreign {{$txt.ForeignTable.NameGo}}
seed := randomize.NewSeed()
if err := randomize.Struct(seed, &foreign, {{$foreignNameSingular}}DBTypes, true, {{$foreignNameSingular}}ColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize {{$txt.ForeignTable.NameGo}} struct: %s", err)
}
if err := randomize.Struct(seed, &local, {{$localNameSingular}}DBTypes, true, {{$localNameSingular}}ColumnsWithDefault...); err != nil {
if err := randomize.Struct(seed, &local, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize {{$txt.LocalTable.NameGo}} struct: %s", err)
}
if err := randomize.Struct(seed, &foreign, {{$foreignVarNameSingular}}DBTypes, true, {{$foreignVarNameSingular}}ColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize {{$txt.ForeignTable.NameGo}} struct: %s", err)
}
{{if .Nullable -}}
local.{{$txt.LocalTable.ColumnNameGo}}.Valid = true

View file

@ -14,7 +14,6 @@ type TxtToOne struct {
ForeignKey bdb.ForeignKey
LocalTable struct {
Name string
NameGo string
ColumnNameGo string
}
@ -45,7 +44,6 @@ func txtsFromFKey(tables []bdb.Table, table bdb.Table, fkey bdb.ForeignKey) TxtT
r.ForeignKey = fkey
r.LocalTable.Name = table.Name
r.LocalTable.NameGo = strmangle.TitleCase(strmangle.Singular(table.Name))
r.LocalTable.ColumnNameGo = strmangle.TitleCase(strmangle.Singular(fkey.Column))
@ -117,14 +115,12 @@ func txtsFromOneToOne(tables []bdb.Table, table bdb.Table, oneToOne bdb.ToOneRel
// TxtToMany contains text that will be used by many-to-one relationships.
type TxtToMany struct {
LocalTable struct {
Name string
NameGo string
NameSingular string
ColumnNameGo string
}
ForeignTable struct {
Name string
NameGo string
NameSingular string
NamePluralGo string
@ -149,12 +145,10 @@ type TxtToMany struct {
// transformation in advance for a given relationship.
func txtsFromToMany(tables []bdb.Table, table bdb.Table, rel bdb.ToManyRelationship) TxtToMany {
r := TxtToMany{}
r.LocalTable.Name = table.Name
r.LocalTable.NameSingular = strmangle.Singular(table.Name)
r.LocalTable.NameGo = strmangle.TitleCase(r.LocalTable.NameSingular)
r.LocalTable.ColumnNameGo = strmangle.TitleCase(rel.Column)
r.ForeignTable.Name = rel.ForeignTable
r.ForeignTable.NameSingular = strmangle.Singular(rel.ForeignTable)
r.ForeignTable.NamePluralGo = strmangle.TitleCase(strmangle.Plural(rel.ForeignTable))
r.ForeignTable.NameGo = strmangle.TitleCase(r.ForeignTable.NameSingular)

View file

@ -23,7 +23,6 @@ func TestTxtsFromOne(t *testing.T) {
expect.ForeignKey = jets.FKeys[0]
expect.LocalTable.Name = "jets"
expect.LocalTable.NameGo = "Jet"
expect.LocalTable.ColumnNameGo = "PilotID"
@ -49,7 +48,6 @@ func TestTxtsFromOne(t *testing.T) {
expect = TxtToOne{}
expect.ForeignKey = jets.FKeys[1]
expect.LocalTable.Name = "jets"
expect.LocalTable.NameGo = "Jet"
expect.LocalTable.ColumnNameGo = "AirportID"
@ -102,7 +100,6 @@ func TestTxtsFromOneToOne(t *testing.T) {
ForeignColumnUnique: false,
}
expect.LocalTable.Name = "pilots"
expect.LocalTable.NameGo = "Pilot"
expect.LocalTable.ColumnNameGo = "ID"
@ -136,12 +133,10 @@ func TestTxtsFromMany(t *testing.T) {
pilots := bdb.GetTable(tables, "pilots")
texts := txtsFromToMany(tables, pilots, pilots.ToManyRelationships[0])
expect := TxtToMany{}
expect.LocalTable.Name = "pilots"
expect.LocalTable.NameGo = "Pilot"
expect.LocalTable.NameSingular = "pilot"
expect.LocalTable.ColumnNameGo = "ID"
expect.ForeignTable.Name = "licenses"
expect.ForeignTable.NameGo = "License"
expect.ForeignTable.NameSingular = "license"
expect.ForeignTable.NamePluralGo = "Licenses"
@ -161,12 +156,10 @@ func TestTxtsFromMany(t *testing.T) {
texts = txtsFromToMany(tables, pilots, pilots.ToManyRelationships[1])
expect = TxtToMany{}
expect.LocalTable.Name = "pilots"
expect.LocalTable.NameGo = "Pilot"
expect.LocalTable.NameSingular = "pilot"
expect.LocalTable.ColumnNameGo = "ID"
expect.ForeignTable.Name = "languages"
expect.ForeignTable.NameGo = "Language"
expect.ForeignTable.NameSingular = "language"
expect.ForeignTable.NamePluralGo = "Languages"