Skip to content

Commit

Permalink
Merge pull request #281 from uptrace/fix/init-table-once
Browse files Browse the repository at this point in the history
Fix/init table once
  • Loading branch information
vmihailenco authored Oct 29, 2021
2 parents 71af086 + 9a1ce1e commit 074e00b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion schema/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func (t *Table) tryRelation(field *Field) bool {

if field.Tag.HasOption("join") {
internal.Warn.Printf(
`%s.%s option "join" requires a relation type`,
`%s.%s "join" option must come together with "rel" option`,
t.TypeName, field.GoName,
)
}
Expand Down
12 changes: 7 additions & 5 deletions schema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ func (t *Tables) table(typ reflect.Type, allowInProgress bool) *Table {
return table
}

if inProgress.init2() {
t.mu.Lock()
delete(t.inProgress, typ)
t.tables.Store(typ, table)
t.mu.Unlock()
if !inProgress.init2() {
return table
}

t.mu.Lock()
delete(t.inProgress, typ)
t.tables.Store(typ, table)
t.mu.Unlock()

t.dialect.OnTable(table)

for _, field := range table.FieldMap {
Expand Down

0 comments on commit 074e00b

Please sign in to comment.