| Bug #35492 | Please implement DbCommandBuilder.QuoteIdentifier | ||
|---|---|---|---|
| Submitted: | 21 Mar 2008 23:55 | Modified: | 16 May 2008 19:16 |
| Reporter: | Max Toro | ||
| Status: | Closed | ||
| Category: | Connector/Net | Severity: | S3 (Non-critical) |
| Version: | all | OS: | Microsoft Windows |
| Assigned to: | Target Version: | ||
| Tags: | DbCommandBuilder(string), QuoteIdentifier | ||
[27 Mar 2008 16:03]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/44518
[27 Mar 2008 16:03]
Reggie Burnett
Fixed in 5.0.9, 5.1.5, 5.2.2, +
[26 Apr 2008 22:48]
Max Toro
>>Fixed in 5.0.9, 5.1.5, 5.2.2, + I downloaded 5.1.5 and it isn't fixed, am I missing something? 5.0.9 its OK.
[27 Apr 2008 4:01]
Reggie Burnett
Correction, this is fixed in 5.0.9, *5.1,6*, and 5.2.2+
[16 May 2008 15:12]
MC Brown
A note has been added to the 5.0.9, 5.1.6, and 5.2.2 changelogs: The DbCommandBuilder.QuoteIdentifer method was not implemented.
[16 May 2008 19:16]
Max Toro
what do you mean "was not implemented"? It's there!

Description: Please implement DbCommandBuilder.QuoteIdentifier(string) It is very easy to implement, and it's useful for dynamic SQL. Also, everytime you want to use MySqlCommandBuilder you MUST set the DataAdapter property, and that DbDataAdapter instance must have it's SelectCommand property set. DbCommandBuilder is useful not only when used with DbDataAdapter. How to repeat: DbCommandBuilder builder = new MySqlCommandBuilder(); builder.QuoteIdentifier(new String()); Suggested fix: public static string QuoteIdentifierString(this DbCommandBuilder commandBuilder, string unquotedIdentifier) { if (commandBuilder == null) throw new ArgumentNullException("commandBuilder"); if (unquotedIdentifier == null) throw new ArgumentNullException("unquotedIdentifier"); string qPrefix = commandBuilder.QuotePrefix, qSuffix = commandBuilder.QuoteSuffix; StringBuilder builder = new StringBuilder(); if (!string.IsNullOrEmpty(qPrefix)) { builder.Append(qPrefix); unquotedIdentifier = unquotedIdentifier.Replace(qPrefix, qPrefix + qPrefix); } if (!string.IsNullOrEmpty(qSuffix)) { if (!qPrefix.Equals(qSuffix, StringComparison.OrdinalIgnoreCase)) unquotedIdentifier = unquotedIdentifier.Replace(qSuffix, qSuffix + qSuffix); builder.Append(unquotedIdentifier); builder.Append(qSuffix); } else { builder.Append(unquotedIdentifier); } return builder.ToString(); }