Skip to content

Commit f4d8b6b

Browse files
authored
Add decimal field to test sandbox, prefer POSTGRES for sandbox (#9011)
1 parent 6084f44 commit f4d8b6b

File tree

3 files changed

+56
-26
lines changed

3 files changed

+56
-26
lines changed

tests/sandbox/configs/all-the-things.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
import { list, graphql, config, group } from '@keystone-6/core'
22
import { allowAll } from '@keystone-6/core/access'
33
import {
4+
bigInt,
5+
calendarDay,
46
checkbox,
7+
decimal,
8+
file,
9+
float,
10+
image,
11+
integer,
12+
json,
13+
multiselect,
514
password,
615
relationship,
16+
select,
717
text,
818
timestamp,
9-
file,
1019
virtual,
11-
select,
12-
json,
13-
integer,
14-
image,
15-
float,
16-
bigInt,
17-
calendarDay,
18-
multiselect,
1920
} from '@keystone-6/core/fields'
2021
import { document, structure } from '@keystone-6/fields-document'
2122
import { componentBlocks } from '../component-blocks'
2223
import { schema as structureSchema } from '../structure'
2324
import { schema as structureNestedSchema } from '../structure-nested'
2425
import { schema as structureRelationshipsSchema } from '../structure-relationships'
25-
import { dbConfig, localStorageConfig, trackingFields } from '../utils'
26+
import { localStorageConfig, trackingFields } from '../utils'
27+
// import { type Lists } from '.keystone/types' // TODO
2628

2729
const description =
2830
'Some thing to describe to test the length of the text for width, blah blah blah blah blah blah blah blah blah'
@@ -152,6 +154,11 @@ export const lists = {
152154
}),
153155
json: json({ ui: { description } }),
154156
integer: integer({ ui: { description } }),
157+
decimal: decimal({
158+
precision: 32,
159+
scale: 8,
160+
ui: { description }
161+
}),
155162
bigInt: bigInt({ isIndexed: 'unique', ui: { description } }),
156163
float: float({ ui: { description } }),
157164
image: image({ ui: { description }, storage: 'images' }),
@@ -222,7 +229,10 @@ export const lists = {
222229
}
223230

224231
export default config({
225-
db: dbConfig,
232+
db: {
233+
provider: 'postgresql',
234+
url: process.env.DATABASE_URL ?? ''
235+
},
226236
storage: localStorageConfig,
227237
lists,
228238
})

