django_evolution.db.sql_result
Classes for storing SQL statements and Alter Table operations.
Classes
|
Represents one or more SQL statements or Alter Table rules. |
|
Represents one or more SQL statements. |
- class django_evolution.db.sql_result.SQLResult(sql=None, pre_sql=None, post_sql=None)
Bases:
objectRepresents one or more SQL statements.
This is returned by functions generating SQL statements. It can store the main SQL statements to execute, or SQL statements to be executed before or after the main statements.
SQLResults can easily be added together or converted into a flat list of SQL statements to execute.
- __init__(sql=None, pre_sql=None, post_sql=None)
- add(sql_or_result)
Adds a list of SQL statements or an SQLResult.
If an SQLResult is passed, its
pre_sql,sql, andpost_sqllists will be added to this one.If a list of SQL statements is passed, it will be added to this SQLResult’s sql list.
- Parameters:
sql_or_result (
object) –The SQL to add. This may be one of the following:
Anopther instance of
SQLResultA list of SQL statements
A single SQL statement
A tuple pair containing the SQL statement and arguments for that statement
A function to call later when executing SQL statements
- Raises:
TypeError –
sql_or_resultwasn’t a supported type.
- add_pre_sql(sql_or_result)
Adds a list of SQL statements or an SQLResult to
pre_sql.If an SQLResult is passed, it will be converted into a list of SQL statements.
- add_sql(sql_or_result)
Adds a list of SQL statements or an SQLResult to
sql.If an SQLResult is passed, it will be converted into a list of SQL statements.
- add_post_sql(sql_or_result)
Adds a list of SQL statements or an SQLResult to
post_sql.If an SQLResult is passed, it will be converted into a list of SQL statements.
- normalize_sql(sql_or_result)
Normalizes a list of SQL statements or an SQLResult into a list.
If a list of SQL statements is provided, it will be returned. If an SQLResult is provided, it will be converted into a list of SQL statements and returned.
- to_sql()
Flattens the SQLResult into a list of SQL statements.
- __repr__()
Return repr(self).
- class django_evolution.db.sql_result.AlterTableSQLResult(evolver, model, alter_table=None, *args, **kwargs)
Bases:
SQLResultRepresents one or more SQL statements or Alter Table rules.
This is returned by functions generating SQL statements. It can store the main SQL statements to execute, or SQL statements to be executed before or after the main statements.
SQLResults can easily be added together or converted into a flat list of SQL statements to execute.
- __init__(evolver, model, alter_table=None, *args, **kwargs)
- add(sql_result)
Adds a list of SQL statements or an SQLResult.
If an SQLResult is passed, its
pre_sql,sql, andpost_sqllists will be added to this one.If an AlterTableSQLResult is passed, its
alter_tablelists will also be added to this one.If a list of SQL statements is passed, it will be added to this SQLResult’s sql list.
- add_alter_table(alter_table)
Adds a list of Alter Table rules to
alter_table.
- to_sql()
Flattens the AlterTableSQLResult into a list of SQL statements.
Any
alter_tableentries will be collapsed together into ALTER TABLE statements.
- __repr__()
Return repr(self).
- __annotations__ = {}