node.jstypescripttypeboxsinclair

Number() not converting floating points from db correct


I am using sinclair/typebox for TypeScript project, here is my schema:

export const ItemValue = Type.Object({
  itemBalance: Type.Number()
}) 

export type ItemValueType = Static<typeof ItemValue>;

how I am reading this data from oracle db:

const result = await connection.execut<ItemValueType>(query, {
{
  outFormat: OUT_FORMAT_OBJECT
}
})

The issue is that there is a value in oracle 15.79 which is being returned as 15.790000000000001

any ideas how to fix this issue?


Solution

  • I ended up using TO_CHAR function in my query like so:

    SELECT TO_CHAR(my_column, 'FM99.99') as myColumn from myTable
    

    This resolved my issue.