support implicit table alias, close #5840 #5940

This commit is contained in:
Jinzhu
2023-01-02 21:46:27 +08:00
parent 3d91802b1d
commit 2bc913787b
3 changed files with 13 additions and 5 deletions
+5
View File
@@ -39,6 +39,11 @@ func TestSoftDelete(t *testing.T) {
t.Fatalf("invalid sql generated, got %v", sql)
}
sql = DB.Session(&gorm.Session{DryRun: true}).Table("user u").Select("name").Find(&User{}).Statement.SQL.String()
if !regexp.MustCompile(`SELECT .name. FROM user u WHERE .u.\..deleted_at. IS NULL`).MatchString(sql) {
t.Errorf("Table with escape character, got %v", sql)
}
if DB.First(&User{}, "name = ?", user.Name).Error == nil {
t.Errorf("Can't find a soft deleted record")
}