Skip to content

Float precision loss #196

@MattNewberry

Description

@MattNewberry

When inserting a number with higher precision than 6 decimal places (for example, longitude of 35.03554004971999) the precision past the 6th place is lost. The field type is float64 and has a data type in Postgres as numeric.

Example:

package main

import (
        "database/sql"
        "fmt"
        _ "github.com/lib/pq"
)

func main() {
        db, _ := sql.Open("postgres", "user=gorm dbname=gorm sslmode=disable")
        sql := `INSERT INTO users (latitude) VALUES ($1) RETURNING "id"`
        res, err := db.Exec(sql, 35.03554004971999)
        fmt.Println(res, err)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions