Skip to content

Typescript errors for inserting with Kysely #1608

@FraBle

Description

@FraBle

Describe the bug

db.insertInto('my_table').values(<some values>) throws errors in Typescript since it expects the presence of fields and methods from XataRecord.

To Reproduce

  • Create a simple schema
  • Use xata pull to codegen the xata.ts file
    Example code snippet from generated file:
    export type MyTable = InferredTypes["my_table"];
    export type MyTableRecord = MyTable & XataRecord;
    
    export type DatabaseSchema = {
      my_table: MyTableRecord;
    };
    
  • Build an insertInto statement with Kysely
    db.insertInto('my_table').values({...myValues})
    
  • Will throw TypeScript errors for type ... is missing the following properties from type ... id, xata, getMetadata, toSerializable, and 4 more
    • Those missing properties come from XataRecord

Expected behavior

  • Accept object without XataRecord properties to insert into a table

Software version

    "dependencies": {
        "@xata.io/client": "^0.30.1",
        "@xata.io/kysely": "^0.2.1",
        "kysely": "^0.27.4",
        "zod": "^3.23.8",
        "zod-validation-error": "^3.4.0"
    },

Additional context

The docs only show an example for selecting a table entry. An insertInto example would be a great addition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions