Error postgresql bigint

hi i just migrated one table from mysql to postgresql and im getting this on query:

operator does not exist: text = bigint

this is my query


SELECT transactions.id,transactions.document,transactions.transaction_date,transactions.ref_no,transactions.status,contacts.supplier_business_name,contacts.id as idcontacto, CONCAT(COALESCE(u.surname, ''),' ',COALESCE(u.first_name, ''),' ',COALESCE(u.last_name,'')) as added_by,SUM(pl.quantity - pl.po_quantity_purchased) as po_qty_remaining,BS.name as location_name,contacts.address_line_1,contacts.custom_field1,contacts.custom_field2,contacts.landline,contacts.mobile,contacts.email

from transactions

LEFT JOIN contacts
ON transactions.contact_id = contacts.id

JOIN business_locations as BS
ON transactions.location_id = BS.id

LEFT JOIN purchase_lines as pl
ON transactions.id = pl.transaction_id

LEFT JOIN users as u
ON transactions.created_by = u.id

WHERE transactions.type = 'purchase_order' GROUP BY transactions.id

what im doing wrong? thank you

for which column?
if there is one column that is text and the id bigint try

ON transactions.created_by::bigint = u.id

how i know which column? i got a lot of columns bigint

i put in all fields

SELECT transactions.id,transactions.document,transactions.transaction_date,transactions.ref_no,transactions.status,contacts.supplier_business_name,contacts.id as idcontacto, CONCAT(COALESCE(u.surname, ''),' ',COALESCE(u.first_name, ''),' ',COALESCE(u.last_name,'')) as added_by,SUM(pl.quantity - pl.po_quantity_purchased) as po_qty_remaining,BS.name as location_name,contacts.address_line_1,contacts.custom_field1,contacts.custom_field2,contacts.landline,contacts.mobile,contacts.email

from transactions

LEFT JOIN contacts
ON transactions.contact_id = contacts.id

JOIN business_locations as BS
ON transactions.location_id::bigint = BS.id

LEFT JOIN purchase_lines as pl
ON transactions.id::bigint = pl.transaction_id

LEFT JOIN users as u
ON transactions.created_by::bigint = u.id

WHERE transactions.type = 'purchase_order' GROUP BY transactions.id

but still the issue

  • rror:true

  • message:"operator does not exist: text = bigint"

  • position:553

    • source:"resource"

You need to look at the db columns and see what types they are so you would know which ones to convert to either bigint or text

im not as clear with that, what should be the logic behind that? i mean i just imported from a mysql db, that was working. when should i use bigint exactly?

most of my tables have all text for example

Do you have access to the db? For example do you know if transactions.contact_id column is a bigint or a text and so on?

yes, postgresql in supabase

Looks like transactions.contact_id is a text and contacts.id could be a bigint(int8). So I made the change below...

However, I cannot tell if pl.transaction_id is also a bigint(int8) - but if it isn't than it should look like
ON transactions.id = pl.transaction_id::bigint

SELECT transactions.id,transactions.document,transactions.transaction_date,transactions.ref_no,transactions.status,contacts.supplier_business_name,contacts.id as idcontacto, CONCAT(COALESCE(u.surname, ''),' ',COALESCE(u.first_name, ''),' ',COALESCE(u.last_name,'')) as added_by,SUM(pl.quantity - pl.po_quantity_purchased) as po_qty_remaining,BS.name as location_name,contacts.address_line_1,contacts.custom_field1,contacts.custom_field2,contacts.landline,contacts.mobile,contacts.email

from transactions

LEFT JOIN contacts

ON transactions.contact_id::bigint = contacts.id

JOIN business_locations as BS

ON transactions.location_id = BS.id

yes pl. transaction_id is int8

so i should but ::bigint to those columns that have int8 as column type?

i may be missing something as i put all ::bigint but still same error

SELECT transactions.id,transactions.document,transactions.transaction_date,transactions.ref_no,transactions.status,contacts.supplier_business_name,contacts.id as idcontacto, CONCAT(COALESCE(u.surname, ''),' ',COALESCE(u.first_name, ''),' ',COALESCE(u.last_name,'')) as added_by,SUM(pl.quantity - pl.po_quantity_purchased) as po_qty_remaining,BS.name as location_name,contacts.address_line_1,contacts.custom_field1,contacts.custom_field2,contacts.landline,contacts.mobile,contacts.email

from transactions

LEFT JOIN contacts
ON transactions.contact_id::bigint = contacts.id

JOIN business_locations as BS
ON transactions.location_id::bigint = BS.id

LEFT JOIN purchase_lines as pl
ON transactions.id = pl.transaction_id::bigint

LEFT JOIN users as u
ON transactions.created_by::bigint = u.id

WHERE transactions.type = 'purchase_order' GROUP BY transactions.id

almost all of my .id are int8, i cant just change to text all that ?

example all of this are int8

LEFT JOIN contacts
ON transactions.contact_id (TEXT) = contacts.id (INT8)

JOIN business_locations as BS
ON transactions.location_id (INT8) = BS.id (INT8)

LEFT JOIN purchase_lines as pl
ON transactions.id (INT8) = pl.transaction_id (INT8)

LEFT JOIN users as u
ON transactions.created_by (INT8) = u.id (INT8)

transactions.contact_id::bigint should be tried
Check out the first answer here: postgresql - What's the difference between BIGINT and INT8? (postgres) - Stack Overflow.

correct, tried that transactions.contact_id::bigint but same

tried the stackoverflow and understood better now is working

thank you a lot