• 
      

    Introduce new structures for storing SQL statements.

    Review Request #5187 — Created Jan. 3, 2014 and submitted

    Information

    Django Evolution
    master

    Reviewers

    Introduce new structures for storing SQL statements.

    This introduces SQLResult and AlterTableSQLResult, which are used to
    return and store lists of SQL statements.

    SQLResult has three fields: pre_sql, sql, and post_sql. pre_sql and
    post_sql are used to store SQL statements that should be executed
    before/after sql. These can be converted to a single list of SQL
    statements with the to_sql() function.

    AlterTableSQLResult extends this to also have an alter_table field that
    contains a list of ALTER TABLE rules. When calling to_sql(), these are
    turned into ALTER TABLE statements.

    Where these structures come into play is with the next round of
    optimizations. By knowing up-front what SQL statements must be executed
    before/after a main set of statements, and which ALTER TABLE rules are
    going to be executed, a post-processor will be able to batch operations
    in an intelligent way. For example, joining all the results together to
    drop all indexes before a batch of statements, combining ALTER TABLE
    rules into a single ALTER TABLE statement, and then creating all new
    indexes after they execute.

    That will come in the next big change.

    All unit tests pass for all supported database types.

    The SQL result of an upgrade from RB 1.7.x to 2.0 remained unchanged,
    since optimizations aren't added yet.

    Description From Last Updated

    This would be just as legible as [{'sql': alter_table_item}]

    david david

    Same here w/ formatting.

    david david

    In general, I try to pass format parameters as additional arguments to logging.*() instead of doing the format myself, since …

    david david
    chipx86
    chipx86
    1. Going to make some changes to how AlterTableSQLResult works. Might want to hold off.

    2. 
        
    chipx86
    david
    1. 
        
    2. django_evolution/db/mysql.py (Diff revision 3)
       
       
       
       
       
       
      Show all issues

      This would be just as legible as [{'sql': alter_table_item}]

    3. django_evolution/db/postgresql.py (Diff revision 3)
       
       
       
       
       
       
      Show all issues

      Same here w/ formatting.

    4. django_evolution/mutators.py (Diff revision 3)
       
       
       
       
      Show all issues

      In general, I try to pass format parameters as additional arguments to logging.*() instead of doing the format myself, since it avoids processing the string twice.

    5. 
        
    chipx86
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed