Bug 26140 - DataTable default tablename is missing since mono 3.12.0
Summary: DataTable default tablename is missing since mono 3.12.0
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: 3.12.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-17 20:07 UTC by Harry May
Modified: 2016-02-22 22:22 UTC (History)
12 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Harry May 2015-01-17 20:07:39 UTC
Description of Problem:

DataTable mytab = new DataTable(String tableName);

Microsoft says:
"If tableName is null or an empty string, a default name is given when added to the DataTableCollection"

In mono this worked until version 3.10.0.

Since 3.12.0 no default name is given, so if we write as usual:
DataTable mytab = new DataTable();
an exception is thrown in various applications using DataTables.


Steps to reproduce the problem:
I can reproduce it when retrieving data from an sqlite database.
The sqliteadapter Fill functions get a DataTable as a parameter and fills it
with data from the database.
In mono versions up to 3.10.0 this worked well.
Since 3.12.0 an exception is thrown that the DataTable has no name. 
A workaround is to give the DataTable a name manually in the source.
But if we run a software without having the source we get a problem.

The default name should be implemented as it was before.
Comment 1 Harry May 2015-01-17 20:15:38 UTC
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: SourceTable is required to be a non-empty string

Parameter name: sourceTable

  at System.Data.Common.DataTableMappingCollection.GetTableMappingBySchemaAction (System.Data.Common.DataTableMappingCollection tableMappings, System.String sourceTable, System.String dataSetTable, MissingMappingAction mappingAction) [0x00000] in <filename unknown>:0
Comment 2 Ryan 2015-04-29 16:57:33 UTC
This problem breaks GetSchema calls for both System.Data.SqlServer and System.Data.OracleClient.  This is also a problem any time DbDataAdapter.Fill is called with an unnamed DataTable. I'm sure there are a lot of other cases where this is now broken as well that I haven't yet tested.  This has also caused headaches for my code where I now need to specify a name any time I create a new DataTable and need to use it with a DbDataAdapter or basically any other piece of System.Data.  I'm not sure how this error even got through any sort of testing.

So far, GetSchema calls still work for Npgsql and MySql.Data.MySqlClient.
Comment 3 A. Glez. B. 2015-05-05 15:38:30 UTC
Same here, but only after upgrading to XS 5.9.0.431 (from 5.8.3.1) and Xamarin 3.11.445 (from 3.9.547).
Comment 4 brandon 2015-05-06 17:50:59 UTC
Seeing this here too. But AM seeing this for MySql.Data.MySqlClient
Comment 5 brandon 2015-05-06 17:52:37 UTC
attached is all my version info

