Skip to content

Commit

Permalink
query cache fix
Browse files Browse the repository at this point in the history
  • Loading branch information
folospace committed Apr 20, 2024
1 parent 14cd79a commit 3796a6e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions orm/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,19 @@ func (q *Query[T]) parseTable(table Table) (*queryTable, error) {
rawSql: temp.raw,
bindings: temp.bindings,
}
return newTable, nil
} else if temp, ok := table.(*SubQuery); ok {
newTable = &queryTable{
table: table,
rawSql: temp.raw,
bindings: temp.bindings,
}
return newTable, nil
} else {
cached := getTableFromCache(table)
if cached != nil {
return cached, nil
tmp := *cached
return &tmp, nil
}
tableStructAddr := reflect.ValueOf(table)
if tableStructAddr.Kind() != reflect.Ptr {
Expand Down Expand Up @@ -185,8 +188,10 @@ func (q *Query[T]) parseTable(table Table) (*queryTable, error) {
ormFields: ormFields,
}
cacheTable(table, newTable)

tmp := *newTable
return &tmp, nil
}
return newTable, nil
}

func (q *Query[T]) isRaw(v any) (string, bool) {
Expand Down

0 comments on commit 3796a6e

Please sign in to comment.