Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2022-09-26 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by David Sanders):

 Hi Matthieu,

 In terms of new features for the framework, it's always a good idea to
 start a thread on the mailing list or forum to see what support there is
 for the feature: https://code.djangoproject.com/wiki/DevelopersMailingList
 

 Documentation updates are always welcomed. Small updates to documentation
 don't require a ticket. I'm not the authority on what the exact
 responsibilities are for ExpressionWrapper but I kinda view it as just
 glueing up the expressions with correct types without any explicit casting
 路‍♂️  Will probably need to clarify that with someone closer to the ORM
 code.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018379307b41-84ad5804-c916-43e2-926d-c3ef282fd9ab-00%40eu-central-1.amazonses.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2022-09-26 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Matthieu Rigal):

 Replying to [comment:6 David Sanders]:
 > There are a few ways to address this but IMHO I don't think anything
 should be done here as this is documented PostgreSQL behaviour [1]
 >
 > Therefore I'd recommend this ticket be marked `wontfix`.
 >
 > I think it's the developers responsibility to cast in this situation
 instead of using `ExpressionWrapper`:
 >
 > {{{
 > next_segments = StartModel.objects.filter('start__gt':
 OuterRef('start')).order_by('start')
 > qs = StartModel.objects.annotate(
 > end=Cast(
 > Subquery(next_segments.values('start')[:1]) -
 datetime.timedelta(days=1),
 > output_field=DateField(),
 > )
 > )
 > }}}
 >
 >
 > [1] https://www.postgresql.org/docs/current/functions-datetime.html
 #OPERATORS-DATETIME-TABLE

 Thanks David!
 Seeing it from a PostgreSQL perspective, it makes sense, as interval has
 the precision of a timestamp!
 However, as this is pretty surprising from a Pythonic point-of-view, I
 would rather consider extending the documentation to warn about this
 potential trap. It should be clear that `timedelta` can only be cast (by
 Psycopg2) to an interval and therefore does not allow the use of the `date
 +/- integer → date` operation of PostgreSQL.

 Besides the example with `Cast` one may add that in case this patterns is
 recurrent, it may be worth adding that creating a custom Field `DateDelta`
 translating to integer on PostrgeSQL side, could be an option...

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018378ff4ea3-edfab130-e5ca-46fd-9d98-8647e78f7d6e-00%40eu-central-1.amazonses.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2022-09-26 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by David Sanders):

 * cc: David Sanders (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018378e4370e-84657725-5bef-4922-a26e-d116e439bc61-00%40eu-central-1.amazonses.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2022-09-26 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Sergey Fedoseev):

 * cc: Sergey Fedoseev (removed)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018378c0d684-fceaf51e-9c02-4e23-87ce-f499ffa69dfc-00%40eu-central-1.amazonses.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2022-09-26 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by David Sanders):

 There are a few ways to address this but IMHO I don't think anything
 should be done here as this is documented PostgreSQL behaviour [1]

 Therefore I'd recommend this ticket be marked `wontfix`.

 I think it's the developers responsibility to cast in this situation
 instead of using `ExpressionWrapper`:

 {{{
 next_segments = StartModel.objects.filter('start__gt':
 OuterRef('start')).order_by('start')
 qs = StartModel.objects.annotate(
 end=Cast(
 Subquery(next_segments.values('start')[:1]) -
 datetime.timedelta(days=1),
 output_field=DateField(),
 )
 )
 }}}


 [1] https://www.postgresql.org/docs/current/functions-datetime.html
 #OPERATORS-DATETIME-TABLE

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018378b8abb5-e4257359-0d0c-46fc-ad65-875cf678de0a-00%40eu-central-1.amazonses.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2021-01-27 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by TapanGujjar):

 * owner:  TapanGujjar => (none)
 * status:  assigned => new


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.8bd1ba14b89412c945cae1f165088148%40djangoproject.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2020-05-14 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:
 |  TapanGujjar
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by TapanGujjar):

 Hi, the issue is because the DateField has no field converter or
 db_converter to convert the value which we got from the database to the
 DateField type. I can implement the field converter for the data field but
 Is the DateField not having the field converter or db_converter by design?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.95eb3254df19fa810536d388ca88c9e7%40djangoproject.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2020-05-08 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:
 |  TapanGujjar
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by TapanGujjar):

 * owner:  nobody => TapanGujjar
 * status:  new => assigned


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.0d37a3336da87349022a39f60a2e14ce%40djangoproject.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL.

2020-04-22 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * Attachment "test_31506.diff" added.


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.ddd6c685ecb6c6eea86757b599830563%40djangoproject.com.


Re: [Django] #31506: ExpressionWrapper() doesn't respect output_field when combining DateField and timedelta on PostgreSQL and MySQL. (was: ExpressionWrapper on DateField + timedelta always returns Da

2020-04-22 Thread Django
#31506: ExpressionWrapper() doesn't respect output_field when combining 
DateField
and timedelta on PostgreSQL and MySQL.
-+-
 Reporter:  Matthieu Rigal   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * cc: Josh Smeaton (added)
 * version:  2.2 => master
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for this ticket. I reproduced this issue on MySQL and PostgreSQL. I
 attached a simple test.

 Reproduced at 060d9d4229c436c44cf8e3a301f34c4b1f9f6c85.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.b21f2bcd945a58838ec083a323da573f%40djangoproject.com.