timezone aware datetime bind variables are passed as UTC
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu bằng cách chạy script Python được cung cấp trên các phiên bản Oracle Database đã nêu ở chế độ thin và thick, tập trung vào việc xử lý bind DB_TYPE_TIMESTAMP_TZ và thực thi update_stmt. So sánh binding, giá trị được lưu trữ và đầu ra múi giờ của session. Được xem là hoàn tất khi hành vi datetime có múi giờ đã chọn được triển khai nhất quán mà không làm thay đổi ngoài dự kiến thời điểm hoặc các thành phần được biểu diễn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When using timezone aware datetime bind variables, the value passed to the server has the same date/time components as the bind variable but the time zone is changed to UTC regardless of session time zone.
I'm aware that named time zones are not supported, but that change messes up data. imho proper behaviors could be:
- passing UTC offset as TZ info (instead of original named time zone)
- pass UTC as TZ info but with date/time components adjusted accordingly
I have tested version 2.3.0 of the driver, both thin and thick modes, with 12.2 and 19.13 databases. Running below script in thin mode with a 19.13 database, produces next output
platform.platform: Linux-6.9.12-200.fc40.x86_64-x86_64-with-glibc2.39
sys.maxsize > 2**32: True
platform.python_version: 3.9.19
oracledb.version: 2.3.0
database version: 19.13.0.0.0
Session time zone: -04:00
Stored old value: 2024-08-04T12:11:13.123-04:00
Parsed old value: 2024-08-04T12:11:13.123
Binding variable: 2024-08-04T13:24:45.272-04:00
Stored new value: 2024-08-04T13:24:45.272+00:00
Parsed new value: 2024-08-04T13:24:45.272
Python script that shows the problem
from datetime import datetime, timezone
from os import environ
from platform import platform, python_version
from sys import maxsize
from oracledb import (
DB_TYPE_TIMESTAMP_TZ,
clientversion,
connect,
init_oracle_client,
version,
)
# read connect info and mode from environment variables
thick_mode = environ.get("DB_THICK_MODE", "false").lower() == "true"
dsn = environ.get("DB_DSN", "localhost:1521/orcl")
user = environ.get("DB_USER", "scott")
password = environ.get("DB_PASSWORD", "tiger")
# sql statements
session_stmt = r"select sessiontimezone from dual"
select_stmt = r"""select to_char(test_ts, 'yyyy-mm-dd"T"hh24:mi:ss.fftzh:tzm'),
test_ts from test_tz where test_id = 1"""
update_stmt = r"update test_tz set test_ts = :dt where test_id = 1"
print("platform.platform:", platform())
print("sys.maxsize > 2**32:", maxsize > 2**32)
print("platform.python_version:", python_version())
print("oracledb.version:", version)
if thick_mode:
init_oracle_client()
print("client version:", ".".join(str(n) for n in clientversion()))
with connect(dsn=dsn, user=user, password=password) as conn:
print("database version:", conn.version)
with conn.cursor() as cursor:
# get session time zone
cursor.execute(session_stmt)
print("\nSession time zone:", cursor.fetchone()[0])
# read old value
cursor.execute(select_stmt)
result = cursor.fetchone()
print("\nStored old value:", result[0])
print("Parsed old value:", result[1].isoformat(timespec="milliseconds"))
# update with current date truncated to milliseconds
dt = datetime.now(timezone.utc).astimezone()
dt = dt.replace(microsecond=dt.microsecond // 1000 * 1000)
print("\nBinding variable:", dt.isoformat(timespec="milliseconds"))
cursor.prepare(update_stmt)
cursor.setinputsizes(dt=DB_TYPE_TIMESTAMP_TZ)
cursor.execute(None, dt=dt)
# read new value
cursor.execute(select_stmt)
result = cursor.fetchone()
print("\nStored new value:", result[0])
print("Parsed new value:", result[1].isoformat(timespec="milliseconds"))
SQL needed to create the database schema
create table test_tz (
test_id number(19),
test_ts timestamp(3) with time zone,
primary key(test_id)
);
insert into test_tz values (1, timestamp '2024-08-04 12:11:13.123');
commit;
- Ngôn ngữ chính
- Python
- Star
- 455
- Fork
- 119
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của oracle/python-oracledb
-
Client Library or Database
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
oracle/python-oracledb#620 · 3 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
oracle/python-oracledb#619 ·
-
asyncio: DPY-4011 on connect_async() when the listener closes the original socket after a redirectCó thể đã có người làm @AlexGracas đã nhận 9 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
oracle/python-oracledb#616 ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
oracle/python-oracledb#615 ·
-
Fetch character columns as raw bytes in the database character set into data frames (Thick mode)Đang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
oracle/python-oracledb#614 · 1 bình luận ·
Tất cả issue của oracle/python-oracledb
Issue tương tự
-
documentation good first issue
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
sujithputta02/Esapay#13 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Flaky: credential-proxy admission metric test asserts a wall-clock bound it does not establishĐang mởneeds-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
gke-labs/kube-agents#3277 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jbacalso24/mimry#291 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 82/100
eli-alvarado/us-watchlist-alerts#14 ·
Maintainer thường phản hồi trong vòng 1 ngày