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

オープン
#1,469 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug graphql mssql pgsql mysql pgsql testing
主要言語
C#
スター
1.5k
フォーク
370
平均マージ
3日 22時間
マージ済み PR(30日)
9

説明

### 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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/Service.Tests/GraphQLBuilder/Sql/StoredProcedureBuilderTests.cs から始め、特に 53-55 行目と StoredProcedure_ParameterValueTypeResolution テストを確認します。en-US 以外のロケールで失敗を再現してください。次に、ストアドプロシージャのパラメーターのデフォルト値パーサーを追跡し、サポートされる日付形式を確定して文書化し、ホストのロケールに依存せずテストが成功することを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
azure, csharp, graphql, sql
領域
api, databases, testing
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。