You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to define a has-one relation between InvTran and OeHdr and i was able to define the join successfully. Although it gives me the data i need it takes nearly 300ms to run. The reason why the data types are not both varchar is that i am building bun on top of a database for a ERP system i do not have control over and i need to follow the existing tables.
I took the generated query
LEFT JOIN "oe_hdr" AS "oe_hdr" ON ("oe_hdr"."order_no" = "inv_tran"."document_no")
and was able to use a CAST method as follows... LEFT JOIN "oe_hdr" AS "oe_hdr" ON ("oe_hdr"."order_no" = CAST("inv_tran"."document_no" as varchar)).
This reduces the query time down to 20ms; Im not entirely sure how i can CAST the document_no using tags in bun or writing a custom relation function.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like to define a has-one relation between
InvTran
andOeHdr
and i was able to define the join successfully. Although it gives me the data i need it takes nearly 300ms to run. The reason why the data types are not both varchar is that i am building bun on top of a database for a ERP system i do not have control over and i need to follow the existing tables.I took the generated query
LEFT JOIN "oe_hdr" AS "oe_hdr" ON ("oe_hdr"."order_no" = "inv_tran"."document_no")
and was able to use a CAST method as follows...
LEFT JOIN "oe_hdr" AS "oe_hdr" ON ("oe_hdr"."order_no" = CAST("inv_tran"."document_no" as varchar))
.This reduces the query time down to 20ms; Im not entirely sure how i can CAST the
document_no
using tags in bun or writing a custom relation function.Here is my models and a example function
Beta Was this translation helpful? Give feedback.
All reactions