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

[BUG]: TypeError: __vite_ssr_import_1__.db.$with is not a function #4035

Open
1 task done
ikrom opened this issue Jan 29, 2025 · 0 comments
Open
1 task done

[BUG]: TypeError: __vite_ssr_import_1__.db.$with is not a function #4035

ikrom opened this issue Jan 29, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ikrom
Copy link

ikrom commented Jan 29, 2025

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.33.0

What version of drizzle-kit are you using?

0.22.0

Other packages

No response

Describe the Bug

I got error when try to use WITH clause in my Sveltekit app.

const baseStatusQuery = db.$with('base_stats').as(
		db
			.select({
				discipline: task.discipline,
				total: sql<number>`COUNT(*)`,
				done_total: sql<number>`SUM(CASE WHEN status = ${TaskStatus.done} THEN 1 ELSE 0 END)`,
				not_started_total: sql<number>`SUM(CASE WHEN status = ${TaskStatus.notStarted} THEN 1 ELSE 0 END)`,
				outstanding_total: sql<number>`SUM(CASE WHEN status = ${TaskStatus.outstanding} THEN 1 ELSE 0 END)`,
				on_progress_total: sql<number>`SUM(CASE WHEN status = ${TaskStatus.onProgress} THEN 1 ELSE 0 END)`
			})
			.from(task)
			.groupBy(task.discipline)
	);

The error:

TypeError: __vite_ssr_import_1__.db.$with is not a function
    at GET (/Users/xxx/projects/yyy/web/src/routes/api/v1/disciplines/summary/+server.ts:46:29)
    at Module.render_endpoint (/Users/xxx/projects/yyy/web/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js:43:24)
    at resolve (/Users/xxx/projects/yyy/web/node_modules/@sveltejs/kit/src/runtime/server/respond.js:455:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Module.respond (/Users/xxx/projects/yyy/web/node_modules/@sveltejs/kit/src/runtime/server/respond.js:331:20)
    at async fetch (/Users/xxx/projects/yyy/web/node_modules/@sveltejs/kit/src/runtime/server/fetch.js:138:22)

My stack:

"@sveltejs/kit": "^2.0.0",
"bun":"1.1.38",
"svelte": "^5.0.0",
"vite": "^5.4.11",

@ikrom ikrom added the bug Something isn't working label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant