Skip to content
Browse files

Added transaction handling to Jet, and corrected some typos

  • Loading branch information...
1 parent 3d1790d commit 6627de5b4657180625429a104c9f0fe42317e9fe @dabide dabide committed Feb 18, 2013
View
4 FluentMigrator (2010).sln.DotSettings
@@ -15,4 +15,6 @@ See the License for the specific language governing permissions and
limitations under the License.</s:String>
<s:String x:Key="/Default/Environment/UserInterface/ShortcutSchemeName/@EntryValue">None</s:String>
<s:Boolean x:Key="/Default/CodeEditing/TypingAssist/FormatStatementOnSemicolon/@EntryValue">False</s:Boolean>
- <s:Boolean x:Key="/Default/CodeEditing/TypingAssist/FormatBlockOnRBrace/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>
+ <s:Boolean x:Key="/Default/CodeEditing/TypingAssist/FormatBlockOnRBrace/@EntryValue">False</s:Boolean>
+ <s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String>
+ <s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String></wpf:ResourceDictionary>
View
2 src/FluentMigrator.Runner/Generators/Jet/JetColumn.cs
@@ -30,7 +30,7 @@ protected override string FormatType(ColumnDefinition column)
protected override string FormatIdentity(ColumnDefinition column)
{
- //Indentity type is handled by FormartType
+ //Indentity type is handled by FormatType
return string.Empty;
}
View
10 src/FluentMigrator.Runner/Generators/Jet/JetGenerator.cs
@@ -14,27 +14,27 @@ public JetGenerator()
public override string Generate(RenameTableExpression expression)
{
- return compatabilityMode.HandleCompatabilty("Renaming of tables is not supporteed for MySql");
+ return compatabilityMode.HandleCompatabilty("Renaming of tables is not supporteed for Jet");
}
public override string Generate(RenameColumnExpression expression)
{
- return compatabilityMode.HandleCompatabilty("Renaming of columns is not supporteed for MySql");
+ return compatabilityMode.HandleCompatabilty("Renaming of columns is not supporteed for Jet");
}
public override string Generate(AlterDefaultConstraintExpression expression)
{
- return compatabilityMode.HandleCompatabilty("Altering of default constraints is not supporteed for MySql");
+ return compatabilityMode.HandleCompatabilty("Altering of default constraints is not supporteed for Jet");
}
public override string Generate(CreateSequenceExpression expression)
{
- return compatabilityMode.HandleCompatabilty("Sequences is not supporteed for MySql");
+ return compatabilityMode.HandleCompatabilty("Sequences is not supporteed for Jet");
}
public override string Generate(DeleteSequenceExpression expression)
{
- return compatabilityMode.HandleCompatabilty("Sequences is not supporteed for MySql");
+ return compatabilityMode.HandleCompatabilty("Sequences is not supporteed for Jet");
}
public override string Generate(DeleteDefaultConstraintExpression expression)
View
51 src/FluentMigrator.Runner/Processors/Jet/JetProcessor.cs
@@ -8,6 +8,7 @@ namespace FluentMigrator.Runner.Processors.Jet
public class JetProcessor : ProcessorBase
{
private OleDbConnection Connection { get; set; }
+ public OleDbTransaction Transaction { get; protected set; }
public override string DatabaseType
{
@@ -38,7 +39,7 @@ public override void Process(PerformDBOperationExpression expression)
if (Options.PreviewOnly)
return;
-
+
EnsureConnectionIsOpen();
if (expression.Operation != null)
@@ -54,7 +55,7 @@ protected override void Process(string sql)
EnsureConnectionIsOpen();
- using (var command = new OleDbCommand(sql, Connection))
+ using (var command = new OleDbCommand(sql, Connection, Transaction))
{
try
{
@@ -77,7 +78,7 @@ public override DataSet Read(string template, params object[] args)
EnsureConnectionIsOpen();
var ds = new DataSet();
- using (var command = new OleDbCommand(String.Format(template, args), Connection))
+ using (var command = new OleDbCommand(String.Format(template, args), Connection, Transaction))
using (var adapter = new OleDbDataAdapter(command))
{
adapter.Fill(ds);
@@ -89,7 +90,7 @@ public override bool Exists(string template, params object[] args)
{
EnsureConnectionIsOpen();
- using (var command = new OleDbCommand(String.Format(template, args), Connection))
+ using (var command = new OleDbCommand(String.Format(template, args), Connection, Transaction))
using (var reader = command.ExecuteReader())
{
return reader.Read();
@@ -118,7 +119,8 @@ public override bool TableExists(string schemaName, string tableName)
var restrict = new object[] { null, null, tableName, "TABLE" };
using (var tables = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, restrict))
{
- for (int i = 0; i < tables.Rows.Count; i++) {
+ for (int i = 0; i < tables.Rows.Count; i++)
+ {
var name = tables.Rows[i].ItemArray[2].ToString();
if (name == tableName)
{
@@ -136,7 +138,8 @@ public override bool ColumnExists(string schemaName, string tableName, string co
var restrict = new[] { null, null, tableName, null };
using (var columns = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, restrict))
{
- for (int i = 0; i < columns.Rows.Count; i++) {
+ for (int i = 0; i < columns.Rows.Count; i++)
+ {
var name = columns.Rows[i].ItemArray[3].ToString();
if (name == columnName)
{
@@ -169,8 +172,44 @@ public override bool IndexExists(string schemaName, string tableName, string ind
}
}
+ public bool SupportsTransactions
+ {
+ get { return true; }
+ }
+
+ public override void BeginTransaction()
+ {
+ if (!SupportsTransactions || Transaction != null) return;
+
+ EnsureConnectionIsOpen();
+
+ Announcer.Say("Beginning Transaction");
+ Transaction = Connection.BeginTransaction();
+ }
+
+ public override void RollbackTransaction()
+ {
+ if (Transaction == null) return;
+
+ Announcer.Say("Rolling back transaction");
+ Transaction.Rollback();
+ WasCommitted = true;
+ Transaction = null;
+ }
+
+ public override void CommitTransaction()
+ {
+ if (Transaction == null) return;
+
+ Announcer.Say("Committing Transaction");
+ Transaction.Commit();
+ WasCommitted = true;
+ Transaction = null;
+ }
+
protected override void Dispose(bool isDisposing)
{
+ RollbackTransaction();
EnsureConnectionIsClosed();
}
}

0 comments on commit 6627de5

Please sign in to comment.
Something went wrong with that request. Please try again.