DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Ambiguous columns use the last ambiguous column value as the value

Open jostrander opened this issue 6 years ago • 2 comments

DBFlow Version: 4.2.4

Bug or Feature Request: Bug

Description: When attempting to query a double inner join, the last column "id" is the value no matter which table you are selecting from.

For example: Table 1 is a pivot table:

id, storeId, storeId2

and Table 2 has extra information:

id, store_name, store_coords

So if I want to do a join to combine these two records into one row into a list I would use FlowCursorList

FlowCursorList.Builder<Table1>(SQLite.select()
    .from(Table1::class.java)
    .innerJoin(Table2::class.java).on(Table2_Table.id).eq(Table1_Table.storeId)
    .innerJoin(Table2::class.java).on(Table2_Table.id).eq(Table1_Table.storeId2))
    //   ...where/orderBy cut for brevity
    .build()

This always results in storeId2's Id being selected when using Table1.id in my adapter. I've tried using aliases, and selecting the columns manually, but nothing seems to fix it.

jostrander avatar Jun 04 '18 19:06 jostrander

I;ve run into this issue too, any ways to resolve it?

xxxifan avatar Oct 28 '19 02:10 xxxifan

add .withTable() to property should fix this.

xxxifan avatar Oct 28 '19 02:10 xxxifan