fix(mssql): week time grain should respect datefirst setting (#10811)

* "P1W" grain should respect DATEFIRST setting in MS SQL Server

* Added "week_start_sunday" and "week_start_monday" grains support. Adjusted the "week" grain for better backward compatibility with MS SQL 2005/2008.

* Stylistic and linter-requested changes

* fix test

Co-authored-by: Valeriy Aleksashkin <v.aleksashkin@gmail.com>
Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
This commit is contained in:
binome74
2021-11-16 12:36:37 +05:00
committed by GitHub
parent 3ee9e11ce1
commit 211b32a4cd
2 changed files with 18 additions and 13 deletions

View File

@@ -79,7 +79,7 @@ class TestMssqlEngineSpec(TestDbEngineSpec):
col = column("MixedCase")
expr = MssqlEngineSpec.get_timestamp_expr(col, None, "P1Y")
result = str(expr.compile(None, dialect=mssql.dialect()))
self.assertEqual(result, "DATEADD(year, DATEDIFF(year, 0, [MixedCase]), 0)")
self.assertEqual(result, "DATEADD(YEAR, DATEDIFF(YEAR, 0, [MixedCase]), 0)")
def test_convert_dttm(self):
dttm = self.get_dttm()