Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix update predicate problem #7

Merged
merged 2 commits into from
Sep 18, 2020

Conversation

nicholasxuu
Copy link

@nicholasxuu nicholasxuu commented Sep 17, 2020

升级后发现update的where predicate有问题。

之前的解决方法把where...搞没了,不能那么弄。

发现之前predicate是给select query用的,可能怎么处理过了。再给update query用的时候,会被recursive的重复解析。想到的解决方法是,对这种select query出来的predicate,直接取值,不让他解析。

if u.where != nil {
u.WriteString(" WHERE ")
u.WriteString(u.where.String())
u.args = append(u.args, u.where.args...)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个func QueryWithSelectPredicate()就是复制了上面的func Query(),改了这两行

u.Join(u.where)

改为

u.WriteString(u.where.String())
u.args = append(u.args, u.where.args...)

u.Join()处理这个selector里弄出来的predicate,会把predicate的tree每个node都重复处理上去。
只给我们的update()修改一下就行了,不改原生的Query()就不会修改其他调用的结果了。

@HeathLee HeathLee merged commit 44c4485 into shanbay:master Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants