forked from mirror/gorm
simplified regexp (#5677)
This commit is contained in:
parent
f78f635fae
commit
b3eb1c8c51
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
regFullDataType = regexp.MustCompile(`[^\d]*(\d+)[^\d]?`)
|
||||
regFullDataType = regexp.MustCompile(`\D*(\d+)\D?`)
|
||||
)
|
||||
|
||||
// Migrator m struct
|
||||
|
|
|
@ -650,7 +650,7 @@ func (stmt *Statement) Changed(fields ...string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
var nameMatcher = regexp.MustCompile(`^(?:[\W]?([A-Za-z_0-9]+?)[\W]?\.)?[\W]?([A-Za-z_0-9]+?)[\W]?$`)
|
||||
var nameMatcher = regexp.MustCompile(`^(?:\W?(\w+?)\W?\.)?\W?(\w+?)\W?$`)
|
||||
|
||||
// SelectAndOmitColumns get select and omit columns, select -> true, omit -> false
|
||||
func (stmt *Statement) SelectAndOmitColumns(requireCreate, requireUpdate bool) (map[string]bool, bool) {
|
||||
|
|
|
@ -62,7 +62,7 @@ func TestUpsert(t *testing.T) {
|
|||
}
|
||||
|
||||
r := DB.Session(&gorm.Session{DryRun: true}).Clauses(clause.OnConflict{UpdateAll: true}).Create(&RestrictedLanguage{Code: "upsert_code", Name: "upsert_name", Lang: "upsert_lang"})
|
||||
if !regexp.MustCompile(`INTO .restricted_languages. .*\(.code.,.name.,.lang.\) .* (SET|UPDATE) .name.=.*.name.[^\w]*$`).MatchString(r.Statement.SQL.String()) {
|
||||
if !regexp.MustCompile(`INTO .restricted_languages. .*\(.code.,.name.,.lang.\) .* (SET|UPDATE) .name.=.*.name.\W*$`).MatchString(r.Statement.SQL.String()) {
|
||||
t.Errorf("Table with escape character, got %v", r.Statement.SQL.String())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue