We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch @powersync/[email protected] for the project I'm working on.
@powersync/[email protected]
I wanted to add a custom timestamp column type to map between ISO-formatted date strings and Date objects like so:
timestamp
import { customType } from 'drizzle-orm/sqlite-core'; // https://orm.drizzle.team/docs/custom-types export const sqliteTimestamp = customType<{ data: Date; driverData: string }>({ dataType() { return 'text'; }, fromDriver(value) { return new Date(value); }, toDriver(value) { return value.toISOString(); }, });
However, I ran into an issue passing this schema to DrizzleAppSchema:
DrizzleAppSchema
Error: Unsupported column type: SQLiteCustomColumn
Here is the diff that solved my problem:
diff --git a/node_modules/@powersync/drizzle-driver/lib/src/utils/schema.js b/node_modules/@powersync/drizzle-driver/lib/src/utils/schema.js index 9db8abc..94e46cb 100644 --- a/node_modules/@powersync/drizzle-driver/lib/src/utils/schema.js +++ b/node_modules/@powersync/drizzle-driver/lib/src/utils/schema.js @@ -1,7 +1,7 @@ import { column, Schema, Table } from '@powersync/common'; import { entityKind, isTable } from 'drizzle-orm'; import { CasingCache } from 'drizzle-orm/casing'; -import { getTableConfig, SQLiteBoolean, SQLiteInteger, SQLiteReal, SQLiteText, SQLiteTextJson, SQLiteTimestamp } from 'drizzle-orm/sqlite-core'; +import { getTableConfig, SQLiteBoolean, SQLiteCustomColumn, SQLiteInteger, SQLiteReal, SQLiteText, SQLiteTextJson, SQLiteTimestamp } from 'drizzle-orm/sqlite-core'; export function toPowerSyncTable(table, options) { var _a, _b; const { columns: drizzleColumns, indexes: drizzleIndexes } = getTableConfig(table); @@ -14,6 +14,7 @@ export function toPowerSyncTable(table, options) { continue; } let mappedType; + MapColumn: switch (drizzleColumn.columnType) { case SQLiteText[entityKind]: case SQLiteTextJson[entityKind]: @@ -27,6 +28,18 @@ export function toPowerSyncTable(table, options) { case SQLiteReal[entityKind]: mappedType = column.real; break; + case SQLiteCustomColumn[entityKind]: + switch (drizzleColumn.sqlName) { + case 'text': + mappedType = column.text; + break MapColumn; + case 'integer': + mappedType = column.integer; + break MapColumn; + case 'real': + mappedType = column.real; + break MapColumn; + } default: throw new Error(`Unsupported column type: ${drizzleColumn.columnType}`); }
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered:
Hey @simonflk, thanks for this! I'll give it a look over and see if I can get it into main in the next day or so.
Sorry, something went wrong.
Hey @simonflk, I made a minor change - just for sanity could you verify this works for @powersync/[email protected]?
Thank you @Chriztiaan
I just tested this version, and it's working for me
No branches or pull requests
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
@powersync/[email protected]
for the project I'm working on.I wanted to add a custom
timestamp
column type to map between ISO-formatted date strings and Date objects like so:However, I ran into an issue passing this schema to
DrizzleAppSchema
:Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: