Skip to content

Commit

Permalink
fix: replace hashing select field qulify table name
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowa2017 committed Oct 29, 2024
1 parent e436477 commit aff971a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,11 @@ func replaceSelectFieldTableName(oldTableName, tableName string, columns *sqlpar
rcs := []*sqlparser.ResultColumn(*columns)
for i := 0; i < len(rcs); i++ {
rc := rcs[i]
if n, ok := rc.Expr.(*sqlparser.BinaryExpr); ok {
if q, ok2 := n.X.(*sqlparser.QualifiedRef); ok2 {
if q.Table.Name == oldTableName {
n.X.(*sqlparser.QualifiedRef).Table.Name = tableName
}
if n, ok := rc.Expr.(*sqlparser.QualifiedRef); ok {
if n.Table.Name == oldTableName {
n.Table.Name = tableName
}
}

}
r := sqlparser.OutputNames(rcs)
return &r
Expand Down Expand Up @@ -484,6 +481,7 @@ func (s *Sharding) resolve(query string, args ...any) (ftQuery, stQuery, tableNa
replaceConditionTableName(tableName, newTable.Name.Name, stmt.Condition)
stQuery = stmt.String()
}
slog.Debug(stQuery)
}

return
Expand Down

0 comments on commit aff971a

Please sign in to comment.