Azure / Azure/data-api-builder

[Bug]: `StoredProcedureBuilderTests` assume locale of en-US, and may cause problems with how we handle `DateTime` in stored procedure parameters

Offen
#1,469 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug graphql mssql pgsql mysql pgsql testing
Vorherrschende Sprache
C#
Sterne
1.5k
Forks
370
Ø Merge
3 T. 22 Std.
Gemergte PRs (30 T.)
9

Beschreibung

### What happened?

I was running the test suite of `StoredProcedure_ParameterValueTypeResolution` and had the three `DateTime`/`DateTimeOffset` tests:

https://github.com/Azure/data-api-builder/blob/main/src/Service.Tests/GraphQLBuilder/Sql/StoredProcedureBuilderTests.cs#L53-L55

The error is that it failed to parse the default value:

```
Assert.IsTrue failed. Failure: Did not expect error during stored procedure field creation: The parameter value 11/19/2012 10:57:11 AM -08:00 provided in configuration cannot be converted to the type DateTime
```

The reason this fails is that my machine locale is `en-AU`, whereas the date format in the test is `en-US` (denoted by `MM/dd`). As a result, these tests will _never_ pass on my machine because of the locale set, unless I change my machine locale.

While failing unit tests is an annoyance, it's survivable as they pass on the build server, it highlights a potentially larger problem in a production environment - **`DateTime` stored procedure params may fail due to locale assumptions.**

We should probably clearly document that the default value should be in the same format as the locale of the DAB host (which is more difficult to know in the SWA hosted version) or state that we only support a known format, such as ISO 8601, and update the parser to have that explicitly set.

### Version

N/A

### What database are you using?

Azure SQL

### What hosting model are you using?

Local (including CLI)

### Which API approach are you accessing DAB through?

GraphQL

### Relevant log output

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit src/Service.Tests/GraphQLBuilder/Sql/StoredProcedureBuilderTests.cs, insbesondere mit den Zeilen 53-55 und den StoredProcedure_ParameterValueTypeResolution-Tests; reproduziere den Fehler unter einem Nicht-en-US-Gebietsschema. Verfolge anschließend den Parser für Standardwerte von Stored-Procedure-Parametern, lege das unterstützte Datumsformat fest, dokumentiere es und stelle sicher, dass die Tests unabhängig vom Gebietsschema des Hosts bestehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, csharp, graphql, sql
Bereich
api, databases, testing
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.