OQL: Fixed a number of bugs, and implemented new features

- bug: a JOIN b on b.extkey = a.id
- bug: operators precedence (still a shift-reduce conflict with JOINS)
- changed pkey into id (preserved the compatibility for DBObjectSearch::AddCondition()
- allow implicit class name in WHERE condition
- bug: wrong report on typo error
- suggest an alternative in case of typo error

SVN:code[12]
This commit is contained in:
Romain Quetiez
2009-03-27 14:36:14 +00:00
parent a0f4fdb130
commit 8d9ea9dcdd
15 changed files with 989 additions and 612 deletions

View File

@@ -22,6 +22,8 @@ abstract class Expression
// recursively builds an array of class => fieldname
abstract public function ListRequiredFields();
abstract public function IsTrue();
public function RequiresField($sClass, $sFieldName)
{
// #@# todo - optimize : this is called quite often when building a single query !
@@ -50,6 +52,8 @@ abstract class Expression
public function LogAnd($oExpr)
{
if ($this->IsTrue()) return clone $oExpr;
if ($oExpr->IsTrue()) return clone $this;
return new BinaryExpression($this, 'AND', $oExpr);
}
@@ -57,7 +61,6 @@ abstract class Expression
{
return new BinaryExpression($this, 'OR', $oExpr);
}
}
@@ -90,6 +93,16 @@ class BinaryExpression extends Expression
$this->m_sOperator = $sOperator;
}
public function IsTrue()
{
// return true if we are certain that it will be true
if ($this->m_sOperator == 'AND')
{
if ($this->m_oLeftExpr->IsTrue() && $this->m_oLeftExpr->IsTrue()) return true;
}
return false;
}
public function GetLeftExpr()
{
return $this->m_oLeftExpr;
@@ -139,6 +152,12 @@ class UnaryExpression extends Expression
$this->m_value = $value;
}
public function IsTrue()
{
// return true if we are certain that it will be true
return ($this->m_value == 1);
}
public function GetValue()
{
return $this->m_value;
@@ -179,6 +198,11 @@ class TrueExpression extends ScalarExpression
{
parent::__construct(1);
}
public function IsTrue()
{
return true;
}
}
class FieldExpression extends UnaryExpression
@@ -194,6 +218,12 @@ class FieldExpression extends UnaryExpression
$this->m_sName = $sName;
}
public function IsTrue()
{
// return true if we are certain that it will be true
return false;
}
public function GetParent() {return $this->m_sParent;}
public function GetName() {return $this->m_sName;}
@@ -251,6 +281,12 @@ class ListExpression extends Expression
$this->m_aExpressions = $aExpressions;
}
public function IsTrue()
{
// return true if we are certain that it will be true
return false;
}
public function GetItems()
{
return $this->m_aExpressions;
@@ -300,6 +336,12 @@ class FunctionExpression extends Expression
$this->m_aArgs = $aArgExpressions;
}
public function IsTrue()
{
// return true if we are certain that it will be true
return false;
}
public function GetVerb()
{
return $this->m_sVerb;
@@ -353,6 +395,12 @@ class IntervalExpression extends Expression
$this->m_sUnit = $sUnit;
}
public function IsTrue()
{
// return true if we are certain that it will be true
return false;
}
public function GetValue()
{
return $this->m_oValue;
@@ -389,6 +437,12 @@ class CharConcatExpression extends Expression
$this->m_aExpressions = $aExpressions;
}
public function IsTrue()
{
// return true if we are certain that it will be true
return false;
}
public function GetItems()
{
return $this->m_aExpressions;