I have a field that's set as required in the prism...
# orm-help
m
I have a field that's set as required in the prisma.schema file and has a default value set as well. I'm getting an error that the argument is missing if I don't pass it in as an argument. Shouldn't the default cause it to use that value if the argument isn't specified for it? If not, what is the point of the default value?
r
Hey Matt 👋 The default should work without any issue. What version of Prisma you're on and could you share that model of the schema where you've set the default directive?
m
Okay, this is really odd. I have a couple version of the software so I switched back to the "stable" version where I was having the issue and did a
npx prisma -v
to answer you question. It returned:
Copy code
@prisma/cli          : 2.0.0-beta.1
On my newer version of my software, it's beta.4 so on the stable one I did an
npm i
to see if it needed updated. It still shows
beta.1
but I can no longer dupe my issue. The table is kind of large but the line in it for the field in question is this:
Copy code
lead_campaign_id         Int                   @default(4)
I've still got my console up from yesterday so I was able to access the error I got:
Copy code
Invalid `prisma.lead.create()` invocation:

{
  data: {
    test_lead: true,
    first_name: 'Fakey',
    last_name: 'Fakerson',
    phone_cell: '<tel:3333333333|333-333-3333>',
    marketing_qualified: false,
+   LeadCampaign: {
+     create?: LeadCampaignCreateWithoutLeadInput,
+     connect?: LeadCampaignWhereUniqueInput
+   },
?   address_one?: String,
?   address_two?: String,
?   assessment_complete?: Boolean,
?   city?: String,
?   email_one?: String,
?   email_two?: String,
?   gate_code?: String,
?   latitude?: String,
?   longitude?: String,
?   marketing_callable?: Boolean,
?   marketing_emailble?: Boolean,
?   marketing_tag_collection?: String,
?   marketing_textable?: Boolean,
?   phone_home?: String,
?   stage?: New | Working | Converted | Lost,
?   state_abbr?: String,
?   zip?: String,
?   User?: {
?     create?: UserCreateWithoutLeadInput,
?     connect?: UserWhereUniqueInput
?   },
?   Account?: {
?     create?: AccountCreateWithoutLeadInput,
?     connect?: AccountWhereUniqueInput
?   },
?   LeadWorkingEventLog?: {
?     create?: LeadWorkingEventLogCreateWithoutLeadInput,
?     connect?: LeadWorkingEventLogWhereUniqueInput
?   }
  }
}

Argument LeadCampaign for data.LeadCampaign is missing.

Note: Lines with + are required, lines with ? are optional.