From feb013c97620111a2e575ee50ae465fa97dad8d3 Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 8 Feb 2018 23:58:03 +0800 Subject: [PATCH] DataTypeOf should now correctly identify dataValues that are 'json.RawMessage' types as 'jsonb' columns --- dialect_postgres.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dialect_postgres.go b/dialect_postgres.go index 6fdf4df1..058e6e27 100644 --- a/dialect_postgres.go +++ b/dialect_postgres.go @@ -5,6 +5,7 @@ import ( "reflect" "strings" "time" + "encoding/json" ) type postgres struct { @@ -67,9 +68,12 @@ func (s *postgres) DataTypeOf(field *StructField) string { } default: if IsByteArrayOrSlice(dataValue) { - sqlType = "bytea" if isUUID(dataValue) { sqlType = "uuid" + } else if _, ok := dataValue.Interface().(json.RawMessage); ok { + sqlType = "jsonb" + } else { + sqlType = "bytea" } } }