Closed (fixed)
Project:
Entity API
Version:
7.x-1.x-dev
Component:
Entity CRUD controller
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Jan 2011 at 01:47 UTC
Updated:
31 Jan 2011 at 21:30 UTC
When creating servers, they now always have a 0 status (having the nasty side effect that they can't be deleted). Weirdly enough, creating indexes works normally.
From some quick debugging I can't really tell the cause. The SQL default value for the column is 1 (and the whole definition is the same as for indexes). Right before the initial call to save(), $server->entity is NULL, as it should be. And I really have no idea where else something could go wrong. In the INSERT statement, the wrong value is already there.
Any ideas?
Comments
Comment #1
fagoWhat about is $server->entity ?
Maybe you have the status property defined in your class, such that it already exists and db default is not populated?
Comment #2
drunken monkeyOh, sorry, I meant
$server->status. This isNULLwhen I callsave(), but obviously gets changed to 0 between then and the database statement.It's defined with
public $status;, so it should beNULLif it isn't set explicitly — and, as said above, it isNULLwhen the method is called.Comment #3
fagodrupal_write_record() makes use property_exists($object, $field) - so the default won't be applied that way. So either specify the right default value for the class property too, or remove it.
Comment #4
drunken monkeyOh, wow. Doesn't seem like the most logical thing to do, but there's probably some reason for this …
Anyways, thanks a lot for finding that out, should be fixed for the Search API now.