tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

The process of datetime and MySQL interaction is described implicitly

Open dejurin opened this issue 3 years ago • 0 comments

Describe the bug The process of datetime and MySQL interaction is described implicitly

To Reproduce

current_time = datetime.utcnow()
day_begin = datetime(current_time.year, current_time.month, current_time.day, 0, 0, 0)

where = Q(
  Q(put_time__gte=day_begin),
  Q(put_time__lt=current_time),
  join_type="AND"
)
 
await MyModel.filter(where).sql()
SELECT `name`,`put_time` 
FROM `table` 
WHERE `put_time`>='2022-07-14T00:00:00' 
AND `put_time`<'2022-07-14T11:34:32.436741'

Expected behavior I am expected to receive all records that were created from 00:00 hours inclusive of the current day to the end time NOT included. In fact, we get records up to and including the end time because we are dealing with milliseconds because of datetime specifics.

dejurin avatar Jul 14 '22 11:07 dejurin