Introduce new structures for storing SQL statements.

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

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.

    Loading...