-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Improve asDrizzleTable()
types
#10882
Conversation
🦋 Changeset detectedLatest commit: 2aedfce The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/db/src/runtime/index.ts
Outdated
@@ -8,8 +8,14 @@ import { | |||
sqliteTable, | |||
text, | |||
} from 'drizzle-orm/sqlite-core'; | |||
import { type DBColumn, type DBTable } from '../core/types.js'; | |||
import { type SerializedSQL, isSerializedSQL } from './types.js'; | |||
import { tableSchema } from '../core/schemas.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ha, it looks like tableSchema
would pull a core module into the runtime. We have a lint check against this. Perhaps we can move asDrizzleTable
from runtime/
to core/
and still expose as a package export?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a quick look, but not sure if that would work? asDrizzleTable
is used in the Vite plugin:
import { asDrizzleTable, createLocalDatabaseClient, normalizeDatabaseUrl } from ${RUNTIME_IMPORT}; |
`export const ${name} = asDrizzleTable(${JSON.stringify(name)}, ${JSON.stringify( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, tried a different approach, which seems to work. I think the asDrizzleTable()
we expose to users needs to be different from the one we use internally, so in the latest commit I wrapped the internal version with the tweaks we made for use only by integration authors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad we could addrizz
the issue!
Changes
Improves the typing of the
asDrizzleTable()
utilityFixes a type error when passing the output of
defineTable()
to the utility and returns a more detailed type inferred from the columns of the passed table config.Testing
Tested manually in an integration
Docs
n/a — bug fix