Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript errors for inserting with Kysely #1608

Open
FraBle opened this issue Oct 11, 2024 · 0 comments
Open

Typescript errors for inserting with Kysely #1608

FraBle opened this issue Oct 11, 2024 · 0 comments
Labels
bug Something isn't working needs-triage

Comments

@FraBle
Copy link

FraBle commented Oct 11, 2024

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.

@FraBle FraBle added the bug Something isn't working label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant