-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add provider metadata discovery #187
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
Open
PrzemyslawKlys
wants to merge
42
commits into
master
Choose a base branch
from
feature/metadata-discovery-no-smo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
ec51d8c
Add provider metadata discovery
PrzemyslawKlys fc58e2b
Fix SQLite metadata discovery cleanup
PrzemyslawKlys 1cf319d
Fix metadata discovery review gaps
PrzemyslawKlys c55ccc7
Add foreign key and routine metadata
PrzemyslawKlys 4b0ce89
Fix metadata fidelity review gaps
PrzemyslawKlys 91ecc37
Merge master into metadata discovery branch
PrzemyslawKlys 90bc39a
Fix latest metadata review comments
PrzemyslawKlys b903a59
Fix metadata fidelity review comments
PrzemyslawKlys d213320
Add SQL Server management metadata foundation
PrzemyslawKlys fca37d0
Add SQL Server management tier builders
PrzemyslawKlys f705f85
Address SQL Server management PR review
PrzemyslawKlys ff6ec3f
Tighten SQL Server management scripting fidelity
PrzemyslawKlys bf88c06
Improve SQL Server script fidelity
PrzemyslawKlys a097ab9
Preserve advanced SQL Server table metadata
PrzemyslawKlys 32c3f42
Improve provider metadata fidelity
PrzemyslawKlys 2df8aa7
Merge remote-tracking branch 'origin/feature/metadata-discovery-no-sm…
PrzemyslawKlys ed34822
Preserve SQL Server management details
PrzemyslawKlys 3cef7e6
Improve advanced metadata fidelity
PrzemyslawKlys be534d0
Merge remote-tracking branch 'origin/feature/metadata-discovery-no-sm…
PrzemyslawKlys 5cc59d5
Harden SQL Server management scripting
PrzemyslawKlys 22e8709
Preserve SQL Server table scripting state
PrzemyslawKlys 6249327
Defer SQL Server table constraint scripting
PrzemyslawKlys 9590f35
Preserve provider metadata edge cases
PrzemyslawKlys 697080d
Preserve advanced provider metadata
PrzemyslawKlys 5331402
Preserve SQL Server table script state
PrzemyslawKlys 6b0020b
Preserve advanced SQL Server management metadata
PrzemyslawKlys bd1956b
Preserve provider metadata review cases
PrzemyslawKlys 5fd7aa0
Preserve SQL Server advanced script edge cases
PrzemyslawKlys dbcde21
Preserve advanced SQL Server script metadata
PrzemyslawKlys 0c7a863
Gate advanced SQL Server catalogs
PrzemyslawKlys a0573e8
Preserve advanced SQL Server management metadata
PrzemyslawKlys 6846387
Refine SQL Server management edge scripting
PrzemyslawKlys ca0ffad
Preserve advanced SQL Server script metadata
PrzemyslawKlys 54eaeee
Handle additional SQL Server management edge cases
PrzemyslawKlys 392ebf3
Preserve SQL Server trigger and permission metadata
PrzemyslawKlys efac3a6
Preserve SQL Server ledger and CLR metadata
PrzemyslawKlys 65c222b
Gate SQL Server management catalog branches
PrzemyslawKlys 9ca3ebd
Fix SQL Server Azure metadata edge cases
PrzemyslawKlys 7fc4eb0
Preserve SQL Server graph and CLR edge metadata
PrzemyslawKlys 0c2d320
Preserve SQL Server trigger metadata edge cases
PrzemyslawKlys 63ca13e
Preserve SQL Server advanced script details
PrzemyslawKlys fa81868
Merge pull request #188 from EvotecIT/feature/sqlserver-management-tiers
PrzemyslawKlys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Describes a column on a provider-neutral table or view result. | ||
| /// </summary> | ||
| public sealed record DbaColumnInfo(string Schema, string Table, string Name, string DataType) | ||
| { | ||
| /// <summary>One-based ordinal position in the table or view.</summary> | ||
| public int Ordinal { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the provider reports the column as nullable.</summary> | ||
| public bool? IsNullable { get; init; } | ||
|
|
||
| /// <summary>Maximum character or binary length when available.</summary> | ||
| public long? MaxLength { get; init; } | ||
|
|
||
| /// <summary>Numeric precision when available.</summary> | ||
| public int? Precision { get; init; } | ||
|
|
||
| /// <summary>Numeric scale when available.</summary> | ||
| public int? Scale { get; init; } | ||
|
|
||
| /// <summary>Provider-specific default expression when available.</summary> | ||
| public string? DefaultExpression { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the provider reports the column as identity or auto-incrementing.</summary> | ||
| public bool? IsIdentity { get; init; } | ||
|
|
||
| /// <summary>Provider-specific identity generation strategy, such as IDENTITY, AUTO_INCREMENT, ALWAYS, or BY DEFAULT.</summary> | ||
| public string? IdentityGeneration { get; init; } | ||
|
|
||
| /// <summary>Provider-specific generated or computed column expression when available.</summary> | ||
| public string? GeneratedExpression { get; init; } | ||
|
|
||
| /// <summary>Provider-specific generated column kind, such as COMPUTED, STORED, or VIRTUAL.</summary> | ||
| public string? GeneratedKind { get; init; } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Describes a database or catalog visible to a provider connection. | ||
| /// </summary> | ||
| public sealed record DbaDatabaseInfo(string Name) | ||
| { | ||
| /// <summary>Provider-specific owner, schema owner, or current user when available.</summary> | ||
| public string? Owner { get; init; } | ||
|
|
||
| /// <summary>Provider-specific collation or encoding when available.</summary> | ||
| public string? Collation { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the database is provider/system-owned when the provider exposes that information.</summary> | ||
| public bool? IsSystem { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Describes one column mapping in a foreign key relationship. | ||
| /// </summary> | ||
| public sealed record DbaForeignKeyInfo( | ||
| string Schema, | ||
| string Table, | ||
| string Name, | ||
| string Column, | ||
| string ReferencedSchema, | ||
| string ReferencedTable, | ||
| string ReferencedColumn) | ||
| { | ||
| /// <summary>One-based ordinal position of the column inside the foreign key.</summary> | ||
| public int Ordinal { get; init; } | ||
|
|
||
| /// <summary>Provider-specific update action when available.</summary> | ||
| public string? UpdateRule { get; init; } | ||
|
|
||
| /// <summary>Provider-specific delete action when available.</summary> | ||
| public string? DeleteRule { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the provider reports the constraint as enabled.</summary> | ||
| public bool? IsEnabled { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the provider reports the constraint as validated or trusted.</summary> | ||
| public bool? IsTrusted { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Describes an index column. Multi-column indexes return one row per indexed column. | ||
| /// </summary> | ||
| public sealed record DbaIndexInfo(string Schema, string Table, string Name) | ||
| { | ||
| /// <summary>Provider-specific index type or access method when available.</summary> | ||
| public string? IndexType { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the index is unique.</summary> | ||
| public bool IsUnique { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the index backs a primary key.</summary> | ||
| public bool IsPrimaryKey { get; init; } | ||
|
|
||
| /// <summary>Indexed column name when the provider exposes a direct column mapping.</summary> | ||
| public string? Column { get; init; } | ||
|
|
||
| /// <summary>Indexed expression text when the index key is not a direct column reference.</summary> | ||
| public string? Expression { get; init; } | ||
|
|
||
| /// <summary>One-based ordinal position of the column inside the index.</summary> | ||
| public int Ordinal { get; init; } | ||
|
|
||
| /// <summary>Indicates descending sort order when the provider exposes it.</summary> | ||
| public bool? IsDescending { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the column is included but not part of the index key.</summary> | ||
| public bool? IsIncluded { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the provider reports the index as visible to query optimization.</summary> | ||
| public bool? IsVisible { get; init; } | ||
|
|
||
| /// <summary>Provider-specific prefix length for partial-width index keys.</summary> | ||
| public int? PrefixLength { get; init; } | ||
|
|
||
| /// <summary>Provider-specific filter or partial-index predicate when available.</summary> | ||
| public string? FilterDefinition { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| using System; | ||
| using System.Data; | ||
| using System.Globalization; | ||
|
|
||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Provides small conversion helpers for provider metadata readers. | ||
| /// </summary> | ||
| public static class DbaMetadataReader | ||
| { | ||
| /// <summary>Reads a required string field.</summary> | ||
| public static string GetString(IDataRecord record, string name) | ||
| => Convert.ToString(GetValue(record, name), CultureInfo.InvariantCulture) ?? string.Empty; | ||
|
|
||
| /// <summary>Reads an optional string field.</summary> | ||
| public static string? GetNullableString(IDataRecord record, string name) | ||
| { | ||
| var value = GetValue(record, name); | ||
| return value == null || value == DBNull.Value | ||
| ? null | ||
| : Convert.ToString(value, CultureInfo.InvariantCulture); | ||
| } | ||
|
|
||
| /// <summary>Reads a required integer field.</summary> | ||
| public static int GetInt32(IDataRecord record, string name) | ||
| => Convert.ToInt32(GetValue(record, name), CultureInfo.InvariantCulture); | ||
|
|
||
| /// <summary>Reads an optional integer field.</summary> | ||
| public static int? GetNullableInt32(IDataRecord record, string name) | ||
| { | ||
| var value = GetValue(record, name); | ||
| return value == null || value == DBNull.Value | ||
| ? null | ||
| : Convert.ToInt32(value, CultureInfo.InvariantCulture); | ||
| } | ||
|
|
||
| /// <summary>Reads an optional long field.</summary> | ||
| public static long? GetNullableInt64(IDataRecord record, string name) | ||
| { | ||
| var value = GetValue(record, name); | ||
| return value == null || value == DBNull.Value | ||
| ? null | ||
| : Convert.ToInt64(value, CultureInfo.InvariantCulture); | ||
| } | ||
|
|
||
| /// <summary>Reads a required Boolean field.</summary> | ||
| public static bool GetBoolean(IDataRecord record, string name) | ||
| => ConvertToBoolean(GetValue(record, name)) ?? false; | ||
|
|
||
| /// <summary>Reads an optional Boolean field.</summary> | ||
| public static bool? GetNullableBoolean(IDataRecord record, string name) | ||
| => ConvertToBoolean(GetValue(record, name)); | ||
|
|
||
| private static object? GetValue(IDataRecord record, string name) | ||
| { | ||
| var ordinal = record.GetOrdinal(name); | ||
| return record.IsDBNull(ordinal) ? null : record.GetValue(ordinal); | ||
| } | ||
|
|
||
| private static bool? ConvertToBoolean(object? value) | ||
| { | ||
| if (value == null || value == DBNull.Value) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| if (value is bool boolean) | ||
| { | ||
| return boolean; | ||
| } | ||
|
|
||
| if (value is string text) | ||
| { | ||
| if (bool.TryParse(text, out var parsed)) | ||
| { | ||
| return parsed; | ||
| } | ||
|
|
||
| if (string.Equals(text, "YES", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(text, "Y", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(text, "1", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| if (string.Equals(text, "NO", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(text, "N", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(text, "0", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| return Convert.ToInt32(value, CultureInfo.InvariantCulture) != 0; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Describes a provider-neutral stored routine such as a procedure or function. | ||
| /// </summary> | ||
| public sealed record DbaRoutineInfo(string Schema, string Name, DbaRoutineKind Kind) | ||
| { | ||
| /// <summary>Provider-specific result data type when available.</summary> | ||
| public string? DataType { get; init; } | ||
|
|
||
| /// <summary>Provider-specific overload-safe routine identifier when available.</summary> | ||
| public string? SpecificName { get; init; } | ||
|
|
||
| /// <summary>Provider-specific argument signature when available.</summary> | ||
| public string? Signature { get; init; } | ||
|
|
||
| /// <summary>Routine definition text when the provider exposes it to the current principal.</summary> | ||
| public string? Definition { get; init; } | ||
|
|
||
| /// <summary>Indicates whether the provider marks the routine as system-owned.</summary> | ||
| public bool? IsSystem { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Classifies a stored routine. | ||
| /// </summary> | ||
| public enum DbaRoutineKind | ||
| { | ||
| /// <summary>Routine type is not known or does not fit the provider-neutral categories.</summary> | ||
| Unknown, | ||
|
|
||
| /// <summary>Stored procedure routine.</summary> | ||
| Procedure, | ||
|
|
||
| /// <summary>Function routine.</summary> | ||
| Function, | ||
|
|
||
| /// <summary>Oracle package or another package-style routine container.</summary> | ||
| Package | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Identifies a tabular database object such as a table or view. | ||
| /// </summary> | ||
| public sealed record DbaTableInfo(string Schema, string Name, DbaTableKind Kind) | ||
| { | ||
| /// <summary>Provider-specific object owner when different from <see cref="Schema"/>.</summary> | ||
| public string? Owner { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| namespace DBAClientX.Metadata; | ||
|
|
||
| /// <summary> | ||
| /// Classifies provider-neutral tabular objects returned by metadata discovery. | ||
| /// </summary> | ||
| public enum DbaTableKind | ||
| { | ||
| /// <summary>A regular table.</summary> | ||
| Table, | ||
|
|
||
| /// <summary>A view or virtual table-like object.</summary> | ||
| View | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.