Hello there im working on pagination on my query
first lets see my query
query
|> join(:left, [o], op in OrderProduct, as: :order_product, on: o.id == op.order_id)
|> join(:left, [o, op], p in Product, as: :product, on: op.product_id == p.id)
|> preload(
[order_product: op, product: p],
[
:order_type,
:merchant,
:customer,
:payment_method,
order_product: {
op,
product: p
},
]
)
is valid query and its working, after giving it limit the result mess up
what i mean by mess up is i set the limit 5 but it return 3
i thought it was my query but after hour debugging i realize if i remove nested preload to be this
query
|> join(:left, [o], op in OrderProduct, as: :order_product, on: o.id == op.order_id)
|> join(:left, [o, op], p in Product, as: :product, on: op.product_id == p.id)
|> preload(
[order_product: op, product: p],
[
:order_type,
:merchant,
:customer,
:payment_method,
# order_product: {
# op,
# product: p
# },
]
it working and find any idea what is going here ??