|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the MIT license. For more information, see |
|
17
|
|
|
* <http://www.doctrine-project.org>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Doctrine\ORM\Query; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Description of QueryException. |
|
24
|
|
|
* |
|
25
|
|
|
* @link www.doctrine-project.org |
|
26
|
|
|
* @since 2.0 |
|
27
|
|
|
* @author Guilherme Blanco <[email protected]> |
|
28
|
|
|
* @author Jonathan Wage <[email protected]> |
|
29
|
|
|
* @author Roman Borschel <[email protected]> |
|
30
|
|
|
* @author Benjamin Eberlei <[email protected]> |
|
31
|
|
|
*/ |
|
32
|
|
|
class QueryException extends \Doctrine\ORM\ORMException |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @param string $dql |
|
36
|
|
|
* |
|
37
|
|
|
* @return QueryException |
|
38
|
|
|
*/ |
|
39
|
49 |
|
public static function dqlError($dql) |
|
40
|
|
|
{ |
|
41
|
49 |
|
return new self($dql); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param string $message |
|
46
|
|
|
* @param \Exception|null $previous |
|
47
|
|
|
* |
|
48
|
|
|
* @return QueryException |
|
49
|
|
|
*/ |
|
50
|
17 |
|
public static function syntaxError($message, $previous = null) |
|
51
|
|
|
{ |
|
52
|
17 |
|
return new self('[Syntax Error] ' . $message, 0, $previous); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param string $message |
|
57
|
|
|
* @param \Exception|null $previous |
|
58
|
|
|
* |
|
59
|
|
|
* @return QueryException |
|
60
|
|
|
*/ |
|
61
|
33 |
|
public static function semanticalError($message, $previous = null) |
|
62
|
|
|
{ |
|
63
|
33 |
|
return new self('[Semantical Error] ' . $message, 0, $previous); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return QueryException |
|
68
|
|
|
*/ |
|
69
|
|
|
public static function invalidLockMode() |
|
70
|
|
|
{ |
|
71
|
|
|
return new self('Invalid lock mode hint provided.'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param string $expected |
|
76
|
|
|
* @param string $received |
|
77
|
|
|
* |
|
78
|
|
|
* @return QueryException |
|
79
|
|
|
*/ |
|
80
|
|
|
public static function invalidParameterType($expected, $received) |
|
81
|
|
|
{ |
|
82
|
|
|
return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.'); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @param string $pos |
|
87
|
|
|
* |
|
88
|
|
|
* @return QueryException |
|
89
|
|
|
*/ |
|
90
|
|
|
public static function invalidParameterPosition($pos) |
|
91
|
|
|
{ |
|
92
|
|
|
return new self('Invalid parameter position: ' . $pos); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param integer $expected |
|
97
|
|
|
* @param integer $received |
|
98
|
|
|
* |
|
99
|
|
|
* @return QueryException |
|
100
|
|
|
*/ |
|
101
|
1 |
|
public static function tooManyParameters($expected, $received) |
|
102
|
|
|
{ |
|
103
|
1 |
|
return new self('Too many parameters: the query defines ' . $expected . ' parameters and you bound ' . $received); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param integer $expected |
|
108
|
|
|
* @param integer $received |
|
109
|
|
|
* |
|
110
|
|
|
* @return QueryException |
|
111
|
|
|
*/ |
|
112
|
1 |
|
public static function tooFewParameters($expected, $received) |
|
113
|
|
|
{ |
|
114
|
1 |
|
return new self('Too few parameters: the query defines ' . $expected . ' parameters but you only bound ' . $received); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @param string $value |
|
119
|
|
|
* |
|
120
|
|
|
* @return QueryException |
|
121
|
|
|
*/ |
|
122
|
2 |
|
public static function invalidParameterFormat($value) |
|
123
|
|
|
{ |
|
124
|
2 |
|
return new self('Invalid parameter format, '.$value.' given, but :<name> or ?<num> expected.'); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @param string $key |
|
129
|
|
|
* |
|
130
|
|
|
* @return QueryException |
|
131
|
|
|
*/ |
|
132
|
1 |
|
public static function unknownParameter($key) |
|
133
|
|
|
{ |
|
134
|
1 |
|
return new self("Invalid parameter: token ".$key." is not defined in the query."); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return QueryException |
|
139
|
|
|
*/ |
|
140
|
|
|
public static function parameterTypeMismatch() |
|
141
|
|
|
{ |
|
142
|
|
|
return new self("DQL Query parameter and type numbers mismatch, but have to be exactly equal."); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @param object $pathExpr |
|
147
|
|
|
* |
|
148
|
|
|
* @return QueryException |
|
149
|
|
|
*/ |
|
150
|
|
|
public static function invalidPathExpression($pathExpr) |
|
151
|
|
|
{ |
|
152
|
|
|
return new self( |
|
153
|
|
|
"Invalid PathExpression '" . $pathExpr->identificationVariable . "." . $pathExpr->field . "'." |
|
154
|
|
|
); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @param string $literal |
|
159
|
|
|
* |
|
160
|
|
|
* @return QueryException |
|
161
|
|
|
*/ |
|
162
|
|
|
public static function invalidLiteral($literal) |
|
163
|
|
|
{ |
|
164
|
|
|
return new self("Invalid literal '$literal'"); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @param array $assoc |
|
169
|
|
|
* |
|
170
|
|
|
* @return QueryException |
|
171
|
|
|
*/ |
|
172
|
|
|
public static function iterateWithFetchJoinCollectionNotAllowed($assoc) |
|
173
|
|
|
{ |
|
174
|
|
|
return new self( |
|
175
|
|
|
"Invalid query operation: Not allowed to iterate over fetch join collections ". |
|
176
|
|
|
"in class ".$assoc['sourceEntity']." association ".$assoc['fieldName'] |
|
177
|
|
|
); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @return QueryException |
|
182
|
|
|
*/ |
|
183
|
|
|
public static function partialObjectsAreDangerous() |
|
184
|
|
|
{ |
|
185
|
|
|
return new self( |
|
186
|
|
|
"Loading partial objects is dangerous. Fetch full objects or consider " . |
|
187
|
|
|
"using a different fetch mode. If you really want partial objects, " . |
|
188
|
|
|
"set the doctrine.forcePartialLoad query hint to TRUE." |
|
189
|
|
|
); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @param array $assoc |
|
194
|
|
|
* |
|
195
|
|
|
* @return QueryException |
|
196
|
|
|
*/ |
|
197
|
|
|
public static function overwritingJoinConditionsNotYetSupported($assoc) |
|
198
|
|
|
{ |
|
199
|
|
|
return new self( |
|
200
|
|
|
"Unsupported query operation: It is not yet possible to overwrite the join ". |
|
201
|
|
|
"conditions in class ".$assoc['sourceEntityName']." association ".$assoc['fieldName'].". ". |
|
202
|
|
|
"Use WITH to append additional join conditions to the association." |
|
203
|
|
|
); |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* @return QueryException |
|
208
|
|
|
*/ |
|
209
|
2 |
|
public static function associationPathInverseSideNotSupported() |
|
210
|
|
|
{ |
|
211
|
2 |
|
return new self( |
|
212
|
|
|
"A single-valued association path expression to an inverse side is not supported". |
|
213
|
2 |
|
" in DQL queries. Use an explicit join instead." |
|
214
|
|
|
); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* @param array $assoc |
|
219
|
|
|
* |
|
220
|
|
|
* @return QueryException |
|
221
|
|
|
*/ |
|
222
|
3 |
|
public static function iterateWithFetchJoinNotAllowed($assoc) |
|
223
|
|
|
{ |
|
224
|
3 |
|
return new self( |
|
225
|
3 |
|
"Iterate with fetch join in class " . $assoc['sourceEntity'] . |
|
226
|
3 |
|
" using association " . $assoc['fieldName'] . " not allowed." |
|
227
|
|
|
); |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* @return QueryException |
|
232
|
|
|
*/ |
|
233
|
1 |
|
public static function associationPathCompositeKeyNotSupported() |
|
234
|
|
|
{ |
|
235
|
1 |
|
return new self( |
|
236
|
|
|
"A single-valued association path expression to an entity with a composite primary ". |
|
237
|
|
|
"key is not supported. Explicitly name the components of the composite primary key ". |
|
238
|
1 |
|
"in the query." |
|
239
|
|
|
); |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* @param string $className |
|
244
|
|
|
* @param string $rootClass |
|
245
|
|
|
* |
|
246
|
|
|
* @return QueryException |
|
247
|
|
|
*/ |
|
248
|
1 |
|
public static function instanceOfUnrelatedClass($className, $rootClass) |
|
249
|
|
|
{ |
|
250
|
1 |
|
return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " . |
|
251
|
1 |
|
"inheritance hierarchy does not exists between these two classes."); |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* @param string $dqlAlias |
|
256
|
|
|
* |
|
257
|
|
|
* @return QueryException |
|
258
|
|
|
*/ |
|
259
|
1 |
|
public static function invalidQueryComponent($dqlAlias) |
|
260
|
|
|
{ |
|
261
|
1 |
|
return new self( |
|
262
|
1 |
|
"Invalid query component given for DQL alias '" . $dqlAlias . "', ". |
|
263
|
1 |
|
"requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys." |
|
264
|
|
|
); |
|
265
|
|
|
} |
|
266
|
|
|
} |
|
267
|
|
|
|