tests/sandbox/schema.graphql

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Thing {
2626
multiselect: [String!]
2727
json: JSON
2828
integer: Int
29+
decimal: Decimal
2930
bigInt: BigInt
3031
float: Float
3132
image: ImageFieldOutput
@@ -65,6 +66,8 @@ type PasswordState {
6566

6667
scalar CalendarDay @specifiedBy(url: "https://datatracker.ietf.org/doc/html/rfc3339#section-5.6")
6768

69+
scalar Decimal
70+
6871
scalar BigInt
6972

7073
type ImageFieldOutput {
@@ -138,6 +141,7 @@ input ThingWhereInput {
138141
selectOnSideItemViewOnly: StringNullableFilter
139142
selectSegmentedControl: StringNullableFilter
140143
integer: IntNullableFilter
144+
decimal: DecimalNullableFilter
141145
bigInt: BigIntNullableFilter
142146
float: FloatNullableFilter
143147
}
@@ -164,9 +168,15 @@ input StringFilter {
164168
contains: String
165169
startsWith: String
166170
endsWith: String
171+
mode: QueryMode
167172
not: NestedStringFilter
168173
}
169174

175+
enum QueryMode {
176+
default
177+
insensitive
178+
}
179+
170180
input NestedStringFilter {
171181
equals: String
172182
in: [String!]
@@ -229,6 +239,7 @@ input StringNullableFilter {
229239
contains: String
230240
startsWith: String
231241
endsWith: String
242+
mode: QueryMode
232243
not: StringNullableFilter
233244
}
234245

@@ -243,6 +254,17 @@ input IntNullableFilter {
243254
not: IntNullableFilter
244255
}
245256

257+
input DecimalNullableFilter {
258+
equals: Decimal
259+
in: [Decimal!]
260+
notIn: [Decimal!]
261+
lt: Decimal
262+
lte: Decimal
263+
gt: Decimal
264+
gte: Decimal
265+
not: DecimalNullableFilter
266+
}
267+
246268
input BigIntNullableFilter {
247269
equals: BigInt
248270
in: [BigInt!]
@@ -276,6 +298,7 @@ input ThingOrderByInput {
276298
selectOnSideItemViewOnly: OrderDirection
277299
selectSegmentedControl: OrderDirection
278300
integer: OrderDirection
301+
decimal: OrderDirection
279302
bigInt: OrderDirection
280303
float: OrderDirection
281304
}
@@ -306,6 +329,7 @@ input ThingUpdateInput {
306329
multiselect: [String!]
307330
json: JSON
308331
integer: Int
332+
decimal: Decimal
309333
bigInt: BigInt
310334
float: Float
311335
image: ImageFieldInput
@@ -389,6 +413,7 @@ input ThingCreateInput {
389413
multiselect: [String!]
390414
json: JSON
391415
integer: Int
416+
decimal: Decimal
392417
bigInt: BigInt
393418
float: Float
394419
image: ImageFieldInput
@@ -732,11 +757,6 @@ enum KeystoneAdminUIFieldMetaItemViewFieldPosition {
732757
sidebar
733758
}
734759

735-
enum QueryMode {
736-
default
737-
insensitive
738-
}
739-
740760
type KeystoneAdminUIFieldGroupMeta {
741761
label: String!
742762
description: String

tests/sandbox/schema.prisma

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
// This file is automatically generated by Keystone, do not modify it manually.
22
// Modify your Keystone config when you want to change this.
33

4-
datasource sqlite {
4+
datasource postgresql {
55
url = env("DATABASE_URL")
66
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
7-
provider = "sqlite"
7+
provider = "postgresql"
88
}
99

1010
generator client {
1111
provider = "prisma-client-js"
12-
output = "node_modules/.testprisma/client"
1312
}
1413

1514
model Thing {
1615
id String @id @default(cuid())
1716
text String @default("")
1817
timestamp DateTime?
19-
structure String @default("{\"integer\":0,\"array\":[]}")
20-
structureNested String @default("[]")
21-
structureRelationships String @default("[]")
18+
structure Json @default("{\"integer\":0,\"array\":[]}")
19+
structureNested Json @default("[]")
20+
structureRelationships Json @default("[]")
2221
checkbox Boolean @default(false)
2322
password String?
2423
toOneRelationship User? @relation("Thing_toOneRelationship", fields: [toOneRelationshipId], references: [id])
@@ -29,14 +28,15 @@ model Thing {
2928
toOneRelationshipCard User? @relation("Thing_toOneRelationshipCard", fields: [toOneRelationshipCardId], references: [id])
3029
toOneRelationshipCardId String? @map("toOneRelationshipCard")
3130
toManyRelationshipCard Todo[] @relation("Thing_toManyRelationshipCard")
32-
calendarDay String?
31+
calendarDay DateTime? @postgresql.Date
3332
select String?
3433
selectOnSide String?
3534
selectOnSideItemViewOnly String?
3635
selectSegmentedControl String?
37-
multiselect String @default("[]")
38-
json String?
36+
multiselect Json @default("[]")
37+
json Json?
3938
integer Int?
39+
decimal Decimal? @postgresql.Decimal(32, 8)
4040
bigInt BigInt? @unique
4141
float Float?
4242
image_filesize Int?
@@ -46,7 +46,7 @@ model Thing {
4646
image_id String?
4747
file_filesize Int?
4848
file_filename String?
49-
document String @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
49+
document Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
5050
5151
@@index([toOneRelationshipId])
5252
@@index([toOneRelationshipAlternateLabelId])

0 commit comments

Comments
 (0)