Skip to content

Order by doesnt use with table #2821

Description

@DoctorFTB

Description and expected behavior
Then using order by with enum - got wrong order

Environment (please complete the following information):

  • ZenStack version: 3.9.2
  • Database type: PostgreSQL
  • Node.js/Bun version: 22
  • Package manager: npm

Additional context

Schema:

enum OkStatus {
  OK @map("ok")
  NO @map("no")

  @@map("ok_status")
}

model Post {
  id        String   @id
  status    OkStatus
}

Code:

const output1_variant1 = await client
  .$qb.selectFrom('Post')
  .select('status')
  .orderBy('status', 'asc')
  .execute();
const output2_variant1 = await client
  .$qb.selectFrom('Post')
  .select('status')
  .orderBy('Post.status', 'asc')
  .execute();
const output2_variant2 = await client
  .$qb.selectFrom('Post')
  .select('status as otherName')
  .orderBy('status', 'asc')
  .execute();

console.log(output1_variant1); // [{ status: 'NO' }, { status: 'OK' }]
console.log(output2_variant1); // [{ status: 'OK' }, { status: 'NO' }]
console.log(output2_variant2); // [{ otherName: 'OK' }, { otherName: 'NO' }]

I think kysely mapper missing auto add table name for order by
Cuz orderBy uses select name "status"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions