From abf9c937be1e8af55e9ee2ec92801e813dc3d3d1 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sat, 29 Oct 2016 10:20:10 +0100 Subject: [PATCH] Ensure @thing:id is int64 if whole number --- sql/ast.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/ast.go b/sql/ast.go index 556ca62f..24c20aa3 100644 --- a/sql/ast.go +++ b/sql/ast.go @@ -455,9 +455,10 @@ func (this Thing) MarshalText() (data []byte, err error) { func NewThing(TB string, ID interface{}) *Thing { if str, ok := ID.(string); ok { - if cnv, err := strconv.ParseInt(str, 10, 64); err == nil { - return &Thing{TB: TB, ID: cnv} - } else if cnv, err := strconv.ParseFloat(str, 64); err == nil { + if cnv, err := strconv.ParseFloat(str, 64); err == nil { + if cnv == float64(int64(cnv)) { + return &Thing{TB: TB, ID: int64(cnv)} + } return &Thing{TB: TB, ID: cnv} } else if cnv, err := time.Parse(RFCDate, str); err == nil { return &Thing{TB: TB, ID: cnv.UTC()}