From: <pa...@us...> - 2011-03-27 16:59:13
|
Revision: 5552 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5552&view=rev Author: patearl Date: 2011-03-27 16:59:07 +0000 (Sun, 27 Mar 2011) Log Message: ----------- Dialect: Removed meaningless HasAlterTable property. Improved the names and functionality of some other recently added properties. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2011-03-27 05:31:22 UTC (rev 5551) +++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2011-03-27 16:59:07 UTC (rev 5552) @@ -813,8 +813,8 @@ var script = new List<string>(); - if (!string.IsNullOrEmpty(dialect.BeforeDropSchemaCommand)) - script.Add(dialect.BeforeDropSchemaCommand); + if (!dialect.SupportsForeignKeyConstraintInAlterTable && !string.IsNullOrEmpty(dialect.DisableForeignKeyConstraintsString)) + script.Add(dialect.DisableForeignKeyConstraintsString); // drop them in reverse order in case db needs it done that way...);); for (int i = auxiliaryDatabaseObjects.Count - 1; i >= 0; i--) @@ -864,8 +864,8 @@ } } - if (!string.IsNullOrEmpty(dialect.AfterDropSchemaCommand)) - script.Add(dialect.AfterDropSchemaCommand); + if (!dialect.SupportsForeignKeyConstraintInAlterTable && !string.IsNullOrEmpty(dialect.EnableForeignKeyConstraintsString)) + script.Add(dialect.EnableForeignKeyConstraintsString); return script.ToArray(); } Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2011-03-27 05:31:22 UTC (rev 5551) +++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2011-03-27 16:59:07 UTC (rev 5552) @@ -584,14 +584,6 @@ #region DDL support /// <summary> - /// Does this dialect support the <c>ALTER TABLE</c> syntax? - /// </summary> - public virtual bool HasAlterTable - { - get { return true; } - } - - /// <summary> /// Do we need to drop constraints before dropping tables in the dialect? /// </summary> public virtual bool DropConstraints @@ -626,11 +618,11 @@ /// </summary> public virtual bool SupportsForeignKeyConstraintInAlterTable { - get { return HasAlterTable; } + get { return true; } } /// <summary> - /// The syntax used to add a foreign key constraint to a table. + /// The syntax used to add a foreign key constraint to a table. If SupportsForeignKeyConstraintInAlterTable is false, the returned string will be added to the create table statement instead. In this case, extra strings, like "add", that apply when using alter table should be omitted. /// </summary> /// <param name="constraintName">The FK constraint name. </param> /// <param name="foreignKey">The names of the columns comprising the FK </param> @@ -2427,12 +2419,18 @@ return false; } - public virtual string BeforeDropSchemaCommand + /// <summary> + /// Only needed if the Dialect does not have SupportsForeignKeyConstraintInAlterTable. + /// </summary> + public virtual string DisableForeignKeyConstraintsString { get { return null; } } - public virtual string AfterDropSchemaCommand + /// <summary> + /// Only needed if the Dialect does not have SupportsForeignKeyConstraintInAlterTable. + /// </summary> + public virtual string EnableForeignKeyConstraintsString { get { return null; } } Modified: trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs 2011-03-27 05:31:22 UTC (rev 5551) +++ trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs 2011-03-27 16:59:07 UTC (rev 5552) @@ -124,11 +124,6 @@ get { return true; } } - public override bool HasAlterTable - { - get { return false; } - } - public override bool DropConstraints { get { return false; } @@ -293,17 +288,23 @@ /// If there are cycles between tables, it would even be excessively difficult to delete /// the data in the right order first. Because of this, we just turn off the foreign /// constraints before we drop the schema and hope that we're not going to break anything. :( + /// We could theoretically check for data consistency afterwards, but we don't currently. /// </summary> - public override string BeforeDropSchemaCommand + public override string DisableForeignKeyConstraintsString { get { return "PRAGMA foreign_keys = OFF"; } } - public override string AfterDropSchemaCommand + public override string EnableForeignKeyConstraintsString { get { return "PRAGMA foreign_keys = ON"; } } + public override bool SupportsForeignKeyConstraintInAlterTable + { + get { return false; } + } + [Serializable] protected class SQLiteCastFunction : CastFunction { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |