romeerez / orchid-orm

Orchid ORM
https://orchid-orm.netlify.app/
MIT License
488 stars 14 forks source link

SnakeCase Problem #333

Closed KenjiGinjo closed 1 month ago

KenjiGinjo commented 1 month ago

https://github.com/KenjiGinjo/orchid-reproduction/tree/K_333

romeerez commented 1 month ago

There are two problems here:

  1. Incorrect SQL in whereExists indirectly caused by softDelete

    await db.activity.whereExists('members', (q) => q.where({ name: 'test' }));
  2. Snake case problem caused by on bug.

    await db.activity.whereExists(db.activityMember, (q) =>
    // activity_member.activityId isn't turned to snake_case
    q.on('activity.id', 'activity_member.activityId').where({ name: 'test' }),
    );

I published a fix for the first one, and going to make a fix for the second one a bit later.

KenjiGinjo commented 1 month ago

It's ok now.

romeerez commented 1 month ago

nope, the snake case problem isn't solved yet

KenjiGinjo commented 1 month ago
q = q.whereExists('members', (q) => q.where({ 'members.userId': dto.memberId }));
// this is ok, now
romeerez commented 1 month ago

Yes, that's was fixed, but the 2nd wasn't.

I just published an update for the 2nd case:

await db.activity.whereExists(db.activityMember, (q) =>
  // activity_member.activityId isn't turned to snake_case
  q.on('activity.id', 'activity_member.activityId').where({ name: 'test' }),
);

Now it also works.