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

Malformed JSON in SQLite query with preview 4 #30886

Closed
ajcvickers opened this issue May 14, 2023 · 1 comment · Fixed by #30908
Closed

Malformed JSON in SQLite query with preview 4 #30886

ajcvickers opened this issue May 14, 2023 · 1 comment · Fixed by #30908
Assignees
Labels
area-json area-query area-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@ajcvickers
Copy link
Contributor

The JSON columns sample for SQLite has started failing with preview 4. Query:

var orderedAddresses = await context.Authors
    .Where(
        author => (author.Contact.Address.City == "Chigley"
                   && author.Contact.Phone != null)
                  || author.Name.StartsWith("D"))
    .OrderBy(author => author.Contact.Phone)
    .Select(
        author => author.Name + " (" + author.Contact.Address.Street
                  + ", " + author.Contact.Address.City
                  + " " + author.Contact.Address.Postcode + ")")
    .ToListAsync();

Generates:

fail: 5/14/2023 10:51:06.362 RelationalEventId.CommandError[20102] (Microsoft.EntityFrameworkCore.Database.Command)
      Failed executing DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT "a"."Name" || ' (' || "a"."Contact" ->> '$.Address.Street' || ', ' || "a"."Contact" ->> '$.Address.City' || ' ' || "a"."Contact" ->> '$.Address.Postcode' || ')'
      FROM "Authors" AS "a"
      WHERE ("a"."Contact" ->> '$.Address.City' = 'Chigley' AND "a"."Contact" ->> 'Phone' IS NOT NULL) OR "a"."Name" LIKE 'D%'
      ORDER BY "a"."Contact" ->> 'Phone'

Which throws:

Unhandled exception. Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'malformed JSON'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
@roji
Copy link
Member

roji commented May 14, 2023

That's on me, likely a result of #30334. Will investigate.

@roji roji self-assigned this May 14, 2023
@roji roji added the type-bug label May 14, 2023
roji added a commit to roji/efcore that referenced this issue May 16, 2023
@roji roji added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. area-sqlite area-query area-json labels May 16, 2023
@roji roji added this to the 8.0.0 milestone May 16, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0, 8.0.0-preview4, 8.0.0-preview5 May 26, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0-preview5, 8.0.0 Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-json area-query area-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants