Migrate: Client cannot handle "double precision" in Postgresql

Created on 2 Mar 2020  路  5Comments  路  Source: prisma/migrate

When I have the following model:

type Record {
  id: ID!
  lat: Float!
  lng: Float!
  name: String!
  address: String!
  type: DataType!
}

createRecord: (_parent: any, args: any, ctx: Context) => {
      return ctx.prisma.mainData.create({
        data: {
          lat: args.lat,
          lng: args.lat,
          name: args.name,
          address: args.address,
          type: {
            connect: {
              id: args.type
            }
          }
        }
      });
    },

It creates numeric(65,30) columns for lat and lng upon prisma2 migrate up. Using double presicion type is better in my case, but if I do so, the graphql mutation:

mutation {
  createRecord(name: "test", address: "test",lat: 1.00059, lng: 1.00052,  type: 1){
    id
  }
}

will cause the following error.

"Error occurred during query execution:",
"ConnectorError(
  ConnectorError {
    user_facing_error: None,
    kind: QueryError(
      Error 
      {
        kind: Db,
        cause: Some(
          DbError {
            severity: \"ERROR\", 
            parsed_severity: Some(Error),
            code: SqlState(\"22P03\"), 
            message: \"incorrect binary data format in bind parameter 2\", 
            detail: None,
            hint: None,
            position: None,
            where_: None,
            schema: None,
            table: None,
            column: None,
            datatype: None,
            constraint: None,
            file: Some(
              \"d:\\\\pginstaller_12.auto\\\\postgres.windows-x64\\\\src\\\\backend\\\\tcop\\\\postgres.c\"), 
              line: Some(1828),
              routine: Some(\"exec_bind_message\") 
            })
      })
})"

When I change the column type of lat and lng to numeric(65,30) or numeric with no specification on Postgrsql it works.
Isn't double precision supported?

bu2-confirmed kinbug

Most helpful comment

Follow-up to my previous comment: the changes were merged, and as of [email protected] single and double precision floats work on postgres. The fix will be in the next preview release :)

All 5 comments

I'm currently surveying and improving our types mapping story on postgres, I'll try to come back with an answer very soon :)

Follow-up to my previous comment: the changes were merged, and as of [email protected] single and double precision floats work on postgres. The fix will be in the next preview release :)

@seed-of-apricot Can you maybe test your reproduction again with that version? Would be awesome if you could confirm the fix.

@janpio I have confirmed it works, thank you for the fix.
But is it possible to make the default in migration as double precision (or float) instead of numeric (65,30)?
Every time I create a new table I need to change columns from numeric to double precision manually...

Thanks for confirming the fix.

Best create a new issue about the change you want, and we can look into it.

Was this page helpful?
0 / 5 - 0 ratings