MySqlConnector
MySqlConnector copied to clipboard
Support more schema collections in GetSchema
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.
Look at my PR: I have implemented Foreign Keys-, IndexColumns-, Indexes- and Foreign Key Columns-Support
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)
The plans have been visible on this issue for the last six years:
You're welcome to contribute to this freely-available open-source library by opening a PR that adds the missing functionality.
Hi @bgrainger
please take a look: https://github.com/mysql-net/MySqlConnector/pull/1418
Foreign Keys, Indexes, and Index Columns support were added by @eaexo in #1419.
Hello @bgrainger when can we expect to have at least a beta released resp. published to the nuget.org?
Foreign Keys, Indexes, Index Columns added in 2.3.2.
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...
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
Thanks for quick update.
@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
The better solution is implementing the restriction, which I've done: https://github.com/mysql-net/MySqlConnector/commit/d3ad6d1acf8f70e0e693ac845e3ed342222396c1#diff-f0b4261dcdfed8eaab87870a6bce4b45f0a6c91aadddb44b47ff239665b4a082R535-R539