@@ -15274,19 +15274,21 @@ def test_arrow_no_result_set(cursor: mssql_python.Cursor):
1527415274@pytest.mark.skipif(pa is None, reason="pyarrow is not installed")
1527515275def test_arrow_datetimeoffset(cursor: mssql_python.Cursor):
1527615276 "Datetimeoffset converts correctly to utc"
15277- cursor.execute(
15278- "declare @dt datetimeoffset(0) = '2345-02-03 12:34:56 +00:00';\n"
15279- "select @dt, @dt at time zone 'Pacific Standard Time';\n"
15280- )
15281- batch = cursor.arrow_batch(10)
15282- assert batch.num_rows == 1
15283- assert batch.num_columns == 2
15284- for col in batch.columns:
15285- assert pa.types.is_timestamp(col.type)
15286- assert col.type.tz == "+00:00", col.type.tz
15287- assert col.to_pylist() == [
15288- datetime(2345, 2, 3, 12, 34, 56, tzinfo=timezone.utc),
15289- ]
15277+ for force_sqlgetdata in (False, True):
15278+ str_val = "cast('asdf' as nvarchar(max))" if force_sqlgetdata else "'asdf'"
15279+ cursor.execute(
15280+ "declare @dt datetimeoffset(0) = '2345-02-03 12:34:56 +00:00';\n"
15281+ f"select {str_val}, @dt, @dt at time zone 'Pacific Standard Time';\n"
15282+ )
15283+ batch = cursor.arrow_batch(10)
15284+ assert batch.num_rows == 1
15285+ assert batch.num_columns == 3
15286+ for col in batch.columns[1:]:
15287+ assert pa.types.is_timestamp(col.type)
15288+ assert col.type.tz == "+00:00", col.type.tz
15289+ assert col.to_pylist() == [
15290+ datetime(2345, 2, 3, 12, 34, 56, tzinfo=timezone.utc),
15291+ ]
1529015292
1529115293
1529215294@pytest.mark.skipif(pa is None, reason="pyarrow is not installed")
0 commit comments