[coldbox-3.5.2] ormService.get() when ID = 0 or empty string

From the doc’s it says “You can also pass an id = 0 and the service will return to you a new entity” which is true but if you pass an id = 0 (zero) as opposed to id = “” (empty string) the get() method performs a wasted database SELECT according to the console.

Unless I’ve misunderstood the logic, may I suggest that line 436 of BaseORMService.cfc is changed from…

if( (isSimpleValue(arguments.id) and len(arguments.id)) OR NOT isSimpleValue(arguments.id) ){
if( (isSimpleValue(arguments.id) and len(arguments.id) and arguments.id neq 0) OR NOT isSimpleValue(arguments.id) ){



No that should not be the case, the problem with this is if someone is using ORM on a legacy database. Id of zero is a very legit number, and this change would break a very small percentage of databases.

Identity seeds are allowed to start at 0 for MS SQl, not sure bout other databases.

Okay, so if that is the case may I suggest that the doc’s be updated not to suggest using a zero to return an new entity.

Do you have a link for that, as I am curious to see if it states that or it states that if it can’t find the record will return a new record, and was using zero as an example.

If that is not the case, then yeah the docs will need to be updated.

Sure, here you go…