Two dimensional list from query with preload

from c in City,
 left_join: p in Post,
 on: p.id == c.post_id,
 select: [c.name, p.title],
 preload: [:post]

For the csv lib i need the table data in a two dimensional list. The obove gives me:
the binding used in from must be selected in select when using preload in query

I need the result looking like this

 [["Cityname1","Post1"]["Cityname2","Postname2"]]

thanks

2 Likes

You can remove the preload and it should work with just the join that you have. Preload attaches the preloaded data to the source schema and since you are not selecting the source schema (only a single field from it) it is not needed.

1 Like

Thank you. Would there be a way with the existing query? I´ve a big complex query with preload. Now i´d like to only use some fields for exporting to a csv.

1 Like

No, you can’t make it with the existing query. We raise because the :preload does not make sense unless you select the source schema.

If you have a query you are composing I would suggest only adding the preload at the end when you it will actually be used.

3 Likes

I would suggest only adding the preload at the end when you it will actually be used.

I should have thought of that myself :frowning:

Thanks for your input.

1 Like