Skip to content

SELECT field on joined tables gives unexpected undefined #1985

Open
@radegran

Description

Repro steps

const users =  [{UserId: '1', UserName: 'User'}]
const orders = [{UserId: '1', Text: 'Order text'}]

const expected = alasql(`
  SELECT *
  FROM ? u 
  JOIN ? o 
  ON u.UserId = o.UserId`, 
  [users, orders])

const unexpected = alasql(`
  SELECT UserName,Text 
  FROM ? u 
  JOIN ? o 
  ON u.UserId = o.UserId`, 
  [users, orders])
  
console.log({expected, unexpected}); 
// {
//   expected: [{
//     Text: "Order text",                       <- "Text" field is there ...
//     UserId: "1",
//     UserName: "User"
// }],
//   unexpected: [{
//     Text: undefined,                          <- ... but it is undefined when selected
//     UserName: "User"
//   }]
// }

JSFiddle

https://jsfiddle.net/0nhuqp9f/

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions