HergBot / musqrat

A lightweight, strongly typed wrapper for using MySQL in Node.JS
0 stars 0 forks source link

Can't use join fields in where query #2

Closed xHergz closed 3 years ago

xHergz commented 3 years ago

Currently the where section of the query has no knowledge of the joins.

Reproduce:

interface SchemaA{
  A_Id: number;
  A_Field: string;
}

const SchemaA = musqrat.initTable<SchemaA, "A_Id">("SchemaA");

interface SchemaB{
  B_Id: number;
  A_Id: number;
  B_Field: string;
}

const SchemaB= musqrat.initTable<SchemaB, "B_Id">("SchemaB");

const result = SchemaB.select<[SchemaA]>('A_Field')
  .innerJoin(SchemaA, 'A_Id', 'A_Id')
  .where('A_Field', '=', 'value') //Error
  .exec();
xHergz commented 3 years ago

One case fixed, some additional fixes needed + one bug caused.