Skip to content

Problem mapping field on use Join #57

@icharge

Description

@icharge
const sql = sqlQuery.select()
      .from('machine_log')
      .select('when', 'machine_id', 'event')
      .from('machines', 'machine_id ', 'machine_log', 'machine_id')
      .select('name')
      .order('when', 'Z')
      .limit(limit)
      .build();

And it produce this SQL that so wrong

SELECT `t1`.`when`, `t1`.`machine_id`, `t1`.`event`, `t2`.`name` FROM `machine_log` `t1` JOIN `machines` `t2` ON `t2`.`machines` = `t1`.`machine_id` ORDER BY `when` DESC LIMIT 10

ON t2.machines must be ON t2.machine_id
like this

SELECT `t1`.`when`, `t1`.`machine_id`, `t1`.`event`, `t2`.`name` FROM `machine_log` `t1` JOIN `machines` `t2` ON `t2`.`machine_id` = `t1`.`machine_id` ORDER BY `when` DESC LIMIT 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions