Skip to content

Commit

Permalink
fix: recognize QualifiedRef of column condition (#167)
Browse files Browse the repository at this point in the history
About #94
  • Loading branch information
Gowa2017 authored Aug 1, 2024
1 parent 59c3209 commit 5a63663
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,14 @@ func (s *Sharding) insertValue(key string, names []*sqlparser.Ident, exprs []sql
func (s *Sharding) nonInsertValue(key string, condition sqlparser.Expr, args ...any) (value any, id int64, keyFind bool, err error) {
err = sqlparser.Walk(sqlparser.VisitFunc(func(node sqlparser.Node) error {
if n, ok := node.(*sqlparser.BinaryExpr); ok {
if x, ok := n.X.(*sqlparser.Ident); ok {
x, ok := n.X.(*sqlparser.Ident)
if !ok {
if q, ok2 := n.X.(*sqlparser.QualifiedRef); ok2 {
x = q.Column
ok = true
}
}
if ok {
if x.Name == key && n.Op == sqlparser.EQ {
keyFind = true
switch expr := n.Y.(type) {
Expand Down

0 comments on commit 5a63663

Please sign in to comment.