-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Connection.GetSchema #185
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #185 +/- ##
===========================================
+ Coverage 87.83% 88.41% +0.58%
===========================================
Files 42 54 +12
Lines 1504 1761 +257
Branches 217 239 +22
===========================================
+ Hits 1321 1557 +236
- Misses 127 146 +19
- Partials 56 58 +2 ☔ View full report in Codecov by Sentry. |
Pull Request Test Coverage Report for Build 9155702909Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Is it still WIP? |
Yes, want to implement a few more essential collections. |
I'll mark it as Draft. Please mark it ready for review when it's finished. Thanks |
Ok. This is ready for review now. I've implemented almost all metadata I wanted, except |
Thanks, I'll try to review it in the next few days. Is there any documentation on how |
The documentation is really loose, the basic description of how it should work is here: https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/retrieving-database-schema-information. With common schema collections and custom collections that are available via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good! Left some minor comments.
DuckDB.NET.Data/DuckDBSchema.cs
Outdated
{ DuckDbMetaDataCollectionNames.Tables, 4, 3 }, | ||
{ DuckDbMetaDataCollectionNames.Columns, 4, 4 }, | ||
{ DuckDbMetaDataCollectionNames.ForeignKeys, 4, 3 }, | ||
{ DuckDbMetaDataCollectionNames.Indexes, 4, 3 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do these numbers mean? Can you add a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from columns definition above:
{ DbMetaDataColumnNames.CollectionName, typeof(string) },
{ DbMetaDataColumnNames.NumberOfRestrictions, typeof(int) },
{ DbMetaDataColumnNames.NumberOfIdentifierParts, typeof(int) }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do the numbers 4 and 3 refer too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first number says how many restrictions could the collection have (it is about restrictionValues
/restrictionNames
arrays). The last number is purely for information purposes. It says that index has 3 components in its full name: catalog.schema.index_name
.
DuckDB.NET.Data/DuckDBSchema.cs
Outdated
const string query = "SELECT table_catalog, table_schema, table_name, table_type FROM information_schema.tables"; | ||
|
||
using var command = BuildCommand(connection, query, restrictionValues, true, | ||
["table_catalog", "table_schema", "table_name", "table_type"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the numbers above refer to the length of these arrays, can you extract these arrays somewhere and refer to their Length in GetMetaDataCollections
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the numbers above refer to the length of these arrays
Yes,
can you extract these arrays somewhere and refer to their Length in GetMetaDataCollections
I could, try, but it would just complicate the code, I afraid, without providing any benefit.
Thanks, merged. |
Thank you |
@hazzik This is now live on NuGet. |
This PR implements
Connection.GetSchema
.Standard collections:
✔️ MetaDataCollections
✔️ Restrictions
✔️ ReservedWords
❌ DataSourceInformation
❌ DataTypes
Non standard common collections
✔️ Tables
✔️ Columns
✔️ ForeignKeys
✔️ Indexes