New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #30128 -- Fixed handling timedelta timezone in database functions. #10910
Conversation
django/db/backends/sqlite3/base.py
Outdated
if '+' in tzname: | ||
tzname = tzname.split('+')[0] | ||
elif '-' in tzname: | ||
tzname = tzname.split('-')[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after that, I want to add a code block whose purpose is to convert the string to time. Is there another way to solve this?
Does one test cover all the new code? Oracle also needs to be addressed. Possibly add something to the 3.0 release notes under "Database backend API" about how third party databases need to adapt. |
4cd43ed
to
a7a7bc3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bar release note change, looks OK I think.
buildbot, test on oracle.
docs/releases/3.0.txt
Outdated
@@ -213,6 +213,15 @@ backends. | |||
|
|||
* ``DatabaseIntrospection.get_field_type()`` may no longer return tuples. | |||
|
|||
* ``DatabaseOperations._prepare_tzname_delta()`` is used to customize the database spesific time zone delta function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this block quite makes sense as it is: _prepare_tzname_delta()
is a private helper used only in the already private _convert_field_to_tz()
— there's no guarantee at all that a backend will implement either. (The SQLite backend doesn't, for example...)
Maybe just something like:
Supported database backends now correctly handle ``timezone`` formats when
created using `timedelta` instances:
>>> from datetime import timezone, timedelta
>>> str(timezone(timedelta(hours=5)))
'UTC+05:00'
Third-party backends should ensure that they correctly handle this format when
preparing ``datetime`` fields in ``datetime_cast_date_sql()`` & co.
(@felixxm, @timgraham?)
Docs should be wrapped to 79 chars.
New test fails on Oracle. |
I had checked on Oracle. I've checked again and I can see that the test is successful. Could you share something with me to create your env on my test env |
@cansarigol it fails with |
Time to call in the fire service... 🚒 @felixxm: ORACLE ISSUE. PING. 😀 |
I use OracleVM and I guess it is a version problem. I use orcl12c |
I found this page, maybe would be helpful. https://community.oracle.com/thread/841802 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I tried to suggest in a previous comment, test coverage doesn't seem sufficient. I think the '-' in tzname:
branches aren't tested.
django/db/backends/sqlite3/base.py
Outdated
time_delta_params = {} | ||
for attr in {'second', 'minute', 'hour', 'millisecond'}: | ||
if hasattr(_offset_date, attr): | ||
time_delta_params["%ss" % attr] = _offset_date.__getattribute__(attr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getattr()
rather than calling a dunder method
@carltongibson I'll check in next few hours 🕵️♂️ , but Oracle version shouldn't be an issue. |
a7a7bc3
to
8f9dc0c
Compare
I added the test_operations in mysql so far. Is it ok? I can add tests for all backends and all operations funcs (datetime_extract_sql, datetime_trunc_sql etc.) and also sqlite3.base. we can publish with ref commit @timgraham |
8f9dc0c
to
5dd2f83
Compare
@cansarigol I think the point is to include them here first time, rather than later. Any reason not to do that? |
I didn't expect a low-level test. Is testing extract with, e.g. |
Sorry i couldn't understand that "include them" 😀 |
5dd2f83
to
fd7e1e6
Compare
Sorry, you are right I added it for negative timedelta. there was a problem on sqlite3 and I could fix it through the test. |
Oracle failure is a great mystery for me, at least for now 🕵️♂️. I checked on Oracle 12c, 18c and in the same Oracle DB that we use in Jenkins, all passed without failures. This can be related with some env variables. I need to take a closer look ... 🔍 |
088cf0d
to
ab4f168
Compare
hi @felixxm did you have a chance to take a look? and is there any problem with the second commit? |
@cansarigol Please send a fix to the 28373 as a separate PR, it is harder to trace fixes for multiple tickets in a single PR. Can you also rebase this branch from master and fix conflicts? |
a1bd9db
to
e2e6f6f
Compare
hi, commits are separated and rebased. |
sqlite failures related? |
as i remember, it is unrelated. We just have problem about oracle tests. |
@cansarigol Please rebase from master and resolve conflicts, after that I will take another round. |
ok I will |
16ef895
to
86ef63f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cansarigol I left few comments.
Sorry, late to the party, but is there a reason |
It is a part of internal API that is not implemented for all backends and it is used only in |
Thanks for explaining! |
Ticket: #30128