Skip to content

postgres: Foreign Keys with same name cause compilation errors #85

Closed
@eduacostam

Description

@eduacostam

After executing the sql script defined in https://github.com/vattle/sqlboiler#features--examples into an empty database, and executing sqlboiler postgres, running go test ./models/ fails with the following message:

models\jets.go:345: (*Jet).PilotG redeclared in this block
        previous declaration at models\jets.go:326
models\jets.go:350: (*Jet).Pilot redeclared in this block
        previous declaration at models\jets.go:331
models\jets.go:364: (*Jet).PilotG redeclared in this block
        previous declaration at models\jets.go:345
models\jets.go:369: (*Jet).Pilot redeclared in this block
        previous declaration at models\jets.go:350
models\jets.go:383: (*Jet).PilotG redeclared in this block
        previous declaration at models\jets.go:364
models\jets.go:388: (*Jet).Pilot redeclared in this block
        previous declaration at models\jets.go:369
models\jets.go:477: jetL.LoadPilot redeclared in this block
        previous declaration at models\jets.go:403
models\jets.go:551: jetL.LoadPilot redeclared in this block
        previous declaration at models\jets.go:477
models\jets.go:625: jetL.LoadPilot redeclared in this block
        previous declaration at models\jets.go:551
models\jets.go:748: (*Jet).SetPilot redeclared in this block
        previous declaration at models\jets.go:700
models\jets.go:748: too many errors
FAIL   /test/models [build failed]

I can also see, in almost all structs, that there is lots of duplicated entries. For example, the jetR struct is defined as followed, which is clearly wrong.

// jetR is where relationships are stored.
type jetR struct {
	Pilot *Pilot
	Pilot *Pilot
	Pilot *Pilot
	Pilot *Pilot
}

Another clear example is the pilotR struct, which not only has duplicated attributes, but it also misses the Jets JetSlice attribute.

// pilotR is where relationships are stored.
type pilotR struct {
	Jets      JetSlice
	Jets      JetSlice
	Jets      JetSlice
	Jets      JetSlice
	Languages LanguageSlice
	Languages LanguageSlice
	Languages LanguageSlice
	Languages LanguageSlice
}

My Go version: go version go1.7.4 windows/amd64 running postgres 9.5 on an Ubuntu VM.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions