Bug #45206 | Querying with Guid as parameter in where statement yeilds no results | ||
---|---|---|---|
Submitted: | 30 May 2009 13:50 | Modified: | 2 Jun 2009 19:24 |
Reporter: | Muhammad Mosa | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 6.03 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | Binary(16), Guid, UUID |
[30 May 2009 13:50]
Muhammad Mosa
[30 May 2009 19:16]
Muhammad Mosa
I guess this bug is related to MySqlGuid.WriteValue method. when I modified the last portion of this method as the following I was able to fetch my records using Guid where my field of course of type binary(16): if (binary) { byte[] bytes = guid.ToByteArray(); packet.WriteLength(bytes.Length); packet.Write(bytes); } else { //Core modified lines var guidAsBinaryString = String.Format("0x{0}", guid.ToString("N")); packet.WriteStringNoNull(guidAsBinaryString); }
[2 Jun 2009 19:24]
Reggie Burnett
Unable to reproduce this. How did you insert the guid values? Here is the test case I used to attempt to reproduce. /// <summary> /// Bug #45206 Querying with Guid as parameter in where statement yeilds no results /// </summary> [Test] public void GuidOnWhereClause() { execSQL("CREATE TABLE Test(id INT, g BINARY(16))"); Guid guid = Guid.NewGuid(); MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, @g)", conn); cmd.Parameters.Add(new MySqlParameter("@g", MySqlDbType.Guid)); cmd.Parameters[0].Value = guid; cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT * FROM Test WHERE g=@g"; cmd.Parameters[0].Value = guid.ToString("D"); using (MySqlDataReader r = cmd.ExecuteReader()) { r.Read(); Guid g = r.GetGuid("g"); Assert.AreEqual(guid, g); } }