{"id":"ec37fb1812fa343f","repo":"drizzle-team/drizzle-orm","slug":"failed-query-querystring-params-params-ec37fb","errorCode":null,"errorMessage":"Failed query: ${queryString}\nparams: ${params}","messagePattern":"Failed query: (.+?)\nparams: (.+?)","errorType":"exception","errorClass":"DrizzleQueryError","httpStatus":null,"severity":"error","filePath":"drizzle-orm/src/singlestore-core/session.ts","lineNumber":77,"sourceCode":"\t\tif (cache && cache.strategy() === 'all' && cacheConfig === undefined) {\n\t\t\tthis.cacheConfig = { enable: true, autoInvalidate: true };\n\t\t}\n\t\tif (!this.cacheConfig?.enable) {\n\t\t\tthis.cacheConfig = undefined;\n\t\t}\n\t}\n\n\t/** @internal */\n\tprotected async queryWithCache<T>(\n\t\tqueryString: string,\n\t\tparams: any[],\n\t\tquery: () => Promise<T>,\n\t): Promise<T> {\n\t\tif (this.cache === undefined || is(this.cache, NoopCache) || this.queryMetadata === undefined) {\n\t\t\ttry {\n\t\t\t\treturn await query();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\t// don't do any mutations, if globally is false\n\t\tif (this.cacheConfig && !this.cacheConfig.enable) {\n\t\t\ttry {\n\t\t\t\treturn await query();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new DrizzleQueryError(queryString, params, e as Error);\n\t\t\t}\n\t\t}\n\n\t\t// For mutate queries, we should query the database, wait for a response, and then perform invalidation\n\t\tif (\n\t\t\t(\n\t\t\t\tthis.queryMetadata.type === 'insert' || this.queryMetadata.type === 'update'\n\t\t\t\t|| this.queryMetadata.type === 'delete'\n\t\t\t) && this.queryMetadata.tables.length > 0","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-orm/src/singlestore-core/session.ts#L59-L95","documentation":"DrizzleQueryError thrown in SingleStorePreparedQuery.queryWithCache (session.ts:77) in the no-cache / NoopCache branch. When the underlying driver query rejects, Drizzle wraps the driver error and re-throws with the rendered SQL and bound params for diagnostics. The original error is preserved on `.cause`.","triggerScenarios":"Any executed statement (select/insert/update/delete) fails at the database when caching is disabled or the cache is NoopCache: constraint violations, syntax errors, missing tables, connection drops, deadlocks, etc.","commonSituations":"Unique-key or foreign-key violations; typos in raw sql fragments; schema drift (table/column renamed in DB but not in code); transient network/connection errors; incorrect bind param types.","solutions":["Inspect err.query and err.params (and err.cause) to identify the failing statement and root driver error.","Fix the underlying schema/constraint/data issue revealed by err.cause.","Wrap mutating operations in try/catch on DrizzleQueryError to apply domain-specific recovery or retry."],"exampleFix":"// before\nawait db.update(users).set({ email }).where(eq(users.id, id));\n// after\ntry {\n  await db.update(users).set({ email }).where(eq(users.id, id));\n} catch (e) {\n  if (e instanceof DrizzleQueryError) console.error(e.query, e.cause);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import { DrizzleQueryError } from 'drizzle-orm/errors';\nfunction isDrizzleQueryError(e): e is DrizzleQueryError {\n  return e instanceof Error && /^Failed query:/.test(e.message);\n}","tryCatchPattern":"import { DrizzleQueryError } from 'drizzle-orm/errors';\ntry { await q; } catch (e) {\n  if (e instanceof DrizzleQueryError) { logger.error({ query: e.query, params: e.params, cause: e.cause }); }\n  throw e;\n}","preventionTips":["Validate inputs and schema before executing to avoid constraint errors.","Keep schema migrations in sync with code to prevent schema drift.","Log DrizzleQueryError.query/params/cause for post-mortem diagnostics."],"tags":["query-execution","database-error","singlestore","driver"],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}