diff --git a/DONATOR.MD b/DONATOR.MD index ecaeef07e..e8158e624 100644 --- a/DONATOR.MD +++ b/DONATOR.MD @@ -16,6 +16,8 @@ |潘兄|wechat|¥100.00 |Fly的狐狸|wechat|¥100.00 |全|alipay|¥100.00 +|东东|wechat|¥100.00 +|严宇轩|alipay|¥99.99 |土豆相公|alipay|¥66.60 |Hades|alipay|¥66.66 |蔡蔡|wechat|¥666.00 diff --git a/database/gdb/gdb_unit_z_mysql_types_test.go b/database/gdb/gdb_unit_z_mysql_types_test.go index ff29a5627..18de8af1a 100644 --- a/database/gdb/gdb_unit_z_mysql_types_test.go +++ b/database/gdb/gdb_unit_z_mysql_types_test.go @@ -27,9 +27,11 @@ func Test_Types(t *testing.T) { %s decimal(5,2) NOT NULL, %s double NOT NULL, %s bit(2) NOT NULL, + %s tinyint(1) NOT NULL, + %s bool NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - `, "`blob`", "`binary`", "`date`", "`decimal`", "`double`", "`bit`")); err != nil { + `, "`blob`", "`binary`", "`date`", "`decimal`", "`double`", "`bit`", "`tinyint`", "`bool`")); err != nil { gtest.Error(err) } defer dropTable("types") @@ -41,6 +43,8 @@ func Test_Types(t *testing.T) { "decimal": 123.456, "double": 123.456, "bit": 2, + "tinyint": true, + "bool": false, } r, err := db.Table("types").Data(data).Insert() gtest.Assert(err, nil) @@ -56,5 +60,7 @@ func Test_Types(t *testing.T) { gtest.Assert(one["decimal"].String(), 123.46) gtest.Assert(one["double"].String(), data["double"]) gtest.Assert(one["bit"].Int(), data["bit"]) + gtest.Assert(one["tinyint"].Bool(), data["tinyint"]) + gtest.Assert(one["tinyint"].Bool(), data["tinyint"]) }) } diff --git a/database/gredis/gredis_unit_test.go b/database/gredis/gredis_unit_test.go index 9d8cd32d4..edfcad857 100644 --- a/database/gredis/gredis_unit_test.go +++ b/database/gredis/gredis_unit_test.go @@ -208,3 +208,22 @@ func Test_Basic(t *testing.T) { time.Sleep(time.Second) }) } + +func Test_Bool(t *testing.T) { + gtest.Case(t, func() { + redis := gredis.New(config) + _, err := redis.Do("SET", "key-true", true) + gtest.Assert(err, nil) + + _, err = redis.Do("SET", "key-false", false) + gtest.Assert(err, nil) + + r, err := redis.DoVar("GET", "key-true") + gtest.Assert(err, nil) + gtest.Assert(r.Bool(), true) + + r, err = redis.DoVar("GET", "key-false") + gtest.Assert(err, nil) + gtest.Assert(r.Bool(), false) + }) +} diff --git a/util/gconv/gconv.go b/util/gconv/gconv.go index 8baf3b42a..822c76499 100644 --- a/util/gconv/gconv.go +++ b/util/gconv/gconv.go @@ -213,6 +213,11 @@ func Bool(i interface{}) bool { switch value := i.(type) { case bool: return value + case []byte: + if _, ok := emptyStringMap[string(value)]; ok { + return false + } + return true case string: if _, ok := emptyStringMap[value]; ok { return false