Is there some general fix to conversion problems?

Been off SC for a while and decided to convert my version 8 apps to 9, following the steps. Recompiled all the code and I have random errors all over the place.

A particularly vexing one is this: happening with my grids. An example, a grid running on the orders table which has the automatic lookup on ProductID

select ProductName from product where ProductID = {ProductID} order by ProductName

On v8, this correctly displays the name of the product but in v9, there is an SQL error. On examination, I find SC9 is attempting this.

select ProductName from product where ProductID = Pizza order by ProductName

i.e. it has somehow substituted ProductName for ProductID in the SQL.

This is so bewildering I don’t even know where to start.

I dont think it is due to SC convertion.
It is likely your app has a bug which was somewhat hidden in SC8 and now has been uncovered in SC9.
I would check the code that assigns the field value used in the where clause.

It worked when I changed the lookup to:

select ProductID, ProductName from product where ProductID = {ProductID} order by ProductName

However, this is a grid and so there should not be a need to do that at all!!

Created a fresh app without this change and it worked. So definitely something’s wrong with the conversion, not my code. This is on SC 9.4.032 though.