mirror of https://github.com/go-gorm/gorm.git
* Fixed #5355. * Fixed unit test to test both CRLF and CR line endings
This commit is contained in:
parent
7496c3a56e
commit
540fb49bcb
|
@ -127,7 +127,7 @@ func (expr NamedExpr) Build(builder Builder) {
|
|||
if v == '@' && !inName {
|
||||
inName = true
|
||||
name = []byte{}
|
||||
} else if v == ' ' || v == ',' || v == ')' || v == '"' || v == '\'' || v == '`' || v == '\n' || v == ';' {
|
||||
} else if v == ' ' || v == ',' || v == ')' || v == '"' || v == '\'' || v == '`' || v == '\r' || v == '\n' || v == ';' {
|
||||
if inName {
|
||||
if nv, ok := namedMap[string(name)]; ok {
|
||||
builder.AddVar(builder, nv)
|
||||
|
|
|
@ -94,6 +94,16 @@ func TestNamedExpr(t *testing.T) {
|
|||
Vars: []interface{}{sql.Named("name", "jinzhu")},
|
||||
Result: "name1 = ? AND name2 = ?;",
|
||||
ExpectedVars: []interface{}{"jinzhu", "jinzhu"},
|
||||
}, {
|
||||
SQL: "name1 = @name1\r\n AND name2 = @name2",
|
||||
Vars: []interface{}{map[string]interface{}{"name1": "jinzhu", "name2": "jinzhu"}},
|
||||
Result: "name1 = ?\r\n AND name2 = ?",
|
||||
ExpectedVars: []interface{}{"jinzhu", "jinzhu"},
|
||||
}, {
|
||||
SQL: "name1 = @name1\r AND name2 = @name2",
|
||||
Vars: []interface{}{map[string]interface{}{"name1": "jinzhu", "name2": "jinzhu"}},
|
||||
Result: "name1 = ?\r AND name2 = ?",
|
||||
ExpectedVars: []interface{}{"jinzhu", "jinzhu"},
|
||||
}, {
|
||||
SQL: "?",
|
||||
Vars: []interface{}{clause.Column{Table: "table", Name: "col"}},
|
||||
|
|
Loading…
Reference in New Issue