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

MySQL generated columns #169

Open
twiddler opened this issue Jun 30, 2024 · 0 comments
Open

MySQL generated columns #169

twiddler opened this issue Jun 30, 2024 · 0 comments

Comments

@twiddler
Copy link

twiddler commented Jun 30, 2024

This MySQL table

CREATE TABLE `Foo` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `firstName` varchar(255) NOT NULL DEFAULT '',
  `lastName` varchar(255) NOT NULL DEFAULT '',
  `fullName` varchar(255) GENERATED ALWAYS AS (concat(`firstName`, ' ',`lastName`)) STORED NOT NULL
);

leads to these types

export interface Foo {
    id: Generated<number>
    firstName: Generated<string>
    lastName: Generated<string>
    fullName: string
}

This causes issues when trying

db.insertInto("Foo").values({
    firstName: "foo",
    lastName: "bar"
})

Property 'fullName' is missing in type '{ firstName: string; lastName: string; }' but required in type '{ fullName: ValueExpression<DB, "Foo", string>; }'.ts(2345)

I believe fullName should be typed Generated<string>, shouldn't it? 🤔

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant