kysely-org / kysely

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

Breaking change with addColumn between 0.27.2 and 0.27.3 #908

Closed ankane closed 5 months ago

ankane commented 5 months ago

Hi, thanks for this project.

Before 0.27.3, addColumn worked with custom data types in Postgres.

await db.schema.createTable('items').addColumn('embedding', 'vector(3)').execute();

However, this now throws:

invalid column data type "vector(3)"

It looks like it's due to 3df726fd566664a1842d0fe8cfc0d79983647e39.

igalklebanov commented 5 months ago

Hey 👋

Just like before, you have to use sql template tag if a data type is not available in the list.

import { sql } from "kysely";

await db.schema
  .createTable("items")
  .addColumn("embedding", sql`vector(3)`)
  .execute();

https://kyse.link/nwcuY

ankane commented 5 months ago

Thanks for the response. This was not the case before 0.27.3, but good to know.

igalklebanov commented 5 months ago

The API was designed to tell you NOT to do it the way you pasted.

image https://kyse.link/3e74S

koskimas commented 5 months ago

As @igalklebanov said, previously, if you ignored the type error and built the code anyway, it worked. Now there's also a runtime check. We don't consider that a breaking change as you shouldn't ignore typescript errors.