xormplus 10 anni fa
parent
commit
951e22a4ef
2 ha cambiato i file con 14 aggiunte e 1 eliminazioni
  1. 1 1
      helpers.go
  2. 13 0
      test/xorm_test.go

+ 1 - 1
helpers.go

@@ -134,7 +134,7 @@ func reflect2value(rawValue *reflect.Value) (str string, err error) {
 	//时间类型
 	case reflect.Struct:
 		if aa.ConvertibleTo(core.TimeType) {
-			str = rawValue.Convert(core.TimeType).Interface().(time.Time).Format(time.RFC3339Nano)
+			str = vv.Convert(core.TimeType).Interface().(time.Time).Format(time.RFC3339Nano)
 		} else {
 			err = fmt.Errorf("Unsupported struct type %v", vv.Type().Name())
 		}

+ 13 - 0
test/xorm_test.go

@@ -54,6 +54,19 @@ func Test_InitDB(t *testing.T) {
 	}
 }
 
+func Test_Get_Struct(t *testing.T) {
+	var article Article
+	has, err := db.Id(3).Get(&article)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if !has {
+		t.Log("[Test_Get_Struct]->rows: not exist\n")
+	}
+
+	t.Log("[Test_Get_Struct]->rows:\n" , article)
+}
+
 func Test_GetFirst_Json(t *testing.T) {
 	var article Article
 	has, rows, err := db.Id(2).GetFirst(&article).Json()