UPDATE: Ignore everything in this post. It is incorrect. See the second post after this one.
==== IGNORE THIS ====
I looked into it. There is a bug of sorts, that exists between PHP and DataMapper.
When you look up an Object, DM figures out what you want using the __get() magic method. This method is only called if the specified property (in this case, the related model) doesn’t already exist.
When you call ->delete($obj), DataMapper assumes you want to remove the object as well. So, it calls unset() on the property. However, apparently PHP doesn’t consider an unset() property the same thing as one that doesn’t exist.
So, enough with the technical explanation. To fix it, I recommend this. Go to line 2419 or so, and replace this line:
unset($this->{$object->model});
with this one:
$this->{$object->model}->clear();
This should fix the problem, while still clearing out the related object.
UPDATE Question:
What version of PHP are you running? I tested it on mine, and PHP 5.2.6 had no problem calling the __get method after an unset.
UPDATE 2
One more: you actually have a mistake in your example code! You are calling sch->school, but you mean sch->student. That’s your error.