mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 00:05:15 +00:00
fix reflection
This commit is contained in:
parent
00b9c3156f
commit
82501ff57c
|
@ -1,6 +1,6 @@
|
||||||
-- +up
|
-- +up
|
||||||
-- +begin
|
-- +begin
|
||||||
ALTER TABLE `trades` ADD COLUMN `inserted_at` DATETIME(3) DEFAULT CURRENT_TIMESTAMP NOT NULL AFTER `traded_at`;
|
ALTER TABLE `trades` ADD COLUMN `inserted_at` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL AFTER `traded_at`;
|
||||||
-- +end
|
-- +end
|
||||||
|
|
||||||
-- +begin
|
-- +begin
|
||||||
|
|
|
@ -27,13 +27,16 @@ func tableNameOf(record interface{}) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func placeholdersOf(record interface{}) []string {
|
func placeholdersOf(record interface{}) []string {
|
||||||
vt := reflect.ValueOf(record)
|
|
||||||
rt := reflect.TypeOf(record)
|
rt := reflect.TypeOf(record)
|
||||||
|
|
||||||
if rt.Kind() == reflect.Ptr {
|
if rt.Kind() == reflect.Ptr {
|
||||||
rt = rt.Elem()
|
rt = rt.Elem()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vt := reflect.ValueOf(record)
|
||||||
|
if vt.Kind() == reflect.Ptr {
|
||||||
|
vt = vt.Elem()
|
||||||
|
}
|
||||||
|
|
||||||
if rt.Kind() != reflect.Struct {
|
if rt.Kind() != reflect.Struct {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -60,13 +63,16 @@ func placeholdersOf(record interface{}) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func fieldsNamesOf(record interface{}) []string {
|
func fieldsNamesOf(record interface{}) []string {
|
||||||
vt := reflect.ValueOf(record)
|
|
||||||
rt := reflect.TypeOf(record)
|
rt := reflect.TypeOf(record)
|
||||||
|
|
||||||
if rt.Kind() == reflect.Ptr {
|
if rt.Kind() == reflect.Ptr {
|
||||||
rt = rt.Elem()
|
rt = rt.Elem()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vt := reflect.ValueOf(record)
|
||||||
|
if vt.Kind() == reflect.Ptr {
|
||||||
|
vt = vt.Elem()
|
||||||
|
}
|
||||||
|
|
||||||
if rt.Kind() != reflect.Struct {
|
if rt.Kind() != reflect.Struct {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user