Xamarin Studio
Version 5.9 (build 431)
Installation UUID: 56872acb-c69b-4513-9716-59739ffede61
Runtime:
 Mono 4.0.0 ((detached/d136b79)
 GTK+ 2.24.23 (Raleigh theme)

 Package version: 400000143

Apple Developer Tools
Xcode 6.2 (6776)
Build 6C131e

Xamarin.iOS
Version: 8.9.1.3 (Business Edition)
Hash: f7736a4
Branch: 
Build date: 2015-04-09 04:22:08-0400

Xamarin.Android
Not Installed

Xamarin Android Player
Not Installed

Xamarin.Mac
Not Installed

Build Information
Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

Operating System
Mac OS X 10.9.5
Darwin RichardLapTop-2.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 6 Peter Hagen 2015-05-07 16:01:18 UTC
I can confirm that on Mono 4.0.1 (mono-4.0.0-branch/c06ccca Wed May  6 23:16:31 CEST 2015) its broken also for MySql. On 3.12.0 it did work. For example:

 ((MySqlConnection)connection).GetSchema("Tables", new string[] { null, null, null, null });

fails with exception: SourceTable is required to be a non-empty string

Parameter name: sourceTable (System.ArgumentException)
  at System.Data.Common.DataTableMappingCollection.GetTableMappingBySchemaAction (System.Data.Common.DataTableMappingCollection tableMappings, System.String sourceTable, System.String dataSetTable, MissingMappingAction mappingAction) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DataAdapter.SetupSchema (SchemaType schemaType, System.String sourceTableName) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DataAdapter.FillInternal (System.Data.DataTable dataTable, IDataReader dataReader) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DataAdapter.Fill (System.Data.DataTable dataTable, IDataReader dataReader) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable, IDbCommand command, CommandBehavior behavior) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Data.Common.DbDataAdapter:Fill (System.Data.DataTable)
  at MySql.Data.MySqlClient.ISSchemaProvider.GetTable (System.String sql) [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.ISSchemaProvider.Query (System.String table_name, System.String initial_where, System.String[] keys, System.String[] values) [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.ISSchemaProvider.GetColumns (System.String[] restrictions) [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.SchemaProvider.GetSchemaInternal (System.String collection, System.String[] restrictions) [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.ISSchemaProvider.GetSchemaInternal (System.String collection, System.String[] restrictions) [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.SchemaProvider.GetSchema (System.String collection, System.String[] restrictions) [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.MySqlConnection.GetSchema (System.String collectionName, System.String[] restrictionValues) [0x00000] in <filename unknown>:0 
  at Willow.Data.MySql.MySqlProvider.GetSchemaTable (IDbConnection connection, System.String tablename) [0x00000] in <filename unknown>:0 
  at Willow.Data.MySql.MySqlProvider.GetSchema (IDbConnection connection, iMetaDataTable table) [0x00000] in <filename unknown>:0
Comment 7 matteo 2015-05-12 09:13:54 UTC
Same here
Comment 8 Shane van Wyk 2015-06-10 00:45:40 UTC
Upgraded to Mono 4.0.1.44 and it is still broken, it worked fine on 3.12.0 for us.

Never used to be a problem.

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: SourceTable is required to be a non-empty string
Parameter name: sourceTable
  at System.Data.Common.DataTableMappingCollection.GetTableMappingBySchemaAction (System.Data.Common.DataTableMappingCollection tableMappings, System.String sourceTable, System.String dataSetTable, MissingMappingAction mappingAction) [0x00000] in <filename unknown>:0
  at System.Data.Common.DataAdapter.SetupSchema (SchemaType schemaType, System.String sourceTableName) [0x00000] in <filename unknown>:0
  at System.Data.Common.DataAdapter.FillInternal (System.Data.DataTable dataTable, IDataReader dataReader) [0x00000] in <filename unknown>:0
  at System.Data.Common.DataAdapter.Fill (System.Data.DataTable dataTable, IDataReader dataReader) [0x00000] in <filename unknown>:0
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable, IDbCommand command, CommandBehavior behavior) [0x00000] in <filename unknown>:0
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable) [0x00000] in <filename unknown>:
Comment 9 XpandeR 2015-07-20 01:41:27 UTC
Same here, from mySQL.
Mono JIT compiler version 4.0.2 (Stable 4.0.2.5/c99aa0c Wed Jun 24 10:04:37 UTC 2015)
Same code works fine with MS.NET.

SourceTable is required to be a non-empty string
Parameter name: sourceTable
  at System.Data.Common.DataTableMappingCollection.GetTableMappingBySchemaAction (System.Data.Common.DataTableMappingCollection tableMappings, System.String sourceTable, System.String dataSetTable, MissingMappingAction mappingAction) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DataAdapter.SetupSchema (SchemaType schemaType, System.String sourceTableName) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DataAdapter.FillInternal (System.Data.DataTable dataTable, IDataReader dataReader) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DataAdapter.Fill (System.Data.DataTable dataTable, IDataReader dataReader) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable, IDbCommand command, CommandBehavior behavior) [0x00000] in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Data.Common.DbDataAdapter:Fill (System.Data.DataTable)
  at DbUtility.GetTable (System.String command, CommandType type, MySql.Data.MySqlClient.MySqlParameter[] parameters) [0x00000] in <filename unknown>:0
Comment 10 XpandeR 2015-07-20 02:26:10 UTC
Rollback to 3.12 did the trick. 
It's a pity: 6 months passed since important System.Data bug was reported and it is still not fixed.
Data Adapters won't work with it.
Comment 11 Peter Hagen 2015-07-20 02:44:19 UTC
I have the 4.0.2.5 tagged commit from the master branch running at the moment, and there its fixed. The 4.0 branch also didn't work for me. It should be this one: https://github.com/mono/mono/tree/mono-4.0.2.5
Comment 12 XpandeR 2015-08-07 17:17:45 UTC
Well, I was on (Stable 4.0.2.5/c99aa0c) [current released version per http://www.mono-project.com/docs/about-mono/releases/ ] - looks like commit you've pointed. 
I've also tried 4.0.3.20 (current beta). It looks fixed there. Thanx guys.
Comment 13 Alexis Christoforides 2016-02-22 22:22:12 UTC
This bug was fixed as consequence of switching the implementation of System.Data to the MS referencesource one, as of commit 9f006cd1041c08ca6a048c039a3c57c187a1f453 & Mono version 4.2.