From: Peter S. <sz...@us...> - 2004-05-03 14:33:27
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Tool/hbm2ddl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7876/NHibernate/Tool/hbm2ddl Modified Files: SchemaExport.cs Log Message: Added setdelimiter. Index: SchemaExport.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SchemaExport.cs 26 Mar 2004 16:57:28 -0000 1.7 --- SchemaExport.cs 3 May 2004 14:33:19 -0000 1.8 *************** *** 10,14 **** ! namespace NHibernate.Tool.hbm2ddl { /// <summary> /// Commandline tool to export table schema for a configured <c>Configuration</c> to the database --- 10,15 ---- ! namespace NHibernate.Tool.hbm2ddl ! { /// <summary> /// Commandline tool to export table schema for a configured <c>Configuration</c> to the database *************** *** 17,21 **** /// To compile run "csc SchemaExport.cs /reference:../../bin/debug/NHibernate.dll" /// </remarks> ! public class SchemaExport { private string[] dropSQL; private string[] createSQL; --- 18,23 ---- /// To compile run "csc SchemaExport.cs /reference:../../bin/debug/NHibernate.dll" /// </remarks> ! public class SchemaExport ! { private string[] dropSQL; private string[] createSQL; *************** *** 23,31 **** private string outputFile = null; private Dialect.Dialect dialect; /// <summary> /// Create a schema exported for a given Configuration /// </summary> ! public SchemaExport(Configuration cfg) : this(cfg, cfg.Properties) { } --- 25,35 ---- private string outputFile = null; private Dialect.Dialect dialect; + private string delimiter = null; /// <summary> /// Create a schema exported for a given Configuration /// </summary> ! public SchemaExport(Configuration cfg) : this(cfg, cfg.Properties) ! { } *************** *** 36,40 **** /// <param name="cfg"></param> /// <param name="connectionProperties"></param> ! public SchemaExport(Configuration cfg, IDictionary connectionProperties) { this.connectionProperties = connectionProperties; dialect = Dialect.Dialect.GetDialect(connectionProperties); --- 40,45 ---- /// <param name="cfg"></param> /// <param name="connectionProperties"></param> ! public SchemaExport(Configuration cfg, IDictionary connectionProperties) ! { this.connectionProperties = connectionProperties; dialect = Dialect.Dialect.GetDialect(connectionProperties); *************** *** 46,59 **** /// Set the output filename. The generated script will be written to this file /// </summary> ! public SchemaExport SetOutputFile(string filename) { outputFile = filename; return this; } ! /// <summary> /// Run the schema creation script /// </summary> ! public void Create(bool script, bool export) { ! Execute(script, export, false, true, null); } --- 51,74 ---- /// Set the output filename. The generated script will be written to this file /// </summary> ! public SchemaExport SetOutputFile(string filename) ! { outputFile = filename; return this; } ! ! /// <summary> ! /// Set the end of statement delimiter ! /// </summary> ! public SchemaExport SetDelimiter(string delimiter) ! { ! this.delimiter = delimiter; ! return this; ! } /// <summary> /// Run the schema creation script /// </summary> ! public void Create(bool script, bool export) ! { ! Execute(script, export, false, true); } *************** *** 61,69 **** /// Run the drop schema script /// </summary> ! public void Drop(bool script, bool export) { ! Execute(script, export, true, true, null); } ! private void Execute(bool script, bool export, bool justDrop, bool format, string delimiter) { IDbConnection connection = null; --- 76,85 ---- /// Run the drop schema script /// </summary> ! public void Drop(bool script, bool export) ! { ! Execute(script, export, true, true); } ! private void Execute(bool script, bool export, bool justDrop, bool format) { IDbConnection connection = null; *************** *** 197,200 **** --- 213,223 ---- } + /// <summary> + /// Format an SQL statement using simple rules: + /// a) Insert newline after each comma; + /// b) Indent three spaces after each inserted newline; + /// If the statement contains single/double quotes return unchanged, + /// it is too complex and could be broken by simple formatting. + /// </summary> private static string Format(string sql) { *************** *** 276,280 **** new SchemaExport(cfg) .SetOutputFile(outputFile) ! .Execute(script, export, drop, formatSQL, delimiter); } } catch(Exception e) { --- 299,304 ---- new SchemaExport(cfg) .SetOutputFile(outputFile) ! .SetDelimiter(delimiter) ! .Execute(script, export, drop, formatSQL); } } catch(Exception e) { |