fix: join on instanceIDs in queries (#4612)

This commit is contained in:
Livio Spring
2022-10-27 08:08:36 +02:00
committed by GitHub
parent d721f725fd
commit 441f215513
61 changed files with 555 additions and 1243 deletions

View File

@@ -365,8 +365,9 @@ var (
)
type table struct {
name string
alias string
name string
alias string
instanceIDCol string
}
func (t table) setAlias(a string) table {
@@ -385,6 +386,13 @@ func (t table) isZero() bool {
return t.name == ""
}
func (t table) InstanceIDIdentifier() string {
if t.alias != "" {
return t.alias + "." + t.instanceIDCol
}
return t.name + "." + t.instanceIDCol
}
type Column struct {
name string
table table
@@ -418,7 +426,7 @@ func (c Column) isZero() bool {
}
func join(join, from Column) string {
return join.table.identifier() + " ON " + from.identifier() + " = " + join.identifier()
return join.table.identifier() + " ON " + from.identifier() + " = " + join.identifier() + " AND " + from.table.InstanceIDIdentifier() + " = " + join.table.InstanceIDIdentifier()
}
type listContains struct {