Skip to content

Conversation

@dechristo
Copy link

No description provided.

Copy link
Member

@bgrainger bgrainger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests of the new method.

close = m_connection.Close;
}

var dataTable = m_connection.GetSchema(collectionName, restrictions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will introduce infinite recursion between this method and MySqlConnection.GetSchema.

Please add tests that verify the correct information is being returned, for example like

[Fact]
public void ReservedWordsSchema()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap! I will add all the tests once I get things right. I am just confused on how to get the restrictions now if this will lead to a infinite recursion. Could you shed some light, please?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MySqlConnection.GetSchema calls this method:

public override DataTable GetSchema(string collectionName, string[] restrictions) => GetSchemaProvider().GetSchema(collectionName);

(Or it will do, once the overload has changed.)

So this method shouldn't call back to MySqlConnection.GetSchema; it should just do the work.

return dataTable;
}

public DataTable GetSchema(string collectionName, string[] restrictions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think introducing a new method should be necessary; string[] restrictions could be added as a new parameter to the existing method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Can I make the default value null then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that sounds fine.

{
m_connection.Open();
close = m_connection.Close;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should just rely on the connection already being open, instead of opening and closing the connection (unless this is required for compatibility with other drivers).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Will change it.

dataTable.Rows.Add("Owner", "@Owner", "TABLE_SCHEMA", 2);
dataTable.Rows.Add("Table", "@Name", "TABLE_NAME", 3);
dataTable.Rows.Add("TableType", "@TableType", "TABLE_TYPE", 4);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Restrictions schema should have four columns: CollectionName, RestrictionName, RestrictionDefault, RestrictionNumber: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/common-schema-collections#restrictions

This table is filled with the names of restrictions that are supported by other schema tables.

For example, to indicate three restrictions on the Tables schema, you would add these rows:

CollectionName RestrictionName RestrictionDefault RestrictionNumber
Tables Schema   1
Tables Table   2
Tables TableType   3

While it's not OK to bring code from Connector/NET into this project, it is totally fine to perform "black box" testing and see what (for example) connection.GetSchema("Restrictions") returns when executed against that library. This code should return a subset of what it supports.

@bgrainger
Copy link
Member

To fix the DCO errors, please attest that you agree to the Developer Certificate of Origin (that is, you have the right to submit this code) by adding the line Signed-off-by: Your Name <youremail@example.com> to the end of your commit message.

More details here: https://probot.github.io/apps/dco/

Signed-off-by: Luiz Eduardo <dudu.christo@gmail.com>
@dechristo
Copy link
Author

Hi @bgrainger. I am still lost on how to proceed with the restrictions array.

@bgrainger
Copy link
Member

@dechristo I would lean towards making this all data-driven. Some ideas:

  • m_schemaCollections becomes Dictionary<string, SchemaInfo>.
  • SchemaInfo is a new class with Action<DataTable, string[]> FillSchema and string[] RestrictionNames properties.
  • RestrictionNames is a simple array of the restriction names supported by a collection.
  • FillSchema takes the restriction values (as a second parameter) and applies them appropriately. This will probably be adding a WHERE clause with parameters in most cases.
  • The "Restrictions" schema is filled by enumerating m_schemaCollections and filling the table with its RestrictionNames.

@KristianWedberg
Copy link

@bgrainger Hi, is the restrictions overload actually working now, returning correctly filtered results, or is this a won't-fix?

@bgrainger
Copy link
Member

@KristianWedberg The issue is still open: #374

I'm closing out this three-year-old PR as the author seems to have abandoned it, and it would need some work to fix all the merge conflicts with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants