public function testExpressions()
{
$a = ['user' => [1 => ['id' => 1, 'name' => 'John', 'surname' => 'Smith', 'cached_name' => 'John Smith'], 2 => ['id' => 2, 'name' => 'Sue', 'surname' => 'Sue', 'cached_name' => 'ERROR']]];
$this->setDB($a);
$db = new Persistence_SQL($this->db->connection);
$m = new Model($db, 'user');
$m->addFields(['name', 'surname', 'cached_name']);
$m->addExpression('full_name', '[name] || " " || [surname]');
$m->addCondition($m->expr('[full_name] != [cached_name]'));
$this->assertEquals('select `id`,`name`,`surname`,`cached_name`,(`name` || " " || `surname`) `full_name` from `user` where (`name` || " " || `surname`) != `cached_name`', $m->action('select')->render());
$m->tryLoad(1);
$this->assertEquals(null, $m['name']);
$m->tryLoad(2);
$this->assertEquals('Sue', $m['name']);
}