Skip to content

[BUG]: Incorrect type inference on relational query #968

Open
@williamlmao

Description

@williamlmao

What version of drizzle-orm are you using?

0.27.2

What version of drizzle-kit are you using?

0.19.12

Describe the Bug

My prepared statement is correctly returning the data I would expect, but the type that is inferred does not match.

Prepared Statement

export const pGetTrainingSetWithExamples = db.query.trainingSets
  .findFirst({
    where: eq(trainingSets.publicId, placeholder("publicId")),
    with: {
      examples: true,
    },
  })
  .prepare();

Returned data:

{
id: 1,
publicId: 'abcd',
userId: '1234',
name: 'Indicators',
description: 'Indicators',
stopSequence: null,
promptSeparator: null,
createdAt: 2023-08-02T06:53:30.000Z,
lastUpdated: 2023-08-02T06:53:30.000Z,
examples: [
  {
    id: 1,
    prompt: "Hi",
    completion: 'Hello',
    flagged: null,
    reviewed: null,
    locked: null,
    validFrom: null,
    validTo: null,
    trainingSetId: 1,
    createdAt: 2023-08-02T08:05:49.000Z,
    lastUpdated: 2023-08-02T08:05:49.000Z
  }
]
}

I would expect examples to be on the type. You can see from the screenshot below that intellisense is not picking up on it.

image

Expected behavior

The type to match the data

Environment & setup

local

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocsImprovements or additions to documentationdocs/improvementspriorityWill be worked on next

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions