I have a query with two left join but only the fields from the first left join shows up
in the returned row
However, the missing field is part of the db._lastsql and if I run the sql query directly
in a query tool (pgAdmin) it returns this field correctly.
Here is my query:
khRow=db((
db.keyholder.id==request.args[0])).select(left=db.shop_product.on(db.keyholder.product==
db.shop_product.id)).first()
db((
db.keyholder.id == request.args[0])).select(db.shop_product.limit_val,
db.shop_product.limit_type,
db.shop_product.name,
db.keyholder.product,
db.keyholder.deposit,
db.keyholder.expire,
db.keyholder.open_count_left,
db.keyholder.price,
db.shop_price.stripe_price_id
, left=[
db.shop_product.on(db.keyholder.product ==
db.shop_product.id), db.shop_price.on(
(db.keyholder.product == db.shop_price.product) & (
db.keyholder.cust_type == db.shop_price.cust_type))], ).first()
I would expect to be able to read the khRow.shop_price.stripe_price_id
but I get an attribute error and inspecting the khRow in a debugger reviles that the field does not exist in the khRow.
The SQL that this quey produce is:
SELECT "shop_product"."limit_val", "shop_product"."limit_type", "shop_product"."name", "keyholder"."product", "keyholder"."deposit", "keyholder"."expire", "keyholder"."open_count_left", "keyholder"."price", "shop_price"."stripe_price_id"
FROM "keyholder"
LEFT JOIN "shop_product" ON (("keyholder"."product" = "shop_product"."id") AND ("shop_product"."org" = 2))
LEFT JOIN "shop_price" ON ((("keyholder"."product" = "shop_price"."product") AND ("keyholder"."cust_type" = "shop_price"."cust_type")) AND ("shop_price"."org" = 2))
WHERE (("keyholder"."id" = 2519) AND ("keyholder"."org" = 2));