Bug #63301 TreatTinyIntegerAsBoolean doesn't return boolean anymore.
Submitted: 17 Nov 2011 7:01 Modified: 22 Dec 2011 12:33
Reporter: Vlad ddd Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.4.4 OS:Windows
Assigned to: Bogdan Degtyariov CPU Architecture:Any

[17 Nov 2011 7:01] Vlad ddd
Description:
TreatTinyIntegerAsBoolean doesn't return boolean anymore. 

How to repeat:
In MySqlConnectionStringBuilder and in a connection string both to true;
[22 Nov 2011 12:33] Bogdan Degtyariov
Hi Vlad,

I do not completely understand what exactly you wanted to report.
Please review the following code fragment and change it to make a repeatable
test case:

/****************************************************************************/
private void button10_Click(object sender, EventArgs e)
{
  MySqlConnection con = new MySqlConnection();
  try
  {
    con.ConnectionString = "server=localhost;database=test;" +
                           "user id=********;Password=********;" +
                           "Treat Tiny As Boolean=true";
    con.Open();
    MySqlCommand cmd = new MySqlCommand();
    cmd.Connection = con;

    cmd.CommandType = CommandType.Text;
    cmd.CommandText = "DROP TABLE IF EXISTS bug63301";
    cmd.ExecuteNonQuery();
    cmd.CommandText = "CREATE TABLE bug63301 " +
                      "(id int auto_increment primary key," +
                      " ti tinyint, bo boolean)";
    cmd.ExecuteNonQuery();

    cmd.CommandText = "INSERT INTO bug63301 (id, ti, bo) VALUES " +
                      "(1, 1, 1)";
    cmd.ExecuteNonQuery();

    cmd.CommandText = "SELECT * FROM bug63301";
    MySqlDataReader dr = cmd.ExecuteReader();

    while (dr.Read())
    {
      String s = "Type 1: " + dr["ti"].GetType().ToString()+
                      "\r\nType 2: " + dr["bo"].GetType().ToString() + 
                      "\r\nResult 1:" + dr.GetBoolean("ti") +
                      "\r\nResult 2:" + dr.GetBoolean("bo");
      MessageBox.Show(s);
    }

  }
  catch (Exception ex)
  {
    string error = ex.Message.ToString();
    error += ex.StackTrace;
    MessageBox.Show("=============================================\r\n" +
                    "Error!\r\n" + error + "\r\n" +
                    "=============================================\r\n");

  }
  con.Close();
}
/****************************************************************************/

Now it displays the result as follows (as you see the boolean result can be read):

Type 1: System.SByte
Type 2: System.Boolean
Result 1:True
Result 2:True

Also, S1 Critical justification of the case does not look appropriate.
It means that the core functionality is broken and no workarounds exist.

You still can have boolean values using .GetBoolean() functions. This might be inconvenient, but it does not fall into S1 anyway.
It actually should be S3, but I do not know all specifics of your application, so setting S2.

Waiting on your feedback.
Thanks.
[23 Dec 2011 7:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".