Re: [Django] #29865: Add XOR for use in Q Queries

2021-07-14 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  Ryan
 |  Heard
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nick Pope):

 * stage:  Someday/Maybe => Accepted


Comment:

 I'd missed that this was triaged as "Someday/Maybe", but I'm accepting
 based on the fact that we have a plausible implementation in
 [https://github.com/django/django/pull/14480 this PR].

-- 
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/063.44b1afdd5ad51575d5659328048dbcac%40djangoproject.com.


Re: [Django] #29865: Add XOR for use in Q Queries

2021-07-02 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  Ryan
 |  Heard
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Ryan Heard):

 * needs_better_patch:  1 => 0


-- 
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/063.d62bd5d2ea86e57cf4533c5caa1a49a7%40djangoproject.com.


Re: [Django] #29865: Add XOR for use in Q Queries

2021-07-02 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  Ryan
 |  Heard
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nick Pope):

 * needs_better_patch:  0 => 1


-- 
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/063.2df24a081b8573a0ed452a1cb40ba7be%40djangoproject.com.


Re: [Django] #29865: Add XOR for use in Q Queries

2021-06-07 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  Ryan
 |  Heard
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Ryan Heard):

 After careful consideration I have decided not to raise a `TypeError` on
 unsupported backends, and instead convert on the fly from `A XOR B` to `(A
 OR B) AND NOT (A AND B)`.

 MySQL will still take advantage of logical XOR.

-- 
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/063.44344f03e17402fce233fc211b3fb515%40djangoproject.com.


Re: [Django] #29865: Add XOR for use in Q Queries

2021-06-02 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  Ryan
 |  Heard
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Jacob Walls):

 * owner:  nobody => Ryan Heard
 * status:  new => assigned
 * has_patch:  0 => 1


-- 
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/063.e50e641ae9d6810c0cbf6f4c064acb72%40djangoproject.com.


Re: [Django] #29865: Add XOR for use in Q Queries

2021-06-02 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Ryan Heard):

 Replying to [ticket:29865 Griffith Rees]:
 > XOR seems to be available in [https://www.postgresql.org/docs/8.4/static
 /functions-math.html Postgresql], [https://dev.mysql.com/doc/refman/8.0/en
 /logical-operators.html MySQL], [https://docs.microsoft.com/en-us/sql/mdx
 /xor-mdx?view=sql-server-2017 SequelServer] and
 [https://docs.oracle.com/cd/E17952_01/mysql-5.1-en/logical-operators.html
 Oracle] but NOT [https://stackoverflow.com/questions/2294137/sqlite-
 exclusive-or-how-do-i-clear-a-flag sqlite]. Two stackoverflow questions
 cover this sort of thing: [https://stackoverflow.com/questions/50408142
 /django-models-xor-at-the-model-level] and
 [https://stackoverflow.com/questions/14711203/perform-a-logical-exclusive-
 or-on-a-django-q-object].
 >
 > I propose adding XOR to work with Q queries like the
 [https://stackoverflow.com/a/21220712/678486 answer]  to the second
 question above. This will be my first time making a major contribution so
 we'll see how this goes (apologies in advance if this is annoying!).
 I started on this hoping to use it on my own postgres site, only to
 realize that postgres does not support logical XOR. Too bad, as it would
 help with not executing large subqueries multiple times.

 Never-the-less I have created a PR with the proposed changes for this
 [https://github.com/django/django/pull/14480 here], which probably needs
 some TLC from a more advanced contributor. This code should add support
 for XOR across the codebase, to both `Q` objects and `QuerySets`, and
 ensure it gets down the SQL fed to the database.

 Note that a TypeError is raised if XOR is attempted on an unsupported
 backend. This seemed safer than converting on the fly to (A AND ~B) OR (~A
 AND B), since doing that could lead to some unintended results when the
 user is expecting XOR to be used. If it is decided that a conversion would
 be more desirable, then the code can be changed.

-- 
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/063.66ea15739e0a1e3d30b350267e01a7da%40djangoproject.com.


Re: [Django] #29865: Add XOR for use in Q Queries

2019-12-07 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by jishansingh):

 XOR can be implemented by

 {{{
 def __xor__(self,other):
 return
 self.__or__(other).__and__(self.__invert__().__or__(other.__invert__()))
 }}}
 it works for sqlite (possibly for others)
 wouldn't it solves the problem

-- 
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/063.175327657d3947a03939ef4a15988c64%40djangoproject.com.


Re: [Django] #29865: Add XOR for use in Q Queries

2019-07-31 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Nick Pope):

 Replying to [comment:4 Marten Kenbeek]:
 > To be clear, you're talking about logical `XOR`, and not bitwise `XOR`?

 As you've highlighted, this should be for logical `XOR` and not bitwise
 `XOR`. So this is only supported for MariaDB and MySQL which have `XOR`.

 This could be implemented by defining `Q.XOR` and `Q.__xor__()` and then
 propagating that around the place.
 It could be possible to support this for other backends by specifying
 `connection.features.supports_logical_xor = False` and then writing out
 the query differently.

 For `Q(a=1) ^ Q(b=2)`, the supporting backends would output `(a = 1 XOR a
 = 2)`, while the others could output `((a = 1 OR b = 2) AND NOT (a = 1 AND
 b = 2))`.

-- 
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/063.152d03c2a56a78ce53947dbb68fd56ca%40djangoproject.com.


Re: [Django] #29865: Add XOR for use in Q Queries

2018-10-20 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Marten Kenbeek):

 To be clear, you're talking about logical `XOR`, and not bitwise `XOR`?

 You linked to PostgreSQL's bitwise `XOR` operator, `#`. At the moment it
 does not have a logical `XOR` operator. The only
 [https://www.postgresql.org/docs/current/static/functions-logical.html
 logical operators] it supports are `AND`, `OR` and `NOT`.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.c0ef5a44c60154f955ce8b00e1534061%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29865: Add XOR for use in Q Queries

2018-10-20 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * cc: felixxm (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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.d7f6b3eb1ee1b1d785678e6f44ca2806%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29865: Add XOR for use in Q Queries

2018-10-20 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by felixxm):

 `XOR` is not officially supported on Oracle (see
 [https://docs.oracle.com/database/121/SQLRF/functions002.htm#SQLRF51178
 doc]) you pointed to the old MySQL documentation.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.7edef6e4c2300865c15441a12465f4f0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29865: Add XOR for use in Q Queries

2018-10-18 Thread Django
#29865: Add XOR for use in Q Queries
-+-
 Reporter:  Griffith Rees|Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  xor  | Triage Stage:
 |  Someday/Maybe
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

 * stage:  Unreviewed => Someday/Maybe


Comment:

 It's probably best to write to the DevelopersMailingList to see if there's
 consensus about this (although having a working patch may help evaluate
 the idea). I wonder if it's possible to emulate XOR on SQLite similar to
 what we do for some other database functions.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.db5af5ab55076fd9fbf90390bd542373%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #29865: Add XOR for use in Q Queries

2018-10-18 Thread Django
#29865: Add XOR for use in Q Queries
-+-
   Reporter:  spool  |  Owner:  nobody
   Type:  New| Status:  new
  feature|
  Component:  Database   |Version:  2.1
  layer (models, ORM)|
   Severity:  Normal |   Keywords:  xor
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 XOR seems to be available in [https://www.postgresql.org/docs/8.4/static
 /functions-math.html Postgresql], [https://dev.mysql.com/doc/refman/8.0/en
 /logical-operators.html MySQL], [https://docs.microsoft.com/en-us/sql/mdx
 /xor-mdx?view=sql-server-2017 SequelServer] and
 [https://docs.oracle.com/cd/E17952_01/mysql-5.1-en/logical-operators.html
 Oracle] but NOT [https://stackoverflow.com/questions/2294137/sqlite-
 exclusive-or-how-do-i-clear-a-flag sqlite]. Two stackoverflow questions
 cover this sort of thing: [https://stackoverflow.com/questions/50408142
 /django-models-xor-at-the-model-level] and
 [https://stackoverflow.com/questions/14711203/perform-a-logical-exclusive-
 or-on-a-django-q-object].

 I propose adding XOR to work with Q queries like the
 [https://stackoverflow.com/a/21220712/678486 answer]  to the second
 question above. This will be my first time making a major contribution so
 we'll see how this goes (apologies in advance if this is annoying!).

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.9eda1ca96945ea4cf5f1f25983bed784%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.