Re: [Django] #24638: New feature: support adding an SQL comment in queries

2022-05-18 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  Adam Johnson |Owner:  Hannes
 |  Ljungberg
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Hannes Ljungberg):

 * needs_docs:  1 => 0
 * version:  1.8 => dev


Comment:

 PR: https://github.com/django/django/pull/15711

-- 
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/01070180d8a8b26a-82002346-b142-4e97-bc0e-8bf328624205-00%40eu-central-1.amazonses.com.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2022-05-18 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  Adam Johnson |Owner:  Hannes
 |  Ljungberg
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Hannes Ljungberg):

 * owner:  nobody => Hannes Ljungberg
 * 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/01070180d6ece1e7-116a446e-6be1-484c-8542-2be21d5c743a-00%40eu-central-1.amazonses.com.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2020-01-04 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  Adam (Chainz)|Owner:  nobody
  Johnson|
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Susie Murray):

 I want to know [https://tspiglobal.com/communication/who-invented-the-
 internet/ who invented the internet]

-- 
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/068.08fd8b7a81c1c8049d2a40aa0744c773%40djangoproject.com.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2015-05-17 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by adamchainz):

 For the record, here's the first open-source version of the regex-based
 SQL-rewriting code I have that adds MySQL's `STRAIGHT_JOIN`:
 https://github.com/adamchainz/django-
 mysql/commit/cf69c24962c4a22cc2fac5b29319777ee2a44fb0 . If we can't add
 `.comment()`, this is the probably the best solution possible.

--
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/068.97d67992b16e184b1f2e1b8a8b7113e2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2015-04-19 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by adamchainz):

 MSSQL - it appears all hints come in an OPTION clause after HAVING:
 https://msdn.microsoft.com/en-us/library/ms189499.aspx
 DB2 - it appears hints come in a %_HINTS clause after WHERE:
 http://scn.sap.com/thread/1573275

 So yes, unfortunately this is not general-purpose enough for adding query
 hints.

 I did try an implementation with the comments injected on
 DeleteSQLCompiler but the cascade did lead to it pretty broken since the
 query hint for delete was carried to the selects. User generated selects
 only sounds good - the current patch does update too, but it's not often
 you want to add hints on them anyway as there are no joins.

--
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/068.921b7bf4ef4dd7afd0ade2468855ac91%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2015-04-16 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by akaariai):

 It might be a bit ugly if we have to support multiple places for the
 comment. What about MSSQL, DB2 and other non-core backends? I'm not sure
 what is the best way to alter the generated SQL if we need support for
 injecting hints in arbitrary places.

 Also, are we ok with support for read queries only, or should we have it
 for update/delete/insert queries, too? The delete queries might be
 especially hard for cascades. Maybe we should aim for "user generated
 select queries only" for the first implementation?

--
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/068.9c71a4a9d0f1a4c480f0782bdb5f3084%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2015-04-16 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by adamchainz):

 For reference (checking I did get the right place for Oracle and MySQL
 query hints):

 1. MySQL hints are listed in its syntax
 https://dev.mysql.com/doc/refman/5.5/en/select.html (STRAIGHT_JOIN,
 SQL_NO_CACHE, etc.). They can be inserted as comments by starting the
 comment with an exclamation mark, which pretty much means "this is not a
 comment" (the reason this exists is that if you follow the exclamation
 mark with an encoded version number, that SQL will only be executed on
 versions of the server at that version or above). Also newer more powerful
 hints are coming in 5.7 with comments that start with a + :
 https://dev.mysql.com/worklog/task/?id=8017

 2. Oracle has extensive documentation on its hints which appear only in
 conditional comments, although the page is lacking in examples:
 http://docs.oracle.com/cd/B19306_01/server.102/b14211/hintsref.htm .
 However the syntax for SELECT does show hints going *before* DISTINCT:
 http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10002.htm
 , however this blog post shows them after: http://www.dba-
 oracle.com/t_index_fast_full_scan.htm .

--
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/068.1bf994926f14ba90f5415e989ea609f2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2015-04-14 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * needs_docs:  0 => 1
 * 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 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/068.4554f92fd900791ba1da1801c557065d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2015-04-14 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:  Accepted
  comment, optimizer hint|
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by akaariai):

 * stage:  Unreviewed => Accepted


--
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/068.71d66fb60aae21bf6330bedb58f93883%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2015-04-14 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:
  comment, optimizer hint|  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by stevemcc):

 * type:  Uncategorized => New feature


--
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/068.6e32ab0b1abfb0bb520ea763849c3926%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24638: New feature: support adding an SQL comment in queries

2015-04-13 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |Owner:  nobody
 Type:  Uncategorized|   Status:  new
Component:  Database layer   |  Version:  1.8
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, query, | Triage Stage:
  comment, optimizer hint|  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by adamchainz):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Ticket https://github.com/django/django/pull/4495

 No documentation yet, don't know if it will be accepted...

--
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/068.59a2d05b6d1f117e0145a01daa3ef80d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #24638: New feature: support adding an SQL comment in queries

2015-04-13 Thread Django
#24638: New feature: support adding an SQL comment in queries
-+-
 Reporter:  adamchainz   |  Owner:  nobody
 Type:  Uncategorized| Status:  new
Component:  Database layer   |Version:  1.8
  (models, ORM)  |   Keywords:  queryset, query,
 Severity:  Normal   |  comment, optimizer hint
 Triage Stage:  Unreviewed   |  Has patch:  0
Easy pickings:  0|  UI/UX:  0
-+-
 This feature gives QuerySet a `.comment(text)` method that inserts text
 into a comment in the output SQL query, right after the `SELECT
 [DISTINCT]` part. This has two uses:

 1. For all database backends, this can be used for feature-to-query
 tracking. For example, you might override `def queryset` on your admin
 classes to use `comment()` to insert the name of the admin class
 generating the query, making query analysis (processlist, slow query logs,
 etc.) easier to track back to the point in the code generating the
 queries. This is not trivial.

 I've seen Facebook have nice tools that automatically insert file/line
 number summaries into queries as comments to make analysis easy. Adding
 `comment()` would making this easy for custom QuerySet subclasses to do
 this however they want, with e.g. caller inspection at `__init__` time.

 2. For the MySQL and Oracle backends, flags and optimizer hints can be
 added. Both have a number of options for queries that are otherwise
 unsupported on django, and they can be inserted with special comments.

 This is my current motivation - I had a pretty complex 3-join/5-subquery
 MySQL query today that could only be made good on the ORM by adding
 MySQL's "STRAIGHT_JOIN" hint, and the only way I found to do this in
 Django at current was to monkey-patch the MySQL backend CursorWrapper's
 execute() to rewrite the generated query with regexes... :( And it
 couldn't use raw() since it was being passed to the admin with the ability
 to filter it.

 I couldn't find any historical tickets on optimizer hints.

--
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/053.31a5c9941541c6e6dd8edd78a4d0468e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.