drizzle-team / drizzle-team/drizzle-orm

[BUG]: pg query object is not aligned with pg-instrumentation

Open
#1,054 7 comments 1 reaction 0 assignees View on GitHub
bug db/postgres
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.28.0

### What version of `drizzle-kit` are you using?

_No response_

### Describe the Bug

The query instrumentation patch is expecting a query object of type
`export interface QueryConfig {`
` name?: string | undefined;`
` text: string;`
` values?: I | undefined;`
` types?: CustomTypesConfig | undefined;`
`}`

drizzle sends this object but is not setting the values so the check on the values sets it to undefined, so the query params are not available in the query hook (which is my use case)

you can see pg-instrumentation check here
`const queryConfig = firstArgIsString`
` ? {`
` text: arg0,`
` values: Array.isArray(args[1]) ? args[1] : undefined,`
` }`
` : firstArgIsQueryObjectWithText // <- drizzle case, but values are not set into arg0 (query object with text)`
` ? arg0`
` : undefined;`

source code:
[https://github.com/open-telemetry/opentelemetry-js-contrib/blob/b3d30afe7376760d211b20c4fb45988ac58c1d85/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts#L192C35-L192C35](url)

### Expected behavior

Values should be set in NodePgPreparedQuery constructor

` constructor(`
` private client: NodePgClient,`
` queryString: string,`
` private params: unknown[],`
` private logger: Logger,`
` private fields: SelectedFieldsOrdered | undefined,`
` name: string | undefined,`
` private customResultMapper?: (rows: unknown[][]) => T['execute'],`
` ) {`
` super();`
` this.rawQuery = {`
` name,`
` text: queryString,`
` values: this.params,`
` };`
` this.query = {`
` name,`
` text: queryString,`
` values: this.params,`
` rowMode: 'array',`
` };`
` }`

### Environment & setup

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the NodePgPreparedQuery constructor and compare the rawQuery and query objects with the pg-instrumentation QueryConfig shown in the issue. Verify the query hook receives the prepared query parameters through values, and confirm the PostgreSQL instrumentation can access them.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, postgresql, typescript
Domain
database
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.