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
a9d739a7
Commit
a9d739a7
authored
Nov 21, 2009
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Refactor Exceptions from Query and AST\InputParameter into QueryException class.
parent
26a2ec2e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
9 deletions
+20
-9
Query.php
lib/Doctrine/ORM/Query.php
+2
-2
InputParameter.php
lib/Doctrine/ORM/Query/AST/InputParameter.php
+1
-4
QueryException.php
lib/Doctrine/ORM/Query/QueryException.php
+16
-2
QueryTest.php
tests/Doctrine/Tests/ORM/Functional/QueryTest.php
+1
-1
No files found.
lib/Doctrine/ORM/Query.php
View file @
a9d739a7
...
...
@@ -209,12 +209,12 @@ final class Query extends AbstractQuery
$paramMappings
=
$this
->
_parserResult
->
getParameterMappings
();
if
(
count
(
$paramMappings
)
!=
count
(
$params
))
{
throw
new
QueryException
(
"Invalid parameter number: number of bound variables does not match number of tokens"
);
throw
QueryException
::
invalidParameterNumber
(
);
}
foreach
(
$params
as
$key
=>
$value
)
{
if
(
!
isset
(
$paramMappings
[
$key
]))
{
throw
new
QueryException
(
"Invalid parameter: token "
.
$key
.
" is not defined in the query."
);
throw
QueryException
::
unknownParameter
(
$key
);
}
if
(
is_object
(
$value
))
{
...
...
lib/Doctrine/ORM/Query/AST/InputParameter.php
View file @
a9d739a7
...
...
@@ -43,10 +43,7 @@ class InputParameter extends Node
public
function
__construct
(
$value
)
{
if
(
strlen
(
$value
)
==
1
)
{
throw
new
\InvalidArgumentException
(
"Invalid parameter format, '"
.
$value
.
"' given, "
.
"but :<name> or ?<num> expected."
);
throw
\Doctrine\ORM\Query\QueryException
::
invalidParameterFormat
(
$value
);
}
$param
=
substr
(
$value
,
1
);
...
...
lib/Doctrine/ORM/Query/QueryException.php
View file @
a9d739a7
...
...
@@ -34,12 +34,11 @@ namespace Doctrine\ORM\Query;
*/
class
QueryException
extends
\Doctrine\Common\DoctrineException
{
public
static
function
syntaxError
(
$message
)
public
static
function
syntaxError
(
$message
)
{
return
new
self
(
'[Syntax Error] '
.
$message
);
}
public
static
function
semanticalError
(
$message
)
{
return
new
self
(
'[Semantical Error] '
.
$message
);
...
...
@@ -49,4 +48,19 @@ class QueryException extends \Doctrine\Common\DoctrineException
{
return
new
self
(
'Invalid parameter position: '
.
$pos
);
}
public
static
function
invalidParameterNumber
()
{
return
new
self
(
"Invalid parameter number: number of bound variables does not match number of tokens"
);
}
public
static
function
invalidParameterFormat
(
$value
)
{
return
new
self
(
'Invalid parameter format, '
.
$value
.
' given, but :<name> or ?<num> expected.'
);
}
public
static
function
unknownParameter
(
$key
)
{
return
new
self
(
"Invalid parameter: token "
.
$key
.
" is not defined in the query."
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Functional/QueryTest.php
View file @
a9d739a7
...
...
@@ -130,7 +130,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
public
function
testInvalidInputParameterThrowsException
()
{
$this
->
setExpectedException
(
"
InvalidArgument
Exception"
);
$this
->
setExpectedException
(
"
Doctrine\ORM\Query\Query
Exception"
);
$q
=
$this
->
_em
->
createQuery
(
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?'
);
$q
->
setParameter
(
1
,
'jwage'
);
...
...
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