MySqlConnector icon indicating copy to clipboard operation
MySqlConnector copied to clipboard

Support more schema collections in GetSchema

Open bgrainger opened this issue 8 years ago • 16 comments
trafficstars

Connector/NET supports the following schema collections in MySqlConnection.GetSchema. MySqlConnector only supports the bolded entries.

  • MetaDataCollections
  • DataSourceInformation
  • DataTypes
  • Restrictions
  • ReservedWords
  • Databases
  • Tables
  • Columns
  • Users
  • Foreign Keys
  • IndexColumns
  • Indexes
  • Foreign Key Columns
  • UDF
  • Views
  • ViewColumns
  • Procedure Parameters
  • Procedures
  • Triggers

Add support for additional schema collections that weren't implemented in #361.

bgrainger avatar Oct 22 '17 06:10 bgrainger

Look at my PR: I have implemented Foreign Keys-, IndexColumns-, Indexes- and Foreign Key Columns-Support

phillipc avatar Jul 05 '22 15:07 phillipc

Hi @bgrainger

Are there any plans to fix this issue? Missing schema collections make the mysqlconnector.net kind of useless with NHibernate (even if one could discuss if it make sense to use automatic scheme update)

eaexo avatar Dec 12 '23 14:12 eaexo

The plans have been visible on this issue for the last six years:

image

You're welcome to contribute to this freely-available open-source library by opening a PR that adds the missing functionality.

bgrainger avatar Dec 12 '23 16:12 bgrainger

Hi @bgrainger

please take a look: https://github.com/mysql-net/MySqlConnector/pull/1418

eaexo avatar Dec 14 '23 14:12 eaexo

Foreign Keys, Indexes, and Index Columns support were added by @eaexo in #1419.

bgrainger avatar Dec 16 '23 00:12 bgrainger

Hello @bgrainger when can we expect to have at least a beta released resp. published to the nuget.org?

eaexo avatar Dec 18 '23 09:12 eaexo

Foreign Keys, Indexes, Index Columns added in 2.3.2.

bgrainger avatar Dec 18 '23 20:12 bgrainger

Hi @bgrainger

unfortunatelly in commit 8748a725e (probably) you broke it again.

At least NHibernate passes 5 restrictions for determining index columns, see NHibernate.Dialect.Schema.AbstractDataBaseSchema.


		public virtual DataTable GetIndexColumns(string catalog, string schemaPattern, string tableName, string indexName)
		{
			if (UseDialectQualifyInsteadOfTableName)
			{
				var actualTableName = GetActualTableName(catalog, schemaPattern, tableName);
				return Connection.GetSchema("IndexColumns", new[] {null, null, actualTableName, indexName, null});
			}

			var restrictions = new[] {catalog, schemaPattern, tableName, indexName, null};
			return Connection.GetSchema("IndexColumns", restrictions);
		}

In my implementation I had a "placeholder" column which matched the 5th restriction: default: COLUMN_NAME.

Should I re-add it again, so it works, or should a different mechanism be introduced to allow more restrictions then really needed, e.g. by introducing something like boolean placeholder flag, which says, that the restriction is there but is not mapped to a specific column? i.e.

NHibernate passes for IndexColumns 5 values, but only 4 of them are set and used, so one would need to somehow allow more restrictions then effectively required. so not used but passed could be tagged/marked in yaml as dummy/placeholder, but took in to the account for the restrictions count check, or one could define a minimal expected number of restrictions...

eaexo avatar Dec 19 '23 09:12 eaexo

Yes, I removed the placeholder that you added with no implementation and no tests.

Added it back with an implementation and working tests: https://github.com/mysql-net/MySqlConnector/commit/d3ad6d1acf8f70e0e693ac845e3ed342222396c1, v2.3.3.

bgrainger avatar Dec 19 '23 14:12 bgrainger

@bgrainger

Thanks for quick update.

eaexo avatar Dec 19 '23 16:12 eaexo

@bgrainger If you like I could try to implement a better solution for "placeholders" in restrictions, so we do not need to specify a "random" column, but saying that any argument starting with index>n will be ignored, or that one can specify a minimum amount of restriction items

eaexo avatar Dec 19 '23 17:12 eaexo

The better solution is implementing the restriction, which I've done: https://github.com/mysql-net/MySqlConnector/commit/d3ad6d1acf8f70e0e693ac845e3ed342222396c1#diff-f0b4261dcdfed8eaab87870a6bce4b45f0a6c91aadddb44b47ff239665b4a082R535-R539

bgrainger avatar Dec 19 '23 17:12 bgrainger