[Mono-bugs] [Bug 76985][Nor] New - Nullable flag not correct for identity fields

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Dec 13 13:17:56 EST 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien.robitaille at croesus.com.

http://bugzilla.ximian.com/show_bug.cgi?id=76985

--- shadow/76985	2005-12-13 13:17:56.000000000 -0500
+++ shadow/76985.tmp.1781	2005-12-13 13:17:56.000000000 -0500
@@ -0,0 +1,92 @@
+Bug#: 76985
+Product: Mono: Class Libraries
+Version: 1.1
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: tsenganal at novell.com                            
+ReportedBy: sebastien.robitaille at croesus.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Nullable flag not correct for identity fields
+
+Description of Problem:
+
+If a database table contains a IDENTITY field, its DataSet.AllowDbNull 
+property will always set to TRUE, even if this is not possible with 
+Sybase (an IDENTITY field must be created as NOT NULL)
+
+Steps to reproduce the problem:
+1. Execute the following test case:
+
+SqlConnection conn = new SqlConnection();
+conn.ConnectionString = "<fill connection string>";
+try
+{
+	conn.Open();
+	IDbCommand command = conn.CreateCommand();
+			
+	// Create table
+	command.CommandText = "create table MyTestTable (MyField1 NUMERIC
+(10,0) IDENTITY NOT NULL, MyField2 DECIMAL(19))";
+	command.ExecuteNonQuery();
+
+	DataSet dataSet = new DataSet();
+	try
+	{
+		// The following query retrieves no data by design. This 
+technique is used to
+		// retrieve the database schema with ADO.NET while 
+avoiding to retrieve needless 
+		// data at this point.
+		string selectString = "SELECT * FROM MyTestTable WHERE 
+1=0";
+		IDbDataAdapter dataAdapter = new SqlDataAdapter
+(selectString,conn);
+		dataAdapter.FillSchema(dataSet, SchemaType.Mapped);
+	}
+	catch
+	{
+	}
+
+	if(dataSet.Tables.Count == 1)
+	{
+		System.Console.WriteLine("Column 0 AllowDbNull: " + 
+dataSet.Tables[0].Columns[0].AllowDBNull.ToString());
+		System.Console.WriteLine("Column 1 AllowDbNull: " + 
+dataSet.Tables[0].Columns[1].AllowDBNull.ToString());
+	}
+
+	// Drop the table.
+	try
+	{
+		command.CommandText = "drop table MyTestTable";
+		command.ExecuteNonQuery();
+	}
+	catch {}
+}
+catch
+{
+}
+
+Actual Results:
+Column 0 AllowDbNull: True
+Column 1 AllowDbNull: True
+
+
+Expected Results:
+Column 0 AllowDbNull: False
+Column 1 AllowDbNull: True
+
+How often does this happen? 
+Always
+
+Additional Information:
+
+This is related to bug #76433


More information about the mono-bugs mailing list