Opened 7 years ago
Closed 7 years ago
#28652 closed Cleanup/optimization (fixed)
Small fixes to some comments in django/db/models/query.py
Reported by: | Дилян Палаузов | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
diff --git a/django/db/models/query.py b/django/db/models/query.py --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -240,7 +240,7 @@ class QuerySet(object): - Returns 100 rows at time (constants.GET_ITERATOR_CHUNK_SIZE) using cursor.fetchmany(). This part is responsible for doing some column masking, and returning the rows in chunks. - 2. sql/compiler.results_iter() + 2. sql.compiler:results_iter() - Returns one row at time. At this point the rows are still just tuples. In some cases the return values are converted to Python values at this location. @@ -417,7 +417,7 @@ class QuerySet(object): # insert into the childmost table. # We currently set the primary keys on the objects when using # PostgreSQL via the RETURNING ID clause. It should be possible for - # Oracle as well, but the semantics for extracting the primary keys is + # Oracle as well, but the semantics for extracting the primary keys is # trickier so it's not done yet. assert batch_size is None or batch_size > 0 # Check that the parents share the same concrete model with the our @@ -1079,7 +1079,7 @@ class QuerySet(object): def _batched_insert(self, objs, fields, batch_size): """ - A little helper method for bulk_insert to insert the bulk one batch + A little helper method for bulk_create to insert the bulk one batch at a time. Inserts recursively a batch from the front of the bulk and then _batched_insert() the remaining objects again. """ diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -894,8 +894,7 @@ class SQLCompiler(object): raise original_exception if result_type == CURSOR: - # Caller didn't specify a result_type, so just give them back the - # cursor to process (and close). + # Just give the caller back the cursor to process (and close). return cursor if result_type == SINGLE: try: diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -183,10 +183,11 @@ class InsertQuery(Query): def insert_values(self, fields, objs, raw=False): """ - Set up the insert query from the 'insert_values' dictionary. The - dictionary gives the model field names and their target values. + Set up the insert query from the 'fields' tuple and 'objs'. The + tuple/list gives the model field names that are retrieved from + each 'objs'. - If 'raw_values' is True, the values in the 'insert_values' dictionary + If 'raw' is True, the values in the 'objs' dictionary are inserted directly into the query, rather than passed as SQL parameters. This provides a way to insert NULL and DEFAULT keywords into the query, for example.
Change History (3)
comment:1 by , 7 years ago
Summary: | Clarify comments → Small fixes to some comments in django/db/models/query.py |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 7 years ago
On maser not much has changed, apart from removing the docstring from sql/subquery.py:InsertQuery:insert_values
diff --git a/django/db/models/query.py b/django/db/models/query.py --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -232,7 +232,7 @@ class QuerySet: - Returns 100 rows at time (constants.GET_ITERATOR_CHUNK_SIZE) using cursor.fetchmany(). This part is responsible for doing some column masking, and returning the rows in chunks. - 2. sql/compiler.results_iter() + 2. sql.compiler.results_iter() - Returns one row at time. At this point the rows are still just tuples. In some cases the return values are converted to Python values at this location. @@ -402,7 +402,7 @@ class QuerySet: # insert into the childmost table. # We currently set the primary keys on the objects when using # PostgreSQL via the RETURNING ID clause. It should be possible for - # Oracle as well, but the semantics for extracting the primary keys is + # Oracle as well, but the semantics for extracting the primary keys is # trickier so it's not done yet. assert batch_size is None or batch_size > 0 # Check that the parents share the same concrete model with the our diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -889,8 +889,7 @@ class SQLCompiler: raise if result_type == CURSOR: - # Caller didn't specify a result_type, so just give them back the - # cursor to process (and close). + # Just give the caller back the cursor to process (and close). return cursor if result_type == SINGLE: try:
Note:
See TracTickets
for help on using tickets.
Thanks for the suggestions. Are you able to submit a GitHub pull request to Django's master branch? Some of these issues are already fixed there.