Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Core/Services/TypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Net;
using Azure.DataApiBuilder.Core.Services.OpenAPI;
using Azure.DataApiBuilder.Service.Exceptions;
Expand Down Expand Up @@ -304,12 +305,12 @@ public static bool TryGetDbTypeFromSqlDbDateTimeType(SqlDbType sqlDbType, [NotNu
SyntaxKind valueKind = node.Kind;
return valueKind switch
{
SyntaxKind.IntValue => Convert.ToInt32(node.Value), // spec
SyntaxKind.FloatValue => Convert.ToDouble(node.Value), // spec
SyntaxKind.IntValue => Convert.ToInt32(node.Value, CultureInfo.InvariantCulture), // spec
SyntaxKind.FloatValue => Convert.ToDouble(node.Value, CultureInfo.InvariantCulture), // spec
SyntaxKind.BooleanValue => Convert.ToBoolean(node.Value), // spec
SyntaxKind.StringValue => Convert.ToString(node.Value), // spec
SyntaxKind.StringValue => Convert.ToString(node.Value, CultureInfo.InvariantCulture), // spec
SyntaxKind.NullValue => null, // spec
_ => Convert.ToString(node.Value)
_ => Convert.ToString(node.Value, CultureInfo.InvariantCulture)
};
}

Expand Down
26 changes: 26 additions & 0 deletions src/Service.Tests/CosmosTests/MutationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net.Http;
using System.Text.Json;
Expand Down Expand Up @@ -1074,6 +1075,31 @@ public async Task CanPatchMoreThan10AttributesInAnItemWithVariables()
Assert.AreEqual(patchResponse.GetProperty("moons").ToString(), JsonSerializer.Serialize(update.moons));
}

[TestMethod]
[DataRow("en-US")]
[DataRow("en-DE")]
public async Task CanCreateItemWithCultureInvariant(string cultureInfo)
{
CultureInfo ci = new(cultureInfo);
CultureInfo.DefaultThreadCurrentCulture = ci;

// Run mutation Add planet;
string id = Guid.NewGuid().ToString();
const string name = "test_name";
string mutation = $@"
mutation {{
createPlanet (item: {{ id: ""{id}"", name: ""{name}"", age: 10.15 }}) {{
id
name
age
}}
}}";
JsonElement response = await ExecuteGraphQLRequestAsync("createPlanet", mutation, variables: new());

// Validate results
Assert.AreEqual(Convert.ToDouble(10.15, CultureInfo.InvariantCulture), response.GetProperty("age").GetDouble());
}

/// <summary>
/// Runs once after all tests in this class are executed
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Service.Tests/CosmosTests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Planet @model(name:""PlanetAlias"") {
id : ID!,
name : String,
character: Character,
age : Int,
age : Float,
dimension : String,
earth: Earth,
tags: [String!],
Expand Down