#At file:///D:/bzr-connector-net/6.1/ based on revid:reggie.burnett@strippedytqduvjtggq
751 Reggie Burnett 2009-08-25
removed the ReturnGeneratedIdentifiers code. We are now treating the command builder the same as SqlClient
modified:
CHANGES
MySql.Data/Provider/Properties/Resources.Designer.cs
MySql.Data/Provider/Properties/Resources.resx
MySql.Data/Provider/Source/CommandBuilder.cs
MySql.Data/Tests/Source/CommandBuilderTests.cs
Release Notes.txt
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES 2009-08-25 16:36:16 +0000
+++ b/CHANGES 2009-08-25 21:26:55 +0000
@@ -1,3 +1,7 @@
+Version 6.1.2
+- removed ReturnGeneratedIdentifiers. We are now treating the command builder exactly
+ the same way SqlClient does
+
Version 6.1.1
- lots of bug fixes merged up from 6.0.5
- fixed website config wizard so that it shows for all web types
=== modified file 'MySql.Data/Provider/Properties/Resources.Designer.cs'
--- a/MySql.Data/Provider/Properties/Resources.Designer.cs 2009-07-28 20:40:35 +0000
+++ b/MySql.Data/Provider/Properties/Resources.Designer.cs 2009-08-25 21:26:55 +0000
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.3053
+// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -21,9 +21,7 @@
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-#if !CF
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-#endif
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
@@ -423,15 +421,6 @@
}
/// <summary>
- /// Looks up a localized string similar to When MySqlCommandBuilder.ReturnGeneratedIdentifiers is true, MySqlCommand.UpdatedRowSource must be set to None..
- /// </summary>
- public static string MixingUpdatedRowSource {
- get {
- return ResourceManager.GetString("MixingUpdatedRowSource", resourceCulture);
- }
- }
-
- /// <summary>
/// Looks up a localized string similar to INTERNAL ERROR: More than one output parameter row detected..
/// </summary>
public static string MoreThanOneOPRow {
=== modified file 'MySql.Data/Provider/Properties/Resources.resx'
--- a/MySql.Data/Provider/Properties/Resources.resx 2009-07-28 20:40:35 +0000
+++ b/MySql.Data/Provider/Properties/Resources.resx 2009-08-25 21:26:55 +0000
@@ -318,9 +318,6 @@
<data name="ParameterMustBeDefined" xml:space="preserve">
<value>Parameter '{0}' must be defined.</value>
</data>
- <data name="MixingUpdatedRowSource" xml:space="preserve">
- <value>When MySqlCommandBuilder.ReturnGeneratedIdentifiers is true, MySqlCommand.UpdatedRowSource must be set to None.</value>
- </data>
<data name="ObjectDisposed" xml:space="preserve">
<value>The object is not open or has been disposed.</value>
</data>
@@ -363,8 +360,8 @@
<data name="TimeoutExpiredNullObject" xml:space="preserve">
<value>Timeout expired but command object was null. This should not happen.</value>
</data>
- <data name="UnableToEnumerateUDF" xml:space="preserve">
- <value>An error occured attempting to enumerate the user-defined functions. Do you have SELECT privileges on the mysql.func table?</value>
+ <data name="UnableToEnumerateUDF" xml:space="preserve">
+ <value>An error occured attempting to enumerate the user-defined functions. Do you have SELECT privileges on the mysql.func table?</value>
</data>
<data name="DataNotInSupportedFormat" xml:space="preserve">
<value>The given value was not in a supported format.</value>
@@ -390,16 +387,4 @@
<data name="MoreThanOneOPRow" xml:space="preserve">
<value>INTERNAL ERROR: More than one output parameter row detected.</value>
</data>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
-</root>
+</root>
\ No newline at end of file
=== modified file 'MySql.Data/Provider/Source/CommandBuilder.cs'
--- a/MySql.Data/Provider/Source/CommandBuilder.cs 2009-08-25 16:36:16 +0000
+++ b/MySql.Data/Provider/Source/CommandBuilder.cs 2009-08-25 21:26:55 +0000
@@ -38,16 +38,10 @@
#endif
public sealed class MySqlCommandBuilder : DbCommandBuilder
{
- private string finalSelect;
- private bool returnGeneratedIds;
-
- #region Constructors
-
/// <include file='docs/MySqlCommandBuilder.xml' path='docs/Ctor/*'/>
public MySqlCommandBuilder()
{
QuotePrefix = QuoteSuffix = "`";
- ReturnGeneratedIdentifiers = true;
}
/// <include file='docs/MySqlCommandBuilder.xml' path='docs/Ctor2/*'/>
@@ -57,10 +51,6 @@
DataAdapter = adapter;
}
- #endregion
-
- #region Properties
-
/// <include file='docs/mysqlcommandBuilder.xml' path='docs/DataAdapter/*'/>
public new MySqlDataAdapter DataAdapter
{
@@ -68,20 +58,6 @@
set { base.DataAdapter = value; }
}
- /// <summary>
- /// Indicates whether the command builder should generate a SELECT statement
- /// to populate any autogenerated fields. We provide this property rather
- /// than rely on the MySqlCommand.UpdatedRowSource property since a user should
- /// still be able to write a custom insert command and not have our work interfere.
- /// </summary>
- public bool ReturnGeneratedIdentifiers
- {
- get { return returnGeneratedIds; }
- set { returnGeneratedIds = value; }
- }
-
- #endregion
-
#region Public Methods
/// <summary>
@@ -176,13 +152,6 @@
return (MySqlCommand)GetInsertCommand(false);
}
- /// <include file='docs/MySqlCommandBuilder.xml' path='docs/RefreshSchema/*'/>
- public override void RefreshSchema()
- {
- base.RefreshSchema();
- finalSelect = null;
- }
-
public override string QuoteIdentifier(string unquotedIdentifier)
{
if (unquotedIdentifier == null) throw new
@@ -220,7 +189,6 @@
#endregion
-
/// <summary>
///
/// </summary>
@@ -241,12 +209,6 @@
return String.Format("@{0}", sb.ToString());
}
- protected override DbCommand InitializeCommand(DbCommand command)
- {
- return base.InitializeCommand(command);
- }
-
-
protected override void ApplyParameterInfo(DbParameter parameter, DataRow row,
StatementType statementType, bool whereClause)
{
@@ -275,58 +237,7 @@
private void RowUpdating(object sender, MySqlRowUpdatingEventArgs args)
{
base.RowUpdatingHandler(args);
-
- if (args.StatementType != StatementType.Insert) return;
-
- if (ReturnGeneratedIdentifiers)
- {
- if (args.Command.UpdatedRowSource != UpdateRowSource.None)
- throw new InvalidOperationException(
- Resources.MixingUpdatedRowSource);
- args.Command.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
- if (finalSelect == null)
- CreateFinalSelect();
- }
-
- if (finalSelect != null && finalSelect.Length > 0)
- args.Command.CommandText += finalSelect;
- }
-
- /// <summary>
- /// We only need to return the single auto generated column since the base
- /// ADO.Net classes will take care of mapping it onto the datarow for us.
- /// </summary>
- private void CreateFinalSelect()
- {
- StringBuilder select = new StringBuilder();
-
- MySqlConnection c = DataAdapter.SelectCommand.Connection;
- DataTable schema = null;
- bool isOpen = c.State == ConnectionState.Open;
-
- try
- {
- if (!isOpen)
- c.Open();
- schema = GetSchemaTable(DataAdapter.SelectCommand);
- }
- finally
- {
- if (!isOpen)
- c.Close();
- }
-
- foreach (DataRow row in schema.Rows)
- {
- if (!(bool)row["IsAutoIncrement"])
- continue;
-
- select.AppendFormat(CultureInfo.InvariantCulture,
- "; SELECT last_insert_id() AS `{0}`", row["ColumnName"]);
- break;
- }
-
- finalSelect = select.ToString();
- }
+ }
+
}
}
=== modified file 'MySql.Data/Tests/Source/CommandBuilderTests.cs'
--- a/MySql.Data/Tests/Source/CommandBuilderTests.cs 2009-07-28 20:40:35 +0000
+++ b/MySql.Data/Tests/Source/CommandBuilderTests.cs 2009-08-25 21:26:55 +0000
@@ -27,6 +27,11 @@
[TestFixture]
public class CommandBuilderTests : BaseTest
{
+ public CommandBuilderTests()
+ {
+ csAdditions += ";logging=true;";
+ }
+
[Test]
public void MultiWord()
{
@@ -243,6 +248,10 @@
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
+ da.InsertCommand = cb.GetInsertCommand();
+ da.InsertCommand.CommandText += "; SELECT last_insert_id()";
+ da.InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
+
DataTable dt = new DataTable();
da.Fill(dt);
dt.Columns[0].AutoIncrement = true;
@@ -273,7 +282,11 @@
"AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20))");
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
- cb.ReturnGeneratedIdentifiers = true;
+
+ MySqlCommand cmd = (MySqlCommand)(cb.GetInsertCommand() as ICloneable).Clone();
+ cmd.CommandText += "; SELECT last_insert_id() as id";
+ cmd.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
+ da.InsertCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
=== modified file 'Release Notes.txt'
--- a/Release Notes.txt 2009-08-18 03:15:12 +0000
+++ b/Release Notes.txt 2009-08-25 21:26:55 +0000
@@ -24,6 +24,14 @@
to populate a guid table and UUID generates a 36 character string. Developers of older
applications can add 'old guids=true' to the connection string and the old binary(16) type will be used.
+Functionality changes
+----------------------------
+We are now treating the command builder just like SqlClient. This means that if you want to
+return an autoincrement value back to your dataset, you will need to clone the generated command
+and manually add the proper SQL onto the end of your command text. The command builder
+was not designed to handle this. In previous versions we have tried to support this but
+it is causing more headaches than it is solving.
+
What we know may be broken
----------------------------
- Documentation is not updated yet.
Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20090825212655-e94zjuyxwl4pe07g.bundle
| Thread |
|---|
| • bzr commit into connector-net-6.1 branch (reggie.burnett:751) | Reggie Burnett | 25 Aug |