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

fix(duckdb): try fix typecheck #39

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/stage-tamagotchi/src/renderer/src/worker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare module '*.js?url' {
const content: string
export default content
}

declare module '*.wasm?url' {
const content: string
export default content
}

declare module '*.cjs?url' {
const content: string
export default content
}
3 changes: 3 additions & 0 deletions packages/drizzle-duckdb-wasm/src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ export function drizzle<
if (typeof connection === 'string')
return constructByDSN(connection, drizzleConfig) as any

if (typeof connection === 'undefined')
throw new Error('connection option is required')

Comment on lines +126 to +128
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I throw Error here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think so

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

return construct(connect({
bundles: connection.bundles,
logger: connection.logger,
Expand Down
7 changes: 4 additions & 3 deletions packages/drizzle-duckdb-wasm/src/dsn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export function parseDSN(dsn: string): StructuredDSN {
structured.bundles = 'import-url'
}

if (isLiterallyTrue(parsed.searchParams.get('logger'))) {
const paramLogger = parsed.searchParams.get('logger')
if (paramLogger && isLiterallyTrue(paramLogger)) {
structured.logger = true
}

Expand All @@ -57,9 +58,9 @@ export function parseDSN(dsn: string): StructuredDSN {
structured.storage = {
type: DBStorageType.ORIGIN_PRIVATE_FS,
path: parsed.pathname.startsWith('/') ? parsed.pathname.slice(1) : parsed.pathname,
...isLiterallyTrue(paramWrite) && {
...(paramWrite && isLiterallyTrue(paramWrite) && {
accessMode: DuckDBAccessMode.READ_WRITE,
},
}),
}
break
}
Expand Down
4 changes: 2 additions & 2 deletions packages/drizzle-duckdb-wasm/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class DuckDBWasmSession<
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(
query: Query,
fields: SelectedFieldsOrdered | undefined,
name: string | undefined,
isResponseInArrayMode: boolean,
_name: string | undefined,
_isResponseInArrayMode: boolean,
customResultMapper?: (rows: unknown[][]) => T['execute'],
): PgPreparedQuery<T> {
return new DuckDBWASMPreparedQuery(
Expand Down
2 changes: 1 addition & 1 deletion packages/duckdb-wasm/src/duckdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface DuckDBWasmClient {
db: AsyncDuckDB
conn: AsyncDuckDBConnection
close: () => Promise<void>
query: (string, params?: unknown[]) => Promise<Record<string, unknown>[]>
query: (query: string, params?: unknown[]) => Promise<Record<string, unknown>[]>
}

export async function connect(options: ConnectOptions): Promise<DuckDBWasmClient> {
Expand Down
2 changes: 1 addition & 1 deletion packages/duckdb-wasm/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function parseInterval(arr: Int32Array) {
const years = arr[0]
const months = arr[1]

const result = []
const result: string[] = []
if (years !== 0) {
result.push(`${years} year${years > 1 ? 's' : ''}`)
}
Expand Down