@@ -6,6 +6,12 @@ import { noop } from "@proto-kit/common";
6
6
import type { PrismaConnection } from "../../PrismaDatabaseConnection" ;
7
7
import { injectable } from "tsyringe" ;
8
8
9
+ // We need to create a correctly configured Decimal constructor
10
+ // with our parameters
11
+ const Decimal = Prisma . Decimal . clone ( {
12
+ precision : 78 ,
13
+ } ) ;
14
+
9
15
@injectable ( )
10
16
export class PrismaStateService implements AsyncStateService {
11
17
private cache : StateEntry [ ] = [ ] ;
@@ -25,18 +31,16 @@ export class PrismaStateService implements AsyncStateService {
25
31
const data = this . cache
26
32
. filter ( ( entry ) => entry . value !== undefined )
27
33
. map ( ( entry ) => ( {
28
- path : new Prisma . Decimal ( entry . key . toString ( ) ) ,
29
- values : entry . value ! . map (
30
- ( field ) => new Prisma . Decimal ( field . toString ( ) )
31
- ) ,
34
+ path : new Decimal ( entry . key . toString ( ) ) ,
35
+ values : entry . value ! . map ( ( field ) => new Decimal ( field . toString ( ) ) ) ,
32
36
mask : this . mask ,
33
37
} ) ) ;
34
38
35
39
await prismaClient . $transaction ( [
36
40
prismaClient . state . deleteMany ( {
37
41
where : {
38
42
path : {
39
- in : this . cache . map ( ( x ) => new Prisma . Decimal ( x . key . toString ( ) ) ) ,
43
+ in : this . cache . map ( ( x ) => new Decimal ( x . key . toString ( ) ) ) ,
40
44
} ,
41
45
mask : this . mask ,
42
46
} ,
@@ -55,7 +59,7 @@ export class PrismaStateService implements AsyncStateService {
55
59
AND : [
56
60
{
57
61
path : {
58
- in : keys . map ( ( key ) => new Prisma . Decimal ( key . toString ( ) ) ) ,
62
+ in : keys . map ( ( key ) => new Decimal ( key . toString ( ) ) ) ,
59
63
} ,
60
64
} ,
61
65
{
@@ -65,8 +69,8 @@ export class PrismaStateService implements AsyncStateService {
65
69
} ,
66
70
} ) ;
67
71
return records . map ( ( record ) => ( {
68
- key : Field ( record . path . toNumber ( ) ) ,
69
- value : record . values . map ( ( x ) => Field ( x . toString ( ) ) ) ,
72
+ key : Field ( record . path . toFixed ( ) ) ,
73
+ value : record . values . map ( ( x ) => Field ( x . toFixed ( ) ) ) ,
70
74
} ) ) ;
71
75
}
72
76
0 commit comments