I'm new to Metastorage, so forgive me if I've overlooked something
obvious. Anyhow, I can't get my persist function to work reliably.
I've using the same function for the same class in several places, and
it works correctly in most cases, but in one particular spot, it
always fails with a "You have an error in your SQL syntax..." error.
I've got debugging turned on, and the debugging output is:
1 Query: SELECT person.id, person.external_user_id, person.name FROM
person WHERE person.external_user_id=2
1 Query: SELECT inventory.id, inventory.name, inventory.description,
inventory.person FROM inventory WHERE id=75
1 Query: SELECT walk.id, walk.name, walk.date, walk.persons,
walk.days, walk.inventory FROM walk WHERE inventory=75
1 Query: SELECT inventory_item.id, inventory_item.notes,
inventory_item.mandatory, inventory_item.shared,
inventory_item.calculation, inventory_item.sort,
inventory_item.description, inventory_item.grams, inventory_item.item,
inventory_item.inventory FROM inventory_item WHERE inventory=75
1 PrepareQuery: UPDATE inventory_item SET notes=?, mandatory=?,
shared=?, calculation=?, sort=?, description=?, grams=?, item=?,
inventory=? WHERE id=?
1 Query: UPDATE inventory_item SET notes='', mandatory='N',
shared='N', calculation='', sort=1, description='', grams=, item=10,
inventory=75 WHERE id=792
1 Query error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near ' item=10, inventory=75 WHERE id=792' at line 1
You can clearly see that the 'grams' field in the 'PrepareQuery' is
'?' (ie, 'grams' has not yet been defined for this object), but in the
'Query' line below that, the 'grams' is simply blank. I was under the
impression that Metastorage should be making it a 'NULL'.
Is this what is supposed to happen?
Or do I have to manually check each and every field every time before
I 'persist'?