Changes between Initial Version and Version 1 of Ticket #31730, comment 5


Ignore:
Timestamp:
Jun 27, 2020, 1:06:17 AM (4 years ago)
Author:
axil

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31730, comment 5

    initial v1  
    1 > Before any code is added here
    2 It might have come unnoticed but there is the code already ;)
    3 https://github.com/django/django/blob/6f33f7dcf3ef20d0585bece747887c7054cf2189/django/db/backends/sqlite3/operations.py#L232-L257
    4 
    5 > I think that we should add backend agnostics tests for the command that execute the provided SQL and assert it has the desired effects.
    6 One of the tests that I've added (django/tests/backends/tests.py:SequenceResetTest.test_reset_sequence) looks pretty backend agnostic to me:
    7 https://github.com/axil/django/blob/7de27842c038d087257ebdd8e964f8921cd68295/tests/backends/tests.py#L186-L203
    8 I've improved it a bit now.
    9 
    10 >In a following commit the logic that identifies the sequences that need to be reset should be moved to the command itself
    11 Actually of the logic identifying the sequences has already been moved to the django.core.commands.sqlsequencerest:
    12 https://github.com/django/django/blob/6f33f7dcf3ef20d0585bece747887c7054cf2189/django/core/management/commands/sqlsequencereset.py#L17-L25
    13 or to be precise to `app_config.get_models(include_auto_created=True)`. By that reason
    14 
    151> to avoid the huge amount of boilerplate repeated in the current PostgreSQL and Oracle DatabaseOperations implementations.
    16 this boilerplate can be cut in half as I suggest in #31731. In what is left after that yes, postgresql and oracle share the same logic and can be refactored, but sqlite needs a somewhat different SQL statement so I see little room for refactoring here.
    17 
    18 > That will also avoid leaking db.models abstraction to the db.backends ones
    19 Yes, my patch doesn't do that.
    20 
    21 
     2this boilerplate can be cut in half as I suggest in #31731
Back to Top