DDBI

dbi.util.SqlGen



class SqlGenerator ;
Helper methods for generating database-specific SQL (without necessarily knowing the specifics of that database's ways of quoting and escaping).

char identifierQuoteChar ();


char stringQuoteChar ();


abstract char[] toNativeType (ColumnInfo info);


final SqlGenerator start (SqlStringWriter_ writer = cast(SqlStringWriter_)null);
Starts chained writing - used together with the write, list, and qlist method as a convenient way of dynamically generating sql.

Example:
 	auto writer = new SqlStringWriter;
 	auto sql = db.sqlGen.start(writer)("SELECT ").list("name","date")
 	(" FROM ").id("user")("WHERE ").id("id")("=?").get;


final SqlGenerator write (char[][] strs...);


alias opCall ;
Alias for write

final SqlGenerator list (char[][] identifiers...);
Writes a list of quoted identifiers

alias id ;
Alias for list - for quoting a single identifier

final SqlGenerator qlist (char[] qualifier, char[][] identifiers...);
Writes a list of quoted, qualified identifiers.

Should be very useful for doing join queries.

Example:
 qlist("user","name","date") // generates "user"."name","user"."date"


alias qid ;
Alias for qlist - for quoting a single qualified identifier

final char[] get ();
Returns:
the sql that has been written

char[] makeInsertSql (SqlStringWriter_ writer, char[] tablename, char[][] fields...);


char[] makeUpdateSql (SqlStringWriter_ writer, char[] tablename, char[] whereClause, char[][] fields...);


char[] makeCreateSql (char[] tablename, ColumnInfo[] columnInfo, char[] options = null);


char[] makeAddColumnSql (char[] tablename, ColumnInfo column);


char[] makeDropSql (char[] tablename, bool checkExists = true);


Documentation last updated Tue Jan 27 00:09:30 2009