Ensure @thing:id is int64 if whole number
This commit is contained in:
parent
67c32e5eea
commit
abf9c937be
1 changed files with 4 additions and 3 deletions
|
@ -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()}
|
||||
|
|
Loading…
Reference in a new issue