Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSenganal T <senga@mono-cvs.ximian.com>2006-02-13 10:54:39 +0300
committerSenganal T <senga@mono-cvs.ximian.com>2006-02-13 10:54:39 +0300
commit870e79a0fddad4d2c0ccb8238fd8a3fa9d8a464c (patch)
treee27e4225ae6549b4ddeac6a7acf04973d254d876 /mcs/class/System.Data/System.Data.Common
parentcad7a4e6983be114834d531b8eef4c4e19f89684 (diff)
2006-02-13 Senganal T <tsenganal@novell.com>
* Test/ProviderTests/System.Data.SqlClient/SqlAdapterTest.cs : Added testcases for #77480 * System.Data.Common/DbDataAdapter.cs : - FillSchema : - Add table to schema only if MissingSchemaAction is not Ignore Add schema to table if MissingSchemaAction is set to either of Add or AddWithKey - BuildSchema : - Set the Schema values only if MissingSchemaAction is set to AddWithKey svn path=/branches/mono-1-1-13/mcs/; revision=56832
Diffstat (limited to 'mcs/class/System.Data/System.Data.Common')
-rw-r--r--mcs/class/System.Data/System.Data.Common/ChangeLog11
-rw-r--r--mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs64
2 files changed, 55 insertions, 20 deletions
diff --git a/mcs/class/System.Data/System.Data.Common/ChangeLog b/mcs/class/System.Data/System.Data.Common/ChangeLog
index db5e6e19e7d..0dae35564ed 100644
--- a/mcs/class/System.Data/System.Data.Common/ChangeLog
+++ b/mcs/class/System.Data/System.Data.Common/ChangeLog
@@ -1,3 +1,14 @@
+2006-02-13 Senganal T <tsenganal@novell.com>
+
+ * DbDataAdapter.cs :
+ - FillSchema :
+ - Add table to schema only if MissingSchemaAction is not Ignore
+ Add schema to table if MissingSchemaAction is set to either of
+ Add or AddWithKey
+ - BuildSchema :
+ - Set the Schema values only if MissingSchemaAction is set to
+ AddWithKey
+
2006-01-31 Senganal T <tsenganal@novell.com>
* DbDataAdapter.cs :
- Corrected an error in the prev checkin.. Fixes #77415
diff --git a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
index 201d3b12440..e021bc32356 100644
--- a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
+++ b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
@@ -513,7 +513,15 @@ namespace System.Data.Common {
string tableName = SetupSchema (schemaType, dataTable.TableName);
if (tableName != null)
{
- BuildSchema (reader, dataTable, schemaType);
+ // FillSchema should add the KeyInfo unless MissingSchemaAction
+ // is set to Ignore or Error.
+ MissingSchemaAction schemaAction = MissingSchemaAction;
+ if (!(schemaAction == MissingSchemaAction.Ignore ||
+ schemaAction == MissingSchemaAction.Error))
+ schemaAction = MissingSchemaAction.AddWithKey;
+
+ BuildSchema (reader, dataTable, schemaType, schemaAction,
+ MissingMappingAction, TableMappings);
}
}
finally
@@ -542,6 +550,13 @@ namespace System.Data.Common {
DataTable table;
try
{
+ // FillSchema should add the KeyInfo unless MissingSchemaAction
+ // is set to Ignore or Error.
+ MissingSchemaAction schemaAction = MissingSchemaAction;
+ if (!(MissingSchemaAction == MissingSchemaAction.Ignore ||
+ MissingSchemaAction == MissingSchemaAction.Error))
+ schemaAction = MissingSchemaAction.AddWithKey;
+
do {
tableName = SetupSchema (schemaType, tableName);
if (tableName != null)
@@ -550,10 +565,14 @@ namespace System.Data.Common {
table = dataSet.Tables [tableName];
else
{
- table = new DataTable(tableName);
- dataSet.Tables.Add (table);
+ // Do not create schema if MissingSchemAction is set to Ignore
+ if (this.MissingSchemaAction == MissingSchemaAction.Ignore)
+ continue;
+ table = dataSet.Tables.Add (tableName);
}
- BuildSchema (reader, table, schemaType);
+
+ BuildSchema (reader, table, schemaType, schemaAction,
+ MissingMappingAction, TableMappings);
output.Add (table);
tableName = String.Format ("{0}{1}", srcTable, ++index);
}
@@ -703,21 +722,25 @@ namespace System.Data.Common {
mapping = tmp;
}
- object value = (AllowDBNullCol != null) ? schemaRow[AllowDBNullCol] : null;
- bool allowDBNull = value is bool ? (bool)value : true;
- col.AllowDBNull = allowDBNull;
- value = (IsKeyCol != null) ? schemaRow[IsKeyCol] : null;
- bool isKey = value is bool ? (bool)value : false;
if (missingSchAction == MissingSchemaAction.AddWithKey) {
+ object value = (AllowDBNullCol != null) ? schemaRow[AllowDBNullCol] : null;
+ bool allowDBNull = value is bool ? (bool)value : true;
+
+ value = (IsKeyCol != null) ? schemaRow[IsKeyCol] : null;
+ bool isKey = value is bool ? (bool)value : false;
+
value = (IsAutoIncrementCol != null) ? schemaRow[IsAutoIncrementCol] : null;
bool isAutoIncrement = value is bool ? (bool)value : false;
+
value = (IsReadOnlyCol != null) ? schemaRow[IsReadOnlyCol] : null;
bool isReadOnly = value is bool ? (bool)value : false;
+
value = (IsUniqueCol != null) ? schemaRow[IsUniqueCol] : null;
bool isUnique = value is bool ? (bool)value : false;
+ col.AllowDBNull = allowDBNull;
// fill woth key info
if (isAutoIncrement && DataColumn.CanAutoIncrement(columnType)) {
col.AutoIncrement = true;
@@ -739,20 +762,21 @@ namespace System.Data.Common {
if (!allowDBNull)
col.AllowDBNull = false;
}
- }
- bool isHidden = false;
- if (schemaTable.Columns.Contains ("IsHidden")) {
- value = schemaRow["IsHidden"];
- isHidden = ((value is bool) ? (bool)value : false);
- }
+ // This might not be set by all DataProviders
+ bool isHidden = false;
+ if (schemaTable.Columns.Contains ("IsHidden")) {
+ value = schemaRow["IsHidden"];
+ isHidden = ((value is bool) ? (bool)value : false);
+ }
+
+ if (isKey && !isHidden) {
+ primaryKey.Add (col);
+ if (allowDBNull)
+ createPrimaryKey = false;
+ }
- if (isKey && !isHidden) {
- primaryKey.Add (col);
- if (allowDBNull)
- createPrimaryKey = false;
}
-
// add the ordinal of the column as a key and the index of the column in the datareader as a value.
mapping[col.Ordinal] = readerIndex++;
}