OrchardCore: Cannot using Where query from GraphQL because columns case

It’s happened with the default parts (Autoroute, Alias, Localization) with postgres@10 and OC dev channel. Somewhat related to this https://github.com/OrchardCMS/OrchardCore/issues/3684 For e.g.:

query MyQuery {
  blogPost(where: { path: "some-path" }) {
    displayText
  }
}

It throws this error:

GraphQL.ExecutionError: Error trying to resolve something.\n —> Npgsql.PostgresException (0x80004005): 42703: column AutoroutePartIndex.path does not exist\n at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()\n— End of stack trace from previous location where exception was thrown —\n at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()\n— End of stack trace from previous location where exception was thrown —\n at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)\n at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)\n at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)\n at Dapper.SqlMapper.QueryAsync[T](IDbConnection cnn, Type effectiveType, CommandDefinition command) in C:\projects\dapper\Dapper\SqlMapper.Async.cs:line 419\n at YesSql.Store.ProduceAsync[T](WorkerQueryKey key, Func2 work, Object[] args)\n at YesSql.Services.DefaultQuery.Query1.ListImpl()\n at OrchardCore.ContentManagement.GraphQL.Queries.ContentItemsFieldType.Resolve(ResolveFieldContext context) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.ContentManagement.GraphQL\Queries\ContentItemsFieldType.cs:line 104\n at OrchardCore.Apis.GraphQL.Resolvers.LockedAsyncFieldResolver`1.Resolve(ResolveFieldContext context) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.Apis.GraphQL.Abstractions\Resolvers\LockedAsyncFieldResolver.cs:line 25\n at GraphQL.Execution.ExecutionStrategy.ExecuteNodeAsync(ExecutionContext context, ExecutionNode node)\n Exception data:\n Severity: ERROR\n SqlState: 42703\n MessageText: column AutoroutePartIndex.path does not exist\n Hint: Perhaps you meant to reference the column "AutoroutePartIndex.Path".\n Position: 371\n File: parse_relation.c\n Line: 3283\n Routine: errorMissingColumn\n — End of inner exception stack trace —

      {
        "code": "POSTGRES",
        "data": {
          "Severity": "ERROR",
          "InvariantSeverity": "ERROR",
          "SqlState": "42703",
          "MessageText": "column AutoroutePartIndex.path does not exist",
          "Hint": "Perhaps you meant to reference the column \"AutoroutePartIndex.Path\".",
          "Position": 371,
          "File": "parse_relation.c",
          "Line": "3283",
          "Routine": "errorMissingColumn"
        }
      }

Should I add an alias here for the column name: https://github.com/OrchardCMS/OrchardCore/blob/cc53e491f9747277813ca2f72f42b5396cbe6d04/src/OrchardCore.Modules/OrchardCore.Autoroute/GraphQL/AutoroutePartIndexAliasProvider.cs#L9-L17 Or look at this function for clues: https://github.com/OrchardCMS/OrchardCore/blob/cc53e491f9747277813ca2f72f42b5396cbe6d04/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Predicates/PredicateQuery.cs#L55-L65

Thanks,

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (17 by maintainers)

Most upvoted comments

Ok i will take it; will try to take a proper look at it over the weekend

Yeah I understand that it’s from case-sensitivity with PostgreSQL, evidently from this line https://github.com/OrchardCMS/OrchardCore/blob/cc53e491f9747277813ca2f72f42b5396cbe6d04/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Predicates/PredicateQuery.cs#L89 this Dialect.QuoteForColumnName(values[1]) return "Path"

Your example doesn’t work because of graphql validation error 😉