prisma-client-php 2.3.4 → 2.3.5

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.
@@ -121,6 +121,8 @@ final class PPHPUtility
121
121
  */
122
122
  public static function checkFieldsExist(array $select, array $fields, string $modelName)
123
123
  {
124
+ $virtualFields = ['_count', '_max', '_min', '_avg', '_sum'];
125
+
124
126
  foreach ($select as $key => $value) {
125
127
  if (is_numeric($key) && is_string($value)) {
126
128
  if (self::fieldExists($key, $fields))
@@ -129,11 +131,13 @@ final class PPHPUtility
129
131
 
130
132
  if (isset($value) && empty($value) || !is_bool($value)) {
131
133
  if (is_string($key) && !self::fieldExists($key, $fields)) {
134
+ if (in_array($key, $virtualFields)) {
135
+ continue;
136
+ }
132
137
  throw new Exception("The field '$key' does not exist in the $modelName model.");
133
138
  }
134
139
 
135
140
  if (is_array($value) && !empty($value)) {
136
-
137
141
  $isRelatedModel = false;
138
142
 
139
143
  foreach ($fields as $field) {
@@ -162,6 +166,9 @@ final class PPHPUtility
162
166
  foreach (explode(',', $key) as $fieldName) {
163
167
  $fieldName = trim($fieldName);
164
168
  if (!self::fieldExists($fieldName, $fields)) {
169
+ if (in_array($fieldName, $virtualFields)) {
170
+ continue;
171
+ }
165
172
  throw new Exception("The field '$fieldName' does not exist in the $modelName model.");
166
173
  }
167
174
  }
@@ -219,13 +226,15 @@ final class PPHPUtility
219
226
  */
220
227
  public static function checkIncludes(array $include, array &$relatedEntityFields, array &$includes, array $fields, string $modelName)
221
228
  {
229
+ $virtualFields = ['_count', '_max', '_min', '_avg', '_sum'];
230
+
222
231
  if (isset($include) && is_array($include)) {
223
232
  foreach ($include as $key => $value) {
224
233
  if (is_array($value) && array_key_exists('join.type', $value)) {
225
234
  continue;
226
235
  }
227
236
 
228
- if ($key === '_count' && is_array($value) && array_key_exists('select', $value)) {
237
+ if (in_array($key, $virtualFields)) {
229
238
  $includes[$key] = $value;
230
239
  continue;
231
240
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prisma-client-php",
3
3
  "description": "Prisma Client PHP is an auto-generated query builder that enables type-safe database access in PHP.",
4
- "version": "2.3.4",
4
+ "version": "2.3.5",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {