Browse Source

Migration fixed and query parser improved.

pull/502/head
Sebastian 6 years ago
parent
commit
bec242a6a9
  1. 2
      backend/src/Squidex.Domain.Apps.Entities/Comments/Commands/CommentTextCommand.cs
  2. 10
      backend/src/Squidex.Infrastructure/Queries/Json/QueryParser.cs
  3. 20
      backend/tests/Squidex.Infrastructure.Tests/Queries/JsonQueryConversionTests.cs
  4. 3
      backend/tools/Migrate_01/OldEvents/ContentUpdateProposed.cs

2
backend/src/Squidex.Domain.Apps.Entities/Comments/Commands/CommentTextCommand.cs

@ -5,8 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
namespace Squidex.Domain.Apps.Entities.Comments.Commands
{
public abstract class CommentTextCommand : CommentsCommand

10
backend/src/Squidex.Infrastructure/Queries/Json/QueryParser.cs

@ -20,8 +20,18 @@ namespace Squidex.Infrastructure.Queries.Json
{
public static ClrQuery Parse(this JsonSchema schema, string json, IJsonSerializer jsonSerializer)
{
if (string.IsNullOrWhiteSpace(json))
{
return new ClrQuery();
}
var query = ParseFromJson(json, jsonSerializer);
if (query == null)
{
return new ClrQuery();
}
var result = SimpleMapper.Map(query, new ClrQuery());
var errors = new List<string>();

20
backend/tests/Squidex.Infrastructure.Tests/Queries/JsonQueryConversionTests.cs

@ -334,6 +334,22 @@ namespace Squidex.Infrastructure.Queries
Assert.Throws<ValidationException>(() => AssertQuery(json, null));
}
[Fact]
public void Should_not_throw_exception_when_parsing_null_string()
{
string? json = null;
Assert.NotNull(schema.Parse(json!, JsonHelper.DefaultSerializer));
}
[Fact]
public void Should_not_throw_exception_when_parsing_null_json()
{
var json = "null";
Assert.NotNull(schema.Parse(json, JsonHelper.DefaultSerializer));
}
private void AssertQuery(object json, string? expectedFilter)
{
var filter = ConvertQuery(json);
@ -374,9 +390,9 @@ namespace Squidex.Infrastructure.Queries
{
var json = JsonHelper.DefaultSerializer.Serialize(value, true);
var jsonFilter = schema.Parse(json, JsonHelper.DefaultSerializer);
var jsonQuery = schema.Parse(json, JsonHelper.DefaultSerializer);
return jsonFilter.ToString();
return jsonQuery.ToString();
}
}
}

3
backend/tools/Migrate_01/OldEvents/ContentUpdateProposed.cs

@ -7,7 +7,6 @@
using System;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Migrations;
@ -17,7 +16,7 @@ namespace Migrate_01.OldEvents
{
[EventType(nameof(ContentUpdateProposed))]
[Obsolete]
public sealed class ContentUpdateProposed : SquidexEvent, IMigrated<IEvent>
public sealed class ContentUpdateProposed : ContentEvent, IMigrated<IEvent>
{
public NamedContentData Data { get; set; }

Loading…
Cancel
Save