Giter Club home page Giter Club logo

Comments (3)

koskimas avatar koskimas commented on May 26, 2024

You can modify the proposed solution to make the casts. We can't add automatic casts since they are database-dependent. We don't know what the column's data type is when you pass in a javascript number for example.

We can't do this automatically. We don't have the information, and never will have, since Kysely is not an ORM.

from kysely.

emishur avatar emishur commented on May 26, 2024

@koskimas Unfortunately, casting did not work for me (maybe I was doing it wrong).

The problem that Kysely generates PREPARE statement elsewhere without parameter types and Postgres defaults all parameters to 'text'.

Instead of doing it automatically, it is possible to let the user to specify values schema:

  db
    .updateTable("foo")
    .fromValues<{col1: "int", col2: "text"}>([
      {col1: 1, col2: "bar"},
      {col1: 2, col2: "buz"}], "v")
    .whereRef("foo.col1", "=", "v.col1")
    .set(eb => ({
      col1: eb.ref("v.col1"),
      col2: eb.ref("v.col2")
    })
    .execute();

and use provided schema when generating PREPARE statement.

IMHO, Postgres allows to construct such queries and it would be nice if Kysely would provide a standard way to do it as well without converting it to ORM.

from kysely.

koskimas avatar koskimas commented on May 26, 2024

Typescript types don't exist in runtime, so no, that's not possible.

from kysely.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.