Skip to content

Commit

Permalink
fix: correction of bugs found by new documentation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tpz committed Feb 27, 2024
1 parent 3a6bc07 commit decd40c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions EvitaDB.Client/DataTypes/EvitaDataTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static string FormatValue(object? value)
}
if (value is bool boolValue)
{
return boolValue.ToString()!;
return boolValue.ToString().ToLower();
}
if (value is Range range)
{
Expand Down Expand Up @@ -341,4 +341,4 @@ private static string DateTimeMillisecondFormat(int milliseconds)
// Three or more digits in milliseconds, format with three milliseconds
return ".fff";
}
}
}
13 changes: 11 additions & 2 deletions EvitaDB.Client/Models/ExtraResults/Hierarchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private void AppendLevelInfoTreeString(StringBuilder treeBuilder, LevelInfo leve
}
}

public record LevelInfo(IEntityClassifier Entity, bool Requested, int? QueriedEntityCount, int? ChildrenCount, List<LevelInfo> Children)
public record LevelInfo(IEntityClassifier Entity, bool Requested, int? QueriedEntityCount, int? ChildrenCount, List<LevelInfo> Children) : IComparable
{
public LevelInfo(LevelInfo levelInfo, List<LevelInfo> children) :
this(levelInfo.Entity, levelInfo.Requested, levelInfo.QueriedEntityCount, levelInfo.ChildrenCount, children)
Expand All @@ -202,4 +202,13 @@ public override string ToString()

return $"[{QueriedEntityCount}:{ChildrenCount} {Entity}]";
}
}

public int CompareTo(object? other)
{
if (other is not LevelInfo levelInfo)
{
return 1;
}
return Entity.PrimaryKey!.Value.CompareTo(levelInfo.Entity.PrimaryKey!.Value);
}
}
6 changes: 5 additions & 1 deletion EvitaDB.Client/Queries/Filter/AttributeInRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ namespace EvitaDB.Client.Queries.Filter;
/// inRange("age", 63)
/// </code>
/// </summary>
public class AttributeInRange<T> : AbstractAttributeFilterConstraintLeaf
public class AttributeInRange<T> : AbstractAttributeFilterConstraintLeaf, IConstraintWithSuffix
where T : IComparable
{
private static readonly string SuffixNow = "now";
private AttributeInRange(params object?[] arguments) : base(arguments)
{
}
Expand Down Expand Up @@ -73,4 +74,7 @@ public AttributeInRange(string attributeName, byte value) : base(attributeName,
public TNumber? TheValue<TNumber>() where TNumber : struct, IComparable => Arguments is [_, TNumber theValue and (byte or short or int or long or decimal)]
? theValue
: null;

public string? SuffixIfApplied => Arguments.Length == 1 ? SuffixNow : null;
public bool ArgumentImplicitForSuffix(object argument) => false;
}
3 changes: 2 additions & 1 deletion EvitaDB.Client/Queries/IQueryConstraints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ dateTimeOffsetValue is null
decimalValue is null ? null : new AttributeInRange<decimal>(attributeName, decimalValue.Value);

/// <inheritdoc cref="Client.Queries.Filter.AttributeInRange{DateTimeOffset}"/>
static AttributeInRange<DateTimeOffset> AttributeInRangeNow(string attributeName) => new(attributeName);
static AttributeInRange<DateTimeOffset>? AttributeInRangeNow(string? attributeName) =>
attributeName is null ? null : new AttributeInRange<DateTimeOffset>(attributeName!);

/// <inheritdoc cref="Client.Queries.Filter.AttributeInSet{T}"/>
static AttributeInSet<T>? AttributeInSet<T>(string? attributeName, params T?[]? set)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using EvitaDB.Client.DataTypes;
using EvitaDB.Client.Models.Data;
using EvitaDB.Client.Models.Schemas;
using EvitaDB.Client.Utils;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -43,7 +44,14 @@ public override void WriteJson(JsonWriter writer, ISealedEntity? value, JsonSeri
if (value.InnerRecordHandling != PriceInnerRecordHandling.Unknown)
{
writer.WritePropertyName("priceInnerRecordHandling");
writer.WriteValue(value.InnerRecordHandling?.ToString().ToUpper());
if (value.InnerRecordHandling != null)
{
writer.WriteValue(StringUtils.ToUpperSnakeCase(value.InnerRecordHandling!.ToString()!));
}
else
{
writer.WriteNull();
}
}

WriteAttributes(writer, value);
Expand Down

0 comments on commit decd40c

Please sign in to comment.