1
0
mirror of synced 2025-03-17 13:33:52 +03:00

[2.0] Fixed custom functions support that was failing to be processed. Also fixed syntax error of Function support.

This commit is contained in:
guilhermeblanco 2010-03-16 14:01:54 +00:00
parent 90103bc604
commit 0fde94ddcf
2 changed files with 21 additions and 12 deletions

View File

@ -302,10 +302,10 @@ abstract class AssociationMapping
public function hasCascades() public function hasCascades()
{ {
return $this->isCascadePersist || return $this->isCascadePersist ||
$this->isCascadeRemove || $this->isCascadeRemove ||
$this->isCascadeRefresh || $this->isCascadeRefresh ||
$this->isCascadeMerge || $this->isCascadeMerge ||
$this->isCascadeDetach; $this->isCascadeDetach;
} }
/** /**
@ -328,9 +328,9 @@ abstract class AssociationMapping
*/ */
public function getQuotedJoinTableName($platform) public function getQuotedJoinTableName($platform)
{ {
return isset($this->joinTable['quoted']) ? return isset($this->joinTable['quoted'])
$platform->quoteIdentifier($this->joinTable['name']) : ? $platform->quoteIdentifier($this->joinTable['name'])
$this->joinTable['name']; : $this->joinTable['name'];
} }
} }

View File

@ -2558,7 +2558,8 @@ class Parser
*/ */
public function FunctionDeclaration() public function FunctionDeclaration()
{ {
$funcName = strtolower($this->_lexer->lookahead['value']); $token = $this->_lexer->lookahead;
$funcName = strtolower($token['value']);
// Check for built-in functions first! // Check for built-in functions first!
if (isset(self::$_STRING_FUNCTIONS[$funcName])) { if (isset(self::$_STRING_FUNCTIONS[$funcName])) {
@ -2568,17 +2569,25 @@ class Parser
} else if (isset(self::$_DATETIME_FUNCTIONS[$funcName])) { } else if (isset(self::$_DATETIME_FUNCTIONS[$funcName])) {
return $this->FunctionsReturningDatetime(); return $this->FunctionsReturningDatetime();
} }
// Check for custom functions afterwards // Check for custom functions afterwards
$config = $this->_em->getConfiguration(); $config = $this->_em->getConfiguration();
if ($config->getCustomStringFunction($funcName) !== null) {
if (($func = $config->getCustomStringFunction($funcName)) !== null) {
self::$_STRING_FUNCTIONS[$funcName] = $func;
return $this->FunctionsReturningStrings(); return $this->FunctionsReturningStrings();
} else if ($config->getCustomNumericFunction($funcName) !== null) { } else if (($func = $config->getCustomNumericFunction($funcName)) !== null) {
self::$_NUMERIC_FUNCTIONS[$funcName] = $func;
return $this->FunctionsReturningNumerics(); return $this->FunctionsReturningNumerics();
} else if ($config->getCustomDatetimeFunction($funcName) !== null) { } else if (($func = $config->getCustomDatetimeFunction($funcName)) !== null) {
self::$_DATETIME_FUNCTIONS[$funcName] = $func;
return $this->FunctionsReturningDatetime(); return $this->FunctionsReturningDatetime();
} }
$this->syntaxError('Known function.', $funcName); $this->syntaxError('known function', $token);
} }
/** /**