Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Array types #259

Closed
yovanoc opened this issue Oct 15, 2019 · 11 comments
Closed

Array types #259

yovanoc opened this issue Oct 15, 2019 · 11 comments
Assignees
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug.
Milestone

Comments

@yovanoc
Copy link

yovanoc commented Oct 15, 2019

As you tell me @divyenduz I create an issue for a follow up on this one #256

Why array types are | null and not simple empty array?

@divyenduz
Copy link

divyenduz commented Oct 15, 2019

@yovanoc Can you please provide an example?

I think it depends on the type (an array can be a nullable array (| null case) or a non-nullable array [] empty array case).

If I understand correctly, please share an example of what you mean.

@yovanoc
Copy link
Author

yovanoc commented Oct 15, 2019

I just sent you an email

@pantharshit00
Copy link
Contributor

I checked this out and arrays are not | null

Also, the schema doesn't allow nullable array by design for the same reasons as you have posted.

Can you please send in the query or the screenshot where arrays are nullable?

I tested using prisma2@2.0.0-preview014.2, binary version: 237b46b97773f5018e336550e4285e2a78c38483

@pantharshit00 pantharshit00 added bug/0-needs-info More information is needed for reproduction. kind/bug A reported bug. labels Oct 21, 2019
@yovanoc
Copy link
Author

yovanoc commented Oct 21, 2019

Ok now with latest alpha array are not nullable anymore, but an optional field in my schema in nested select is not marked as nullable.

PS: Schema and query in our mail conversation. thanks

@pantharshit00
Copy link
Contributor

image

I can't reproduce. It is nullable. Also, as a side note please don't confuse ? operator with nullability. ? makes a property optional not nullable

@yovanoc
Copy link
Author

yovanoc commented Oct 22, 2019

You'are right I said nullability when a field is optional in the prisma schema and should be | null in the generated typescript no? I make a little reproduction tested with prisma2@2.0.0-alpha.266, binary version: 998508a3ac0132b0b211dec85419e0a27f3d1813.

Schema:
image

Query:

const userTest = await photon.userTests.findOne({
    where: {
      id: "Example"
    },
    select: {
      id: true,
      globalConfig: {
        select: {
          accounts: {
            select: {
              username: true,
              password: true,
              config: {
                select: {
                  data: true,
                  list: true
                }
              }
            }
          }
        }
      }
    }
  });

Result:
image

Here I don't get why accounts are marked as | null and the list of Random model too. But what I was telling you first was this AccountData? but yeah now it's good for that.

Thanks

@pantharshit00
Copy link
Contributor

Oh yes, you are right. account and config.list should not be marked a nullable field.

image

I can confirm this as a bug now. Here is the reproduction for internal use: https://github.com/harshit-test-org/prisma-photon-259

@pantharshit00 pantharshit00 added bug/2-confirmed We have confirmed that this is a bug. process/candidate Candidate for next Milestone. and removed bug/0-needs-info More information is needed for reproduction. labels Oct 28, 2019
@timsuchanek timsuchanek added this to the Preview 16 milestone Oct 31, 2019
@timsuchanek
Copy link
Contributor

Fixed in latest alpha.
You can try it out with npm i -g prisma2@alpha.

@yovanoc
Copy link
Author

yovanoc commented Oct 31, 2019

Still happening to me on
image

@timsuchanek
Copy link
Contributor

Please try again with alpha.278, sometimes the CI/npm takes a bit longer.
I just manually test it with 278 and it works for me.

@yovanoc
Copy link
Author

yovanoc commented Oct 31, 2019

AHAH yes thats PERFECT

@janpio janpio removed the process/candidate Candidate for next Milestone. label Nov 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

5 participants