prisma-client-php 2.1.3 → 2.3.0

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.
package/dist/init.js CHANGED
@@ -189,12 +189,12 @@ const readJsonFile = (filePath) => {
189
189
  return JSON.parse(jsonData);
190
190
  };
191
191
  const npmPinnedVersions = {
192
- prisma: "^6.8.2",
193
- "@prisma/client": "^6.8.2",
194
- "@prisma/internals": "^6.8.2",
195
- tsx: "^4.19.4",
196
- typescript: "^5.8.3",
197
- "@types/node": "^22.15.18",
192
+ prisma: "^6.14.0",
193
+ "@prisma/client": "^6.14.0",
194
+ "@prisma/internals": "^6.14.0",
195
+ tsx: "^4.20.5",
196
+ typescript: "^5.9.2",
197
+ "@types/node": "^24.3.0",
198
198
  };
199
199
  function npmPkg(name) {
200
200
  return npmPinnedVersions[name] ? `${name}@${npmPinnedVersions[name]}` : name;
@@ -1543,4 +1543,68 @@ final class PPHPUtility
1543
1543
 
1544
1544
  return $clauses ? ' HAVING ' . implode(' AND ', $clauses) : '';
1545
1545
  }
1546
+
1547
+ public static function normalizeRowTypes(array $row, array $fieldsByName): array
1548
+ {
1549
+ foreach ($fieldsByName as $name => $meta) {
1550
+ if (!array_key_exists($name, $row)) {
1551
+ continue;
1552
+ }
1553
+ if (($meta['kind'] ?? null) !== 'scalar') {
1554
+ continue;
1555
+ }
1556
+
1557
+ $type = $meta['type'] ?? null;
1558
+ $row[$name] = self::normalizeValueByType($row[$name], $type);
1559
+ }
1560
+ return $row;
1561
+ }
1562
+
1563
+ public static function normalizeListTypes(array $rows, array $fieldsByName): array
1564
+ {
1565
+ foreach ($rows as $i => $row) {
1566
+ if (is_array($row)) {
1567
+ $rows[$i] = self::normalizeRowTypes($row, $fieldsByName);
1568
+ } elseif (is_object($row)) {
1569
+ $rows[$i] = (object) self::normalizeRowTypes((array) $row, $fieldsByName);
1570
+ }
1571
+ }
1572
+ return $rows;
1573
+ }
1574
+
1575
+ private static function normalizeValueByType(mixed $value, ?string $type): mixed
1576
+ {
1577
+ if ($value === null) return null;
1578
+
1579
+ switch ($type) {
1580
+ case 'Boolean':
1581
+ return self::toBool($value);
1582
+ case 'Int':
1583
+ return (int) $value;
1584
+ case 'BigInt':
1585
+ return (string) $value;
1586
+ case 'Decimal':
1587
+ return (string) $value;
1588
+ case 'DateTime':
1589
+ return Validator::dateTime($value);
1590
+ default:
1591
+ return $value;
1592
+ }
1593
+ }
1594
+
1595
+ public static function toBool(mixed $v): bool
1596
+ {
1597
+ $b = Validator::boolean($v);
1598
+ if ($b !== null) return $b;
1599
+
1600
+ if (is_numeric($v)) return ((int) $v) === 1;
1601
+
1602
+ if (is_string($v)) {
1603
+ $s = strtolower(trim($v));
1604
+ if (in_array($s, ['t', 'y', 'yes'], true)) return true;
1605
+ if (in_array($s, ['f', 'n', 'no'], true)) return false;
1606
+ }
1607
+
1608
+ return (bool) $v;
1609
+ }
1546
1610
  }
@@ -6,18 +6,18 @@ interface IModel
6
6
  {
7
7
  public function aggregate(array $operation);
8
8
  public function createMany(array $data);
9
- // public function createManyAndReturn(array $data);
9
+ public function createManyAndReturn(array $data);
10
10
  public function create(array $data);
11
11
  public function deleteMany(array $criteria);
12
12
  public function delete(array $criteria);
13
13
  public function findFirst(array $criteria);
14
- // public function findFirstOrThrow(array $criteria);
14
+ public function findFirstOrThrow(array $criteria);
15
15
  public function findMany(array $criteria);
16
16
  public function findUnique(array $criteria);
17
- // public function findUniqueOrThrow(array $criteria);
17
+ public function findUniqueOrThrow(array $criteria);
18
18
  public function groupBy(array $by);
19
19
  public function updateMany(array $data);
20
- // public function updateManyAndReturn(array $data);
20
+ public function updateManyAndReturn(array $data);
21
21
  public function update(array $data);
22
22
  public function upsert(array $data);
23
23
  public function count(array $criteria);
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.1.3",
4
+ "version": "2.3.0",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -25,7 +25,7 @@
25
25
  "prisma-client-php"
26
26
  ],
27
27
  "dependencies": {
28
- "chalk": "^5.4.1",
28
+ "chalk": "^5.6.0",
29
29
  "crypto-js": "^4.2.0"
30
30
  }
31
31
  }