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: support implicit table alias #5940

Closed
wants to merge 1 commit into from

Conversation

yaofeng-wang
Copy link

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Resolves #5840.

User Case Description

@@ -55,7 +55,7 @@ func (db *DB) Clauses(conds ...clause.Expression) (tx *DB) {
return
}

var tableRegexp = regexp.MustCompile(`(?i).+? AS (\w+)\s*(?:$|,)`)
var tableRegexp = regexp.MustCompile(`(?i).+?(?: AS )?(\w+)\s*(?:$|,)`)
Copy link
Member

Choose a reason for hiding this comment

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

the regexp is too general, will break in some cases, for example:

db.Table("select * from users where name = 1") 

@jinzhu jinzhu closed this Jan 1, 2023
jinzhu added a commit that referenced this pull request Jan 2, 2023
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.

Use of a table alias does not work with soft delete
2 participants