Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving wrong field in a query with join. #40

Open
domecq opened this issue Jul 11, 2013 · 1 comment
Open

Retrieving wrong field in a query with join. #40

domecq opened this issue Jul 11, 2013 · 1 comment

Comments

@domecq
Copy link

domecq commented Jul 11, 2013

Hello,
To be honest I don't know if it is an issue or I am doing something wrong.
This is my query:

        var q = new joli.query()
          .select('item.*')
          .from('orderitem')
          .order(['orderitem_id desc'])
          .join('orders','orders.order_id','orderitem.order_id')
          .join('item','item.item_id','orderitem.item_id');

           var items = q.execute();

So far I can see Joli is properly constructing the query :

select item.* 
from orderitem left outer join orders on orders.order_id = orderitem.order_id 
left outer join item on item.item_id = orderitem.item_id 
order by orderitem_id desc

The problem is that items collection only return orderitem's fields rather than the item's fields.

This is what each returning record has:

I/TiAPI   ( 1598):  key in _options
I/TiAPI   ( 1598):  key in _data
I/TiAPI   ( 1598):  key in _originalData
I/TiAPI   ( 1598):  key in isNew
I/TiAPI   ( 1598):  key in orderitem_id
I/TiAPI   ( 1598):  key in order_id
I/TiAPI   ( 1598):  key in item_id
I/TiAPI   ( 1598):  key in item_quantity
I/TiAPI   ( 1598):  key in beer_quantity
I/TiAPI   ( 1598):  key in orderitem_type
I/TiAPI   ( 1598):  key in beer_id

Those are all fields belonging to orderitem instead of item table as I expected.

Thanks!
nico.

@OwenMelbz
Copy link

Hi Nico, I've got this exact problem at the moment, was wondering if you've sorted this and how? Otherwise i'll have to start modifying the joli core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants