kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.8k stars 275 forks source link

`real` and `numeric` are being cast to strings on select #802

Closed will-weiss closed 11 months ago

will-weiss commented 11 months ago

Hello! If I have a real column in Postgres like so

CREATE TABLE foo (
    bar real
);

INSERT INTO foo (bar) VALUES
   (1),
   (4.56),
   (7.89);
await db.selectFrom('foo').selectAll().execute()

I get back

[ { bar: "1" }, { bar: "4.56" }, { bar: "7.89" } ]

I would expect to get back Javascript numbers, like so

[ { bar: 1 }, { bar: 4.56 }, { bar: 7.89 } ]

Might someone know why these are being cast as strings?

I'm running on Deno. My db.ts file looks like so

import {
  Kysely,
  PostgresAdapter,
  PostgresIntrospector,
  PostgresQueryCompiler,
} from 'kysely'
import { DatabaseSchema } from '../types.ts'
import { PostgreSQLDriver } from 'kysely-deno-postgres'

const DATABASE_URL = Deno.env.get('DATABASE_URL')

const db = new Kysely<DatabaseSchema>({
  dialect: {
    createAdapter() {
      return new PostgresAdapter()
    },
    createDriver() {
      // deno-lint-ignore no-explicit-any
      return new PostgreSQLDriver(uri) as any
    },
    createIntrospector(db: Kysely<unknown>) {
      return new PostgresIntrospector(db)
    },
    createQueryCompiler() {
      return new PostgresQueryCompiler()
    },
  },
})

export default db

While in my imports_map.json those imports are pointing to

"kysely": "https://cdn.jsdelivr.net/npm/kysely/dist/esm/index.js",
"kysely/": "https://cdn.jsdelivr.net/npm/kysely/dist/esm/",
"kysely-deno-postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts",

Thanks in advance!

koskimas commented 11 months ago

Duplicate of a duplicate of a duplicate of a duplicate of a duplicate of a duplicate of a duplicate of a duplicate