Prisma1: [1.27.1] datamodel arrays bug

Created on 25 Feb 2019  路  11Comments  路  Source: prisma/prisma1

Describe the bug
We are losing nested arrays in an object.

To Reproduce
re-launch prisma introspect over a postgresql object which includes a 1-N relation.

Expected behavior
Generate arrays, not an object.

Screenshots
image

Versions (please complete the following information):

  • Connector: Postgres
  • Prisma Server: 1.27.1
  • prisma CLI: prisma/1.27.1 (windows-x64) node-v8.9.4
  • OS: W10
bu2-confirmed areintrospection

All 11 comments

Hello,

That behavior should be fixed already. With the current alpha branch, the introspection result looks like this.

Thanks! It will be included in the next release? @ejoebstl

@marticrespi

You can try it right now

npm i -g prisma@alpha

@pantharshit00 Hi, I have tried just now and I only can see a change, boolean values without quotes with alpha current version.

prisma/1.29.0-alpha.6 (windows-x64) node-v8.9.4

image

@pantharshit00 For reference: This issue (booleans being rendered as strings) was fixed a while ago, so this is very odd.

@marticrespi Could you please share your workflow? I assume you are running prisma introspect, but without a prisma.yml or existing datamodel.

Hi @ejoebstl , I'm running prisma introspect with prisma.yml, here you have

````
endpoint: http://localhost:4467
datamodel: datamodel.prisma
secret: XXXXX

generate:
- generator: graphql-schema
output: ./generated/
- generator: typescript-client
output: ./generated/prisma-client/

hooks:
post-deploy:
# - prisma generate
- rm -r ./generated/nexus-prisma
- npx nexus-prisma-generate --client ./generated/prisma-client --output ./generated/nexus-prisma
````

And my current datamodel is this:

````
type BillingAccount @pgTable(name: "BillingAccount") {
createdAt: DateTime!
customer: Customer!
id: Int! @unique
Invoices: Invoice!
Item_BillingAccounts: Item_BillingAccount!
name: String!
updatedAt: DateTime!
}

type Condition @pgTable(name: "Condition") {
createdAt: DateTime!
endDate: DateTime!
id: Int! @unique
product: Product!
startDate: DateTime!
updatedAt: DateTime!
}

type Contract @pgTable(name: "Contract") {
activationDateTime: DateTime
code: String! @unique
Costs: Cost
createdAt: DateTime!
customer: Customer!
enabled: Boolean @default(value: "false")
GlobalConditions: GlobalCondition!
id: Int! @unique
Items: Item!
lookToBook: Float!
minimumFee: Float!
updatedAt: DateTime!
}

type Cost @pgTable(name: "Cost") {
amount: Float
contract: Contract
createdAt: DateTime!
id: Int! @unique
item: Item
max: Int
min: Int
type: ChargeType!
updatedAt: DateTime!
isPercentage: Boolean @default(value: "false")
}

type Customer @pgTable(name: "Customer") {
BillingAccounts: BillingAccount!
code: String! @unique
Contracts: Contract!
createdAt: DateTime!
id: Int! @unique
name: String!
updatedAt: DateTime!
type: CustomerType!
}

type GlobalCondition @pgTable(name: "GlobalCondition") {
amount: Float
contract: Contract!
createdAt: DateTime!
defaultFreeTrialDaysForItem: Int
globalEndFreeTrialPeriod: DateTime
globalStartFreeTrialPeriod: DateTime
id: Int! @unique
millionSearches: Int
numConnections: Int
type: ContractType!
updatedAt: DateTime!
}

type Invoice @pgTable(name: "Invoice") {
amount: Float!
amountPaid: Float!
billingAccount: BillingAccount!
createdAt: DateTime!
endDate: DateTime!
id: Int! @unique
InvoiceBreakdowns: InvoiceBreakdown!
paymentMethod: PaymentMethod!
paymentStatus: PaymentStatus!
startDate: DateTime!
updatedAt: DateTime!
}

type InvoiceBreakdown @pgTable(name: "InvoiceBreakdown") {
amount: Float!
createdAt: DateTime!
endDate: DateTime!
id: Int! @unique
invoice: Invoice!
itemBillingAccount: Item_BillingAccount!
startDate: DateTime!
updatedAt: DateTime!
}

type Item @pgTable(name: "Item") {
contract: Contract!
Costs: Cost
createdAt: DateTime!
enabled: Boolean @default(value: "false")
id: Int! @unique
Item_BillingAccounts: Item_BillingAccount!
Products: Product!
specificFreeTrialDays: Int
updatedAt: DateTime!
}

type Item_BillingAccount @pgTable(name: "Item_BillingAccount") {
billingAccount: BillingAccount!
createdAt: DateTime!
id: Int! @unique
InvoiceBreakdowns: InvoiceBreakdown!
item: Item!
updatedAt: DateTime!
}

type Product @pgTable(name: "Product") {
Conditions: Condition!
createdAt: DateTime!
id: Int! @unique
item: Item!
system: String!
type: ProductType!
updatedAt: DateTime!
}

type ChargeType {
code: String! @unique
cost: Cost!
createdAt: DateTime!
description: String!
id: Int! @unique
name: String!
updatedAt: DateTime!
}

type ContractType {
code: String! @unique
createdAt: DateTime!
description: String!
globalCondition: GlobalCondition!
id: Int! @unique
name: String!
updatedAt: DateTime!
}

type CustomerType {
code: String! @unique
createdAt: DateTime!
customer: Customer!
description: String!
id: Int! @unique
name: String!
updatedAt: DateTime!
}

type PaymentMethod {
code: String! @unique
createdAt: DateTime!
description: String!
id: Int! @unique
invoice: Invoice!
name: String!
updatedAt: DateTime!
}

type PaymentStatus {
code: String! @unique
createdAt: DateTime!
description: String!
id: Int! @unique
invoice: Invoice!
name: String!
updatedAt: DateTime!
}

type ProductType {
code: String! @unique
createdAt: DateTime!
description: String!
id: Int! @unique
name: String!
updatedAt: DateTime!
product: Product!
}
````

Thanks!

Any news @ejoebstl ?

Sorry for the late reply, @marticrespi, I'm currently on vacation.

When you introspect with an existing datamodel, the cardinality for relations from the existing datamodel takes precedence over the introspection result.

I'll discuss this behavior internally and keep you posted.

Solved! I have tried just now with alpha-7 and it's already fixed.

I think this can be closed now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  路  3Comments

tbrannam picture tbrannam  路  3Comments

sorenbs picture sorenbs  路  3Comments

thomaswright picture thomaswright  路  3Comments

jannone picture jannone  路  3Comments