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

fix: Change to supporting of non-null inline arrays #609

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #607

Description

Change to supporting of non-null inline arrays vs supporting nullable inline arrays, as we did previously.

To do post merge:

  • update query spec doc

@AndrewSisley AndrewSisley added bug Something isn't working area/schema Related to the schema system action/no-benchmark Skips the action that runs the benchmark. labels Jul 8, 2022
@AndrewSisley AndrewSisley added this to the DefraDB v0.3 milestone Jul 8, 2022
@AndrewSisley AndrewSisley requested a review from a team July 8, 2022 15:40
@AndrewSisley AndrewSisley self-assigned this Jul 8, 2022
@AndrewSisley AndrewSisley force-pushed the sisley/fix/I607-non-nillable-inline-arrays branch 3 times, most recently from bc2e1cd to 2031397 Compare July 8, 2022 16:02
@codecov
Copy link

codecov bot commented Jul 8, 2022

Codecov Report

Merging #609 (d54f12c) into develop (e2091fc) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #609      +/-   ##
===========================================
+ Coverage    56.41%   56.44%   +0.02%     
===========================================
  Files          121      121              
  Lines        14317    14326       +9     
===========================================
+ Hits          8077     8086       +9     
  Misses        5542     5542              
  Partials       698      698              
Impacted Files Coverage Δ
query/graphql/schema/descriptions.go 86.84% <100.00%> (+0.35%) ⬆️
query/graphql/schema/generate.go 82.51% <100.00%> (+0.11%) ⬆️

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@jsimnz
Copy link
Member

jsimnz commented Jul 8, 2022

While reviewing this, I surfaced a strange bug.

I wanted to test what happens if you give it a schema with a nullable field, ie numbers: [Int] instead of numbers: [Int!] and see what kind of error response would happen, or if it just silently translated to a non-nullable equivalent.

In doing so I got the error: "Field missing associated relation. FieldName: numbers, SchemaType: Int, ObjectType: user" which I thought was a strange error. So this is potentially related to #574.

Also saw those same errors in the log about "Cannot update a relation that is already finalized" which was also strange since I was using a basic schema with scalar (and scalar arrays) only, so it shouldn't be interacting with the relation system.

Turns out, that all gql.List types are being treated as FieldKind_FOREIGN_OBJECT_ARRAY types, which was designed for arrays of related types (objects). IE friends: [User]. But scalar arrays don't fall into this category.

The tests are passing, because technically both the creation and query respond correctly, but it means internally the structure isn't exactly represented correctly, and it tries to use the relation system for scalar arrays.

All this to be able to say:

  1. Should we silently translate [Int] to [Int!] if present in a given schema
    or
  2. Should we return an error saying nullable scalar arrays aren't supported at the moment.

Both of these options likely means resolving the above issue. which would likely be handled by addressing the difference between types for gql.List => [Scalar] and gql.List => [Object]

@fredcarle
Copy link
Collaborator

I wanted to test what happens if you give it a schema with a nullable field, ie numbers: [Int] instead of numbers: [Int!] and see what kind of error response would happen, or if it just silently translated to a non-nullable equivalent.

Good catch! I should have tried doing that too when reviewing.

  1. Should we silently translate [Int] to [Int!] if present in a given schema
    or
  2. Should we return an error saying nullable scalar arrays aren't supported at the moment.

Both of these options likely means resolving the above issue. which would likely be handled by addressing the difference between types for gql.List => [Scalar] and gql.List => [Object]

If we plan on supporting [Int] in the future, I think option 1 is a reasonable thing to do as long as we document that we are doing that.

@AndrewSisley
Copy link
Contributor Author

Should we silently translate [Int] to [Int!] if present in a given schema?

I'm really not a fan of silently altering the types users explicitly give us

Should we return an error saying nullable scalar arrays aren't supported at the moment.

I don't think we need to define this, there are a fair few other gql types that we don't support (such as time) - and that behaviour is undefined as as far as I can tell (we have no tests)

@AndrewSisley
Copy link
Contributor Author

Merging, as I see John's comment as a separate issue (and assume John does to - no changes requested?) - I have linked to it from #574 as it might be relevant there. The undefined type issue is separate too, and I don't think we have an issue for it, but I'm not sure it needs one atm (feel very free to create if anyone wants).

@AndrewSisley AndrewSisley merged commit c8dd5e1 into develop Jul 11, 2022
@AndrewSisley AndrewSisley deleted the sisley/fix/I607-non-nillable-inline-arrays branch July 11, 2022 14:42
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
* Skip test if detecting changes

* Change to supporting of non-null inline arrays

Vs supporting nullable inline arrays, as we did previously
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/schema Related to the schema system bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make current inline-array types non-nillable
3 participants