kylefarris / node-querybuilder

Node QueryBuilder Adapter for Node.js (tags: nodejs, node, mysql, active record, activerecord, querybuilder, query builder)
49 stars 19 forks source link

[2.0.0-beta.1] Asterisk is dropped from select statements #37

Closed Flamenco closed 6 years ago

Flamenco commented 6 years ago

driver: mysql

   qb.from('group_user gu')
      .where('gu.groupId', groupId)
      .where_in('gu.status', [0, 1])
      .join('accounts a', 'a.username=gu.username')
      .join('group g', 'g.id=gu.groupId')
      .join('accounts a2', 'a2.username=g.username')
      .select('gu.*, a.displayname, a.email, g.name as groupName, a2.displayname as invitor')

expected

SELECT gu.* ...

actual

  sql: 'SELECT `gu`., `a`.`displayname`, `a`.`email`, `g`.`name` as `groupName`, `a2`.`displayname` as `invitor` FROM `group_user` `gu` JOIN `accounts` `a` ON `a`.`username` = `gu`.`username` JOIN `group` `g` ON `g`.`id` = `gu`.`groupId` JOIN `accounts` `a2` ON `a2`.`username` = `g`.`username` WHERE `gu`.`groupId` = 20 AND `gu`.`status` IN (0, 1)' }

workaround

.select('gu.*', false')
.select('a.displayname, a.email, g.name as groupName, a2.displayname as invitor')

or

.select('gu.*,a.displayname, a.email, g.name as groupName, a2.displayname as invitor', false)
kylefarris commented 6 years ago

Looks like this was resolved in your pull request.