[Helma-user] SQL Exception when creating a new Object and checking if a collection is present
Franz Philipp Moser
philipp.moser at chello.at
Sat Feb 3 10:52:53 CET 2007
Hi list,
I've encountered the following problem/feature:
I create a new Thing
{{{
var nthing = new Thing();
}}}
then I do
{{{
nthing.renderSkin("edit");
}}}
in the edit skin I have a macro that checks if a certain collection exists.
{{{
if (this[nameofcollection]) ...
}}}
The I get this helma/SQL Error:
{{{
[ERROR] Error retrieving Node for Thing[[object Object]]
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 '[object Object]' at line 1
}}}
and the corresponding SQL Statement
{{{
[INFO] SQL SELECT_BYKEY THINGS 4: SELECT THINGS.* FROM THINGS WHERE
THINGS.ID = [object Object]
}}}
and the type.properties entry (if you use src as nameofcollection):
{{{
src = object(Thing)
src.local = THING_F_THING_SOURCE
src.foreign = ID
}}}
I found out that when helma creates new Objects, it sets the _id to
something like t + number (t1, t2, ...)
Because of that the SQL goes wrong.
Now I have to check if the Object was newly created:
{{{
var newRecord = isNaN(parseInt(this._id, 10));
}}}
Is this standard behavior or a feature? Shouldn't this be changed?
I thing it should return null, to make it more transparent, if you call
this[nameofcollection] in new created Objects.
cu Philipp
More information about the Helma-user
mailing list