diff --git a/args.go b/args.go index 276b61d..8a0ee73 100644 --- a/args.go +++ b/args.go @@ -41,13 +41,9 @@ func (d *DB) handleArgs(prototype interface{}, args []interface{}) (ret *_parsed case Options: ret.Opt = mergeOptions(prototype, arg.(Options)) case Limit: - ret.Limit = arg.(Limit).Limit - case *Limit: - ret.Limit = arg.(*Limit).Limit + ret.Limit = int(arg.(Limit)) case Offset: - ret.Offset = arg.(Offset).Offset - case *Offset: - ret.Offset = arg.(*Offset).Offset + ret.Offset = int(arg.(Offset)) case Cond: cond := arg.(Cond) c = cond.pack(ret.FieldMap) diff --git a/basic_curd_test.go b/basic_curd_test.go index 3e6d33c..8b7293d 100644 --- a/basic_curd_test.go +++ b/basic_curd_test.go @@ -188,7 +188,7 @@ func TestQuery(t *testing.T) { Condition("family_name", "<>", "Disney"), Condition("die_time", "=", nil), // for MySQL NULL, should be "IS" or "IS NOT", but here er make some compatibility Condition("birth_date", ">=", time.Date(1910, 1, 1, 0, 0, 0, 0, time.UTC)), - Offset{1}, Limit{2}, + Offset(1), Limit(2), Order{"id", "DESC"}, ) if err != nil { @@ -231,7 +231,7 @@ func TestQuery(t *testing.T) { }, Condition("first_name", "=", "Diane"), Condition("family_name", "=", "Miller"), - Limit{1}, + Limit(1), ) if err != nil { t.Errorf("Update failed: %v", err) diff --git a/insert_on_duplicate_update_test.go b/insert_on_duplicate_update_test.go index 44f9ebc..50a4767 100644 --- a/insert_on_duplicate_update_test.go +++ b/insert_on_duplicate_update_test.go @@ -141,7 +141,7 @@ func TestInsertManyOnDuplicateKeyUpdate(t *testing.T) { _, err = db.InsertManyOnDuplicateKeyUpdate( ins, map[string]interface{}{ - "f_id": Raw("= f_id"), + "f_id": Raw("= VALUES(`f_id`)"), }, ) if err != nil { diff --git a/raw.go b/raw.go deleted file mode 100644 index 303f3a7..0000000 --- a/raw.go +++ /dev/null @@ -1,9 +0,0 @@ -package mysqlx - -// Raw stores a raw MySQL query statement. In mysqlx operation, Raw type will added to sql query statement directly -// without any escaping. -// -// Currently only update fields supports Raw, like: -// -// map[string]interface{}{"id": mysqlx.Raw("= id")} -type Raw string diff --git a/transaction.go b/transaction.go new file mode 100644 index 0000000..153f9b1 --- /dev/null +++ b/transaction.go @@ -0,0 +1 @@ +package mysqlx diff --git a/type.go b/type.go index b8894d5..226662b 100644 --- a/type.go +++ b/type.go @@ -114,11 +114,15 @@ type Options struct { } // Offset is for MySQL offset statement -type Offset struct { - Offset int -} +type Offset int // Limit is for MySQL limit statement -type Limit struct { - Limit int -} +type Limit int + +// Raw stores a raw MySQL query statement. In mysqlx operation, Raw type will added to sql query statement directly +// without any escaping. +// +// Currently only update fields supports Raw, like: +// +// map[string]interface{}{"id": mysqlx.Raw("= id")} +type Raw string