ITADN
go-pg/pg/Issues

Multiple joins not deserializing correctly

#1998Openfarbodg 创建于 2024-02-08
F
farbodgcommented
I have the following tables: ```golang type Table1 struct { tableName models.TableName `pg:"table1"` ID string `pg:"id,pk"` Table2ID string `pg:"table2_id,notnull"` ... Table2 *Table2 `pg:"rel:has-one"` Table3 *Table3 `pg:"rel:has-one"` // can be has-many } ``` ```golang type Table2 struct { tableName models.TableName `pg:"table2"` ID string `pg:"id,pk"` ... } ``` ```golang type Table3 struct { tableName models.TableName `pg:"table3"` ID string `pg:"id,pk"` Table1ID string `pg:"table1_id,notnull"` ... Table1 *Table1 `pg:"rel:has-one"` } ``` And the following query: ```golang return tx.Model(&table1). ColumnExpr("table2.*"). ColumnExpr("table3.*"). Relation("Table2"). Relation("Table3"). Join("INNER JOIN table2"). JoinOn("table1.table2_id = table2.id"). Join("INNER JOIN table3"). JoinOn("table1.id = table3.table1_id"). Where(...). Select() ``` My results return the records in Table1 and Table2, but not Table3 (Table3 field is nil).
0 条评论