Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
4b39705c
Commit
4b39705c
authored
Apr 15, 2010
by
Roman S. Borschel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed case-sensitivity of custom DQL functions.
parent
01c2c06b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
Configuration.php
lib/Doctrine/ORM/Configuration.php
+12
-3
Parser.php
lib/Doctrine/ORM/Query/Parser.php
+12
-9
No files found.
lib/Doctrine/ORM/Configuration.php
View file @
4b39705c
...
@@ -339,6 +339,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -339,6 +339,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
* Such a function can then be used in any DQL statement in any place where string
* Such a function can then be used in any DQL statement in any place where string
* functions are allowed.
* functions are allowed.
*
*
* DQL function names are case-insensitive.
*
* @param string $name
* @param string $name
* @param string $className
* @param string $className
*/
*/
...
@@ -355,6 +357,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -355,6 +357,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/
*/
public
function
getCustomStringFunction
(
$name
)
public
function
getCustomStringFunction
(
$name
)
{
{
$name
=
strtolower
(
$name
);
return
isset
(
$this
->
_attributes
[
'customStringFunctions'
][
$name
])
?
return
isset
(
$this
->
_attributes
[
'customStringFunctions'
][
$name
])
?
$this
->
_attributes
[
'customStringFunctions'
][
$name
]
:
null
;
$this
->
_attributes
[
'customStringFunctions'
][
$name
]
:
null
;
}
}
...
@@ -371,7 +374,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -371,7 +374,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/
*/
public
function
setCustomStringFunctions
(
array
$functions
)
public
function
setCustomStringFunctions
(
array
$functions
)
{
{
$this
->
_attributes
[
'customStringFunctions'
]
=
$functions
;
$this
->
_attributes
[
'customStringFunctions'
]
=
array_change_key_case
(
$functions
)
;
}
}
/**
/**
...
@@ -379,6 +382,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -379,6 +382,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
* Such a function can then be used in any DQL statement in any place where numeric
* Such a function can then be used in any DQL statement in any place where numeric
* functions are allowed.
* functions are allowed.
*
*
* DQL function names are case-insensitive.
*
* @param string $name
* @param string $name
* @param string $className
* @param string $className
*/
*/
...
@@ -395,6 +400,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -395,6 +400,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/
*/
public
function
getCustomNumericFunction
(
$name
)
public
function
getCustomNumericFunction
(
$name
)
{
{
$name
=
strtolower
(
$name
);
return
isset
(
$this
->
_attributes
[
'customNumericFunctions'
][
$name
])
?
return
isset
(
$this
->
_attributes
[
'customNumericFunctions'
][
$name
])
?
$this
->
_attributes
[
'customNumericFunctions'
][
$name
]
:
null
;
$this
->
_attributes
[
'customNumericFunctions'
][
$name
]
:
null
;
}
}
...
@@ -411,7 +417,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -411,7 +417,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/
*/
public
function
setCustomNumericFunctions
(
array
$functions
)
public
function
setCustomNumericFunctions
(
array
$functions
)
{
{
$this
->
_attributes
[
'customNumericFunctions'
]
=
$functions
;
$this
->
_attributes
[
'customNumericFunctions'
]
=
array_change_key_case
(
$functions
)
;
}
}
/**
/**
...
@@ -419,6 +425,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -419,6 +425,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
* Such a function can then be used in any DQL statement in any place where date/time
* Such a function can then be used in any DQL statement in any place where date/time
* functions are allowed.
* functions are allowed.
*
*
* DQL function names are case-insensitive.
*
* @param string $name
* @param string $name
* @param string $className
* @param string $className
*/
*/
...
@@ -435,6 +443,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -435,6 +443,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/
*/
public
function
getCustomDatetimeFunction
(
$name
)
public
function
getCustomDatetimeFunction
(
$name
)
{
{
$name
=
strtolower
(
$name
);
return
isset
(
$this
->
_attributes
[
'customDatetimeFunctions'
][
$name
])
?
return
isset
(
$this
->
_attributes
[
'customDatetimeFunctions'
][
$name
])
?
$this
->
_attributes
[
'customDatetimeFunctions'
][
$name
]
:
null
;
$this
->
_attributes
[
'customDatetimeFunctions'
][
$name
]
:
null
;
}
}
...
@@ -451,6 +460,6 @@ class Configuration extends \Doctrine\DBAL\Configuration
...
@@ -451,6 +460,6 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/
*/
public
function
setCustomDatetimeFunctions
(
array
$functions
)
public
function
setCustomDatetimeFunctions
(
array
$functions
)
{
{
$this
->
_attributes
[
'customDatetimeFunctions'
]
=
$functions
;
$this
->
_attributes
[
'customDatetimeFunctions'
]
=
array_change_key_case
(
$functions
)
;
}
}
}
}
\ No newline at end of file
lib/Doctrine/ORM/Query/Parser.php
View file @
4b39705c
...
@@ -2619,9 +2619,10 @@ class Parser
...
@@ -2619,9 +2619,10 @@ class Parser
public
function
CustomFunctionsReturningNumerics
()
public
function
CustomFunctionsReturningNumerics
()
{
{
$funcNameLower
=
strtolower
(
$this
->
_lexer
->
lookahead
[
'value'
]);
$funcName
=
strtolower
(
$this
->
_lexer
->
lookahead
[
'value'
]);
$funcClass
=
$this
->
_em
->
getConfiguration
()
->
getCustomNumericFunction
(
$funcNameLower
);
// getCustomNumericFunction is case-insensitive
$function
=
new
$funcClass
(
$funcNameLower
);
$funcClass
=
$this
->
_em
->
getConfiguration
()
->
getCustomNumericFunction
(
$funcName
);
$function
=
new
$funcClass
(
$funcName
);
$function
->
parse
(
$this
);
$function
->
parse
(
$this
);
return
$function
;
return
$function
;
...
@@ -2642,9 +2643,10 @@ class Parser
...
@@ -2642,9 +2643,10 @@ class Parser
public
function
CustomFunctionsReturningDatetime
()
public
function
CustomFunctionsReturningDatetime
()
{
{
$funcNameLower
=
strtolower
(
$this
->
_lexer
->
lookahead
[
'value'
]);
$funcName
=
$this
->
_lexer
->
lookahead
[
'value'
];
$funcClass
=
$this
->
_em
->
getConfiguration
()
->
getCustomDatetimeFunction
(
$funcNameLower
);
// getCustomDatetimeFunction is case-insensitive
$function
=
new
$funcClass
(
$funcNameLower
);
$funcClass
=
$this
->
_em
->
getConfiguration
()
->
getCustomDatetimeFunction
(
$funcName
);
$function
=
new
$funcClass
(
$funcName
);
$function
->
parse
(
$this
);
$function
->
parse
(
$this
);
return
$function
;
return
$function
;
...
@@ -2670,9 +2672,10 @@ class Parser
...
@@ -2670,9 +2672,10 @@ class Parser
public
function
CustomFunctionsReturningStrings
()
public
function
CustomFunctionsReturningStrings
()
{
{
$funcNameLower
=
strtolower
(
$this
->
_lexer
->
lookahead
[
'value'
]);
$funcName
=
$this
->
_lexer
->
lookahead
[
'value'
];
$funcClass
=
$this
->
_em
->
getConfiguration
()
->
getCustomStringFunction
(
$funcNameLower
);
// getCustomStringFunction is case-insensitive
$function
=
new
$funcClass
(
$funcNameLower
);
$funcClass
=
$this
->
_em
->
getConfiguration
()
->
getCustomStringFunction
(
$funcName
);
$function
=
new
$funcClass
(
$funcName
);
$function
->
parse
(
$this
);
$function
->
parse
(
$this
);
return
$function
;
return
$function
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment