Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decimal field to test sandbox, prefer POSTGRES for sandbox #9011

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions tests/sandbox/configs/all-the-things.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import { list, graphql, config, group } from '@keystone-6/core'
import { allowAll } from '@keystone-6/core/access'
import {
bigInt,
calendarDay,
checkbox,
decimal,
file,
float,
image,
integer,
json,
multiselect,
password,
relationship,
select,
text,
timestamp,
file,
virtual,
select,
json,
integer,
image,
float,
bigInt,
calendarDay,
multiselect,
} from '@keystone-6/core/fields'
import { document, structure } from '@keystone-6/fields-document'
import { componentBlocks } from '../component-blocks'
import { schema as structureSchema } from '../structure'
import { schema as structureNestedSchema } from '../structure-nested'
import { schema as structureRelationshipsSchema } from '../structure-relationships'
import { dbConfig, localStorageConfig, trackingFields } from '../utils'

Check failure on line 26 in tests/sandbox/configs/all-the-things.ts

View workflow job for this annotation

GitHub Actions / Linting

'dbConfig' is declared but its value is never read.
// import { type Lists } from '.keystone/types' // TODO

const description =
'Some thing to describe to test the length of the text for width, blah blah blah blah blah blah blah blah blah'
Expand Down Expand Up @@ -152,6 +154,11 @@
}),
json: json({ ui: { description } }),
integer: integer({ ui: { description } }),
decimal: decimal({
precision: 32,
scale: 8,
ui: { description }
}),
bigInt: bigInt({ isIndexed: 'unique', ui: { description } }),
float: float({ ui: { description } }),
image: image({ ui: { description }, storage: 'images' }),
Expand Down Expand Up @@ -222,7 +229,10 @@
}

export default config({
db: dbConfig,
db: {
provider: 'postgresql',
url: process.env.DATABASE_URL ?? ''
},
storage: localStorageConfig,
lists,
})
30 changes: 25 additions & 5 deletions tests/sandbox/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Thing {
multiselect: [String!]
json: JSON
integer: Int
decimal: Decimal
bigInt: BigInt
float: Float
image: ImageFieldOutput
Expand Down Expand Up @@ -65,6 +66,8 @@ type PasswordState {

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

scalar Decimal

scalar BigInt

type ImageFieldOutput {
Expand Down Expand Up @@ -138,6 +141,7 @@ input ThingWhereInput {
selectOnSideItemViewOnly: StringNullableFilter
selectSegmentedControl: StringNullableFilter
integer: IntNullableFilter
decimal: DecimalNullableFilter
bigInt: BigIntNullableFilter
float: FloatNullableFilter
}
Expand All @@ -164,9 +168,15 @@ input StringFilter {
contains: String
startsWith: String
endsWith: String
mode: QueryMode
not: NestedStringFilter
}

enum QueryMode {
default
insensitive
}

input NestedStringFilter {
equals: String
in: [String!]
Expand Down Expand Up @@ -229,6 +239,7 @@ input StringNullableFilter {
contains: String
startsWith: String
endsWith: String
mode: QueryMode
not: StringNullableFilter
}

Expand All @@ -243,6 +254,17 @@ input IntNullableFilter {
not: IntNullableFilter
}

input DecimalNullableFilter {
equals: Decimal
in: [Decimal!]
notIn: [Decimal!]
lt: Decimal
lte: Decimal
gt: Decimal
gte: Decimal
not: DecimalNullableFilter
}

input BigIntNullableFilter {
equals: BigInt
in: [BigInt!]
Expand Down Expand Up @@ -276,6 +298,7 @@ input ThingOrderByInput {
selectOnSideItemViewOnly: OrderDirection
selectSegmentedControl: OrderDirection
integer: OrderDirection
decimal: OrderDirection
bigInt: OrderDirection
float: OrderDirection
}
Expand Down Expand Up @@ -306,6 +329,7 @@ input ThingUpdateInput {
multiselect: [String!]
json: JSON
integer: Int
decimal: Decimal
bigInt: BigInt
float: Float
image: ImageFieldInput
Expand Down Expand Up @@ -389,6 +413,7 @@ input ThingCreateInput {
multiselect: [String!]
json: JSON
integer: Int
decimal: Decimal
bigInt: BigInt
float: Float
image: ImageFieldInput
Expand Down Expand Up @@ -732,11 +757,6 @@ enum KeystoneAdminUIFieldMetaItemViewFieldPosition {
sidebar
}

enum QueryMode {
default
insensitive
}

type KeystoneAdminUIFieldGroupMeta {
label: String!
description: String
Expand Down
20 changes: 10 additions & 10 deletions tests/sandbox/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// This file is automatically generated by Keystone, do not modify it manually.
// Modify your Keystone config when you want to change this.

datasource sqlite {
datasource postgresql {
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
provider = "sqlite"
provider = "postgresql"
dcousens marked this conversation as resolved.
Show resolved Hide resolved
}

generator client {
provider = "prisma-client-js"
output = "node_modules/.testprisma/client"
}

model Thing {
id String @id @default(cuid())
text String @default("")
timestamp DateTime?
structure String @default("{\"integer\":0,\"array\":[]}")
structureNested String @default("[]")
structureRelationships String @default("[]")
structure Json @default("{\"integer\":0,\"array\":[]}")
structureNested Json @default("[]")
structureRelationships Json @default("[]")
checkbox Boolean @default(false)
password String?
toOneRelationship User? @relation("Thing_toOneRelationship", fields: [toOneRelationshipId], references: [id])
Expand All @@ -29,14 +28,15 @@ model Thing {
toOneRelationshipCard User? @relation("Thing_toOneRelationshipCard", fields: [toOneRelationshipCardId], references: [id])
toOneRelationshipCardId String? @map("toOneRelationshipCard")
toManyRelationshipCard Todo[] @relation("Thing_toManyRelationshipCard")
calendarDay String?
calendarDay DateTime? @postgresql.Date
select String?
selectOnSide String?
selectOnSideItemViewOnly String?
selectSegmentedControl String?
multiselect String @default("[]")
json String?
multiselect Json @default("[]")
json Json?
integer Int?
decimal Decimal? @postgresql.Decimal(32, 8)
bigInt BigInt? @unique
float Float?
image_filesize Int?
Expand All @@ -46,7 +46,7 @@ model Thing {
image_id String?
file_filesize Int?
file_filename String?
document String @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
document Json @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")

@@index([toOneRelationshipId])
@@index([toOneRelationshipAlternateLabelId])
Expand Down
Loading