prisma-client-php 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -64,6 +64,10 @@ final class PPHPUtility
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (is_string($key) && is_array($value)) {
|
|
67
|
+
if (self::isAtomicOperationArray($value)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
67
71
|
if (isset($value['select'])) {
|
|
68
72
|
$relatedEntityFields[$key] = $value['select'];
|
|
69
73
|
} elseif (isset($value['include'])) {
|
|
@@ -155,6 +159,10 @@ final class PPHPUtility
|
|
|
155
159
|
continue;
|
|
156
160
|
}
|
|
157
161
|
|
|
162
|
+
if (self::isAtomicOperationArray($value)) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
|
|
158
166
|
$isRelatedModel = false;
|
|
159
167
|
foreach ($fields as $field) {
|
|
160
168
|
$isObject = ($field['kind'] ?? null) === 'object';
|
|
@@ -190,6 +198,17 @@ final class PPHPUtility
|
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
|
|
201
|
+
private static function isAtomicOperationArray(array $arr): bool
|
|
202
|
+
{
|
|
203
|
+
$atomicOps = ['increment', 'decrement', 'multiply', 'divide'];
|
|
204
|
+
foreach ($arr as $key => $value) {
|
|
205
|
+
if (in_array($key, $atomicOps, true)) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
193
212
|
private static function fieldExists(string $key, array $fields): bool
|
|
194
213
|
{
|
|
195
214
|
foreach ($fields as $field) {
|
|
@@ -344,7 +363,23 @@ final class PPHPUtility
|
|
|
344
363
|
|
|
345
364
|
private static function isOperatorArray(array $arr)
|
|
346
365
|
{
|
|
347
|
-
$operators = [
|
|
366
|
+
$operators = [
|
|
367
|
+
'contains',
|
|
368
|
+
'startsWith',
|
|
369
|
+
'endsWith',
|
|
370
|
+
'equals',
|
|
371
|
+
'not',
|
|
372
|
+
'gt',
|
|
373
|
+
'gte',
|
|
374
|
+
'lt',
|
|
375
|
+
'lte',
|
|
376
|
+
'in',
|
|
377
|
+
'notIn',
|
|
378
|
+
'increment',
|
|
379
|
+
'decrement',
|
|
380
|
+
'multiply',
|
|
381
|
+
'divide'
|
|
382
|
+
];
|
|
348
383
|
foreach ($arr as $key => $value) {
|
|
349
384
|
if (!in_array($key, $operators)) {
|
|
350
385
|
return false;
|
|
@@ -1185,8 +1220,23 @@ final class PPHPUtility
|
|
|
1185
1220
|
}
|
|
1186
1221
|
break;
|
|
1187
1222
|
case 'update':
|
|
1188
|
-
$
|
|
1189
|
-
|
|
1223
|
+
if (!empty($modelRelatedFromFields) && !empty($modelRelatedToFields)) {
|
|
1224
|
+
$relatedResult = $relatedClass->update([
|
|
1225
|
+
'where' => $op['where'],
|
|
1226
|
+
'data' => $op['data']
|
|
1227
|
+
]);
|
|
1228
|
+
} else {
|
|
1229
|
+
if (!isset($op[$modelRelatedFieldType])) {
|
|
1230
|
+
throw new Exception(
|
|
1231
|
+
"Expected '{$modelRelatedFieldType}' key in update operation for implicit relation '{$relatedFieldName}'."
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
$relatedFieldData = $op[$modelRelatedFieldType];
|
|
1235
|
+
$relatedResult = $relatedClass->update([
|
|
1236
|
+
'where' => $relatedFieldData['where'],
|
|
1237
|
+
'data' => $relatedFieldData['data']
|
|
1238
|
+
]);
|
|
1239
|
+
}
|
|
1190
1240
|
break;
|
|
1191
1241
|
case 'updateMany':
|
|
1192
1242
|
if ($isExplicitOneToMany) {
|
package/package.json
CHANGED