@@ -15020,19 +15020,21 @@ def test_arrow_no_result_set(cursor: mssql_python.Cursor):
1502015020@pytest.mark.skipif(pa is None, reason="pyarrow is not installed")
1502115021def test_arrow_datetimeoffset(cursor: mssql_python.Cursor):
1502215022 "Datetimeoffset converts correctly to utc"
15023- cursor.execute(
15024- "declare @dt datetimeoffset(0) = '2345-02-03 12:34:56 +00:00';\n"
15025- "select @dt, @dt at time zone 'Pacific Standard Time';\n"
15026- )
15027- batch = cursor.arrow_batch(10)
15028- assert batch.num_rows == 1
15029- assert batch.num_columns == 2
15030- for col in batch.columns:
15031- assert pa.types.is_timestamp(col.type)
15032- assert col.type.tz == "+00:00", col.type.tz
15033- assert col.to_pylist() == [
15034- datetime(2345, 2, 3, 12, 34, 56, tzinfo=timezone.utc),
15035- ]
15023+ for force_sqlgetdata in (False, True):
15024+ str_val = "cast('asdf' as nvarchar(max))" if force_sqlgetdata else "'asdf'"
15025+ cursor.execute(
15026+ "declare @dt datetimeoffset(0) = '2345-02-03 12:34:56 +00:00';\n"
15027+ f"select {str_val}, @dt, @dt at time zone 'Pacific Standard Time';\n"
15028+ )
15029+ batch = cursor.arrow_batch(10)
15030+ assert batch.num_rows == 1
15031+ assert batch.num_columns == 3
15032+ for col in batch.columns[1:]:
15033+ assert pa.types.is_timestamp(col.type)
15034+ assert col.type.tz == "+00:00", col.type.tz
15035+ assert col.to_pylist() == [
15036+ datetime(2345, 2, 3, 12, 34, 56, tzinfo=timezone.utc),
15037+ ]
1503615038
1503715039
1503815040@pytest.mark.skipif(pa is None, reason="pyarrow is not installed")
0 commit comments