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

Parsing PostgreSQL jsonb array gets error #6077

Open
1 task done
alexander161198 opened this issue Apr 21, 2023 · 0 comments
Open
1 task done

Parsing PostgreSQL jsonb array gets error #6077

alexander161198 opened this issue Apr 21, 2023 · 0 comments
Labels
Area: Data Issue is related to filtering, sorting, pagination or projections 🐛 bug Something isn't working 🌶️ hot chocolate

Comments

@alexander161198
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Product

Hot Chocolate

Describe the bug

An error throws when trying to execute query a model with an attribute of type jsonb that contains an array.
I saw similar problem #4429 . But in my case another error occurs.

Steps to reproduce

  1. There is entity class (and related classes):
 public class class1Alias
    {
        public String name { get; set; }

        [Column(TypeName = "jsonb")]
        public TestStructAliasSimple? SimpleStruct { get; set; }

        [Column(TypeName = "jsonb")]
        public TestStructArray? StructArray { get; set; }

        public String[]? ArrayAttr { get; set; }

        [Key]
        public Guid Id { get; set; }
    }

public class TestStructAliasSimple
    {
        public Int32? AttrIntAlias { get; set; }

        public String? AttrStrAlias { get; set; }
    }
public class TestStructArray
    {
        public Boolean? AttrBoolAlias { get; set; }

        public String[]? AttrArrayAlias { get; set; }
    }

And I have simple query method:

public async Task<IQueryable<teststructure.class1Alias>> teststructure_class1alias([ScopedService()] InteractiveStoreContext dbcontext)
        {
            var entities = dbcontext.teststructure_class1Aliases.AsQueryable();
            return await Task.FromResult(entities);
        }

And I have mutations methond, ofc. But I think It doesn't matter now.

  1. I exetute the add mutation which succeeded:
mutation Add{
    add_teststructure_class1alias(teststructure_class1alias: {
      name: "name1", 
      simpleStruct:{attrIntAlias:1, attrStrAlias:"value1"}, 
      structArray:{attrBoolAlias:true, attrArrayAlias:["1", "2"]}, 
      arrayAttr:["d","f"]}) 
  {
    insertedId
    countObjectsModified
    operation
    objectName
  }
}

Data was successfully written to the database:
image

  1. I try to execute query:
query Simple{
  teststructure_class1alias {
    items {
      name,
      id,
      simpleStruct
      {
        attrStrAlias,
        attrIntAlias
      },
      structArray
      {
        attrBoolAlias,
        attrArrayAlias
      },
      arrayAttr
    }
  }
}

And I get the error: No coercion operator is defined between types 'System.String' and 'System.String[]'.
image

When I use query without structArray it works fine:

query Simple{
  teststructure_class1alias {
    items {
      name
      id,
      simpleStruct
      {
        attrStrAlias,
        attrIntAlias
      },
      arrayAttr
    }
  }
}

image

So is this a bug and am I doing something wrong?

Relevant log output

No coercion operator is defined between types 'System.String' and 'System.String[]'.

Additional Context?

It works fine with simple jsonb attributes or simple arrays. But jsonb with arrays broke the program.

Version

12.15.2

@alexander161198 alexander161198 added the 🐛 bug Something isn't working label Apr 21, 2023
@michaelstaib michaelstaib added 🌶️ hot chocolate Area: Data Issue is related to filtering, sorting, pagination or projections labels Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Data Issue is related to filtering, sorting, pagination or projections 🐛 bug Something isn't working 🌶️ hot chocolate
Projects
None yet
Development

No branches or pull requests

2 participants