Bug Report #2455

IS instead of = on where, JOIN with aliases

Added by Chris Fine over 4 years ago.

Status:NewStart date:12/22/2009
Priority:NormalDue date:
Assignee:Ben Rogers% Done:

0%

Category:Libraries:Database
Target version:2.4.1
Resolution: Points:

Description

Two issues here.

Issue 1 where() has '=' as default operator. That's kinda pointless if you're WHEREing a null value.

db->where('mail_read') is so much shorter than db->where('mail_read', 'IS', null) or even db->where('mail_read', 'IS').

Mysql, at least, doesn't see = NULL the same as IS NULL.

Issue 2 is table aliases on joins. You can alias column names but not tables. This is fixed. Use the same syntax.
join(array(AStable => originalTable), etc...)

Here's some code where I actually needed table aliases...

$this->dbb->select(array('m_from_name' => 'users_from.u_name'));
$this->dbb->select(array('m_to_name' => 'users_to.u_name'));
$this->dbb->join(array('users_from' => 'users'), 'm_from', 'users_from.u_id');
$this->dbb->join(array('users_to' => 'users'), 'm_to', 'users_to.u_id');

Database_Builder.php.diff Magnifier (486 Bytes) Chris Fine, 12/22/2009 02:22 PM

Database_Builder.php.old - From 2.4RC2 (19.1 KB) Chris Fine, 12/22/2009 02:22 PM

Database_Builder.php.new (19.3 KB) Chris Fine, 12/22/2009 02:22 PM

Also available in: Atom PDF