Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<ItemGroup>
<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />
<PackageVersion Include="Boxed.Mapping" Version="7.0.0" />
<PackageVersion Include="Dapper" Version="2.1.79" />
<PackageVersion Include="Dapper" Version="2.1.86" />
<PackageVersion Include="Enums.NET" Version="5.0.0" />
<PackageVersion Include="FluentAssertions" Version="8.10.0" />
<PackageVersion Include="FluentAssertions" Version="8.11.0" />
<PackageVersion Include="LanguageExt.Core" Version="4.4.9" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.9.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.2" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.3" />
<PackageVersion Include="Microsoft.Data.SQLite" Version="10.0.12" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.12" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.12" />
Expand All @@ -19,28 +19,28 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.12" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.12" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="10.0.12" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.10.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.401" />
<PackageVersion Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="180.102.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.11.0" />
<PackageVersion Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="180.107.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.11.2" />
<PackageVersion Include="Microsoft.Testing.Platform" Version="2.4.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="MySqlConnector" Version="2.6.2" />
<PackageVersion Include="Nito.AsyncEx" Version="5.1.2" />
<PackageVersion Include="Npgsql" Version="10.0.3" />
<PackageVersion Include="NUnit" Version="4.6.1" />
<PackageVersion Include="NUnit.Analyzers" Version="4.14.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.15.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.3.0" />
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="23.26.301" />
<PackageVersion Include="Polly" Version="8.7.0" />
<PackageVersion Include="Polly" Version="8.8.0" />
<PackageVersion Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageVersion Include="QuikGraph" Version="2.5.0" />
<PackageVersion Include="Roslyn.System.IO.Abstractions.Analyzers" Version="12.2.19" />
<PackageVersion Include="Roslynator.Analyzers" Version="5.0.0" />
<PackageVersion Include="ServiceStack.OrmLite" Version="10.1.4" />
<PackageVersion Include="ServiceStack.OrmLite" Version="10.2.0" />
<PackageVersion Include="Spectre.Console.Analyzer" Version="1.0.0" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.55.0" />
<PackageVersion Include="Spectre.Console.Cli.Extensions.DependencyInjection" Version="0.28.0" />
<PackageVersion Include="Spectre.Console.Cli.Extensions.DependencyInjection" Version="0.29.0" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="3.0.5" />
<PackageVersion Include="System.IO.Abstractions" Version="22.2.0" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="22.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal sealed record Result
internal const string Sql = @$"
select
s.name as [{nameof(Result.SchemaName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.schemas s
left join sys.extended_properties ep on s.schema_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 3
order by s.name";
Expand Down
10 changes: 6 additions & 4 deletions src/SJP.Schematic.SqlServer/Queries/GetAllSequenceDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ internal sealed record Result : ISequenceDefinitionRow
}

internal const string Sql = @$"
-- sys.sequences reports the bounds as sql_variant, whose runtime type follows the sequence's
-- own data type, so they're converted to a single type wide enough to hold any of them
select
ss.name as [{nameof(Result.SchemaName)}],
s.name as [{nameof(Result.SequenceName)}],
Expand All @@ -42,10 +44,10 @@ internal sealed record Result : ISequenceDefinitionRow
cast(t.max_length as int) as [{nameof(Result.TypeMaxLength)}],
cast(s.precision as int) as [{nameof(Result.Precision)}],
cast(s.scale as int) as [{nameof(Result.Scale)}],
s.start_value as [{nameof(Result.StartValue)}],
s.increment as [{nameof(Result.Increment)}],
s.minimum_value as [{nameof(Result.MinValue)}],
s.maximum_value as [{nameof(Result.MaxValue)}],
convert(decimal(38, 0), s.start_value) as [{nameof(Result.StartValue)}],
convert(decimal(38, 0), s.increment) as [{nameof(Result.Increment)}],
convert(decimal(38, 0), s.minimum_value) as [{nameof(Result.MinValue)}],
convert(decimal(38, 0), s.maximum_value) as [{nameof(Result.MaxValue)}],
s.is_cycling as [{nameof(Result.Cycle)}],
s.is_cached as [{nameof(Result.IsCached)}],
s.cache_size as [{nameof(Result.CacheSize)}]
Expand Down
2 changes: 1 addition & 1 deletion src/SJP.Schematic.SqlServer/Queries/GetRoutineComments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal sealed record Result
select
'ROUTINE' as [{nameof(Result.ObjectType)}],
r.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.objects r
left join sys.extended_properties ep on r.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
where r.schema_id = SCHEMA_ID(@{nameof(Query.SchemaName)}) and r.name = @{nameof(Query.RoutineName)} and r.is_ms_shipped = 0
Expand Down
2 changes: 1 addition & 1 deletion src/SJP.Schematic.SqlServer/Queries/GetSchemaComments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal sealed record Result
internal const string Sql = @$"
select
s.name as [{nameof(Result.SchemaName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.schemas s
left join sys.extended_properties ep on s.schema_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 3
where s.name = @{nameof(Query.SchemaName)}";
Expand Down
2 changes: 1 addition & 1 deletion src/SJP.Schematic.SqlServer/Queries/GetSequenceComments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal sealed record Result
select
'SEQUENCE' as [{nameof(Result.ObjectType)}],
s.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.sequences s
left join sys.extended_properties ep on s.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
where s.schema_id = SCHEMA_ID(@{nameof(Query.SchemaName)}) and s.name = @{nameof(Query.SequenceName)} and s.is_ms_shipped = 0
Expand Down
10 changes: 6 additions & 4 deletions src/SJP.Schematic.SqlServer/Queries/GetSequenceDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ internal sealed record Result : ISequenceDefinitionRow
}

internal const string Sql = @$"
-- sys.sequences reports the bounds as sql_variant, whose runtime type follows the sequence's
-- own data type, so they're converted to a single type wide enough to hold any of them
select
schema_name(s.schema_id) as [{nameof(Result.SchemaName)}],
s.name as [{nameof(Result.SequenceName)}],
Expand All @@ -51,10 +53,10 @@ internal sealed record Result : ISequenceDefinitionRow
cast(t.max_length as int) as [{nameof(Result.TypeMaxLength)}],
cast(s.precision as int) as [{nameof(Result.Precision)}],
cast(s.scale as int) as [{nameof(Result.Scale)}],
s.start_value as [{nameof(Result.StartValue)}],
s.increment as [{nameof(Result.Increment)}],
s.minimum_value as [{nameof(Result.MinValue)}],
s.maximum_value as [{nameof(Result.MaxValue)}],
convert(decimal(38, 0), s.start_value) as [{nameof(Result.StartValue)}],
convert(decimal(38, 0), s.increment) as [{nameof(Result.Increment)}],
convert(decimal(38, 0), s.minimum_value) as [{nameof(Result.MinValue)}],
convert(decimal(38, 0), s.maximum_value) as [{nameof(Result.MaxValue)}],
s.is_cycling as [{nameof(Result.Cycle)}],
s.is_cached as [{nameof(Result.IsCached)}],
s.cache_size as [{nameof(Result.CacheSize)}]
Expand Down
2 changes: 1 addition & 1 deletion src/SJP.Schematic.SqlServer/Queries/GetSynonymComments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal sealed record Result
select
'SYNONYM' as [{nameof(Result.ObjectType)}],
s.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.synonyms s
left join sys.extended_properties ep on s.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
where s.schema_id = SCHEMA_ID(@{nameof(Query.SchemaName)}) and s.name = @{nameof(Query.SynonymName)} and s.is_ms_shipped = 0
Expand Down
16 changes: 8 additions & 8 deletions src/SJP.Schematic.SqlServer/Queries/GetTableComments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal sealed record Result
select
'TABLE' as [{nameof(Result.ObjectType)}],
t.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.tables t
left join sys.extended_properties ep on t.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
where t.schema_id = SCHEMA_ID(@{nameof(Query.SchemaName)}) and t.name = @{nameof(Query.TableName)} and t.is_ms_shipped = 0
Expand All @@ -38,7 +38,7 @@ union all
select
'COLUMN' as [{nameof(Result.ObjectType)}],
c.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.tables t
inner join sys.columns c on t.object_id = c.object_id
left join sys.extended_properties ep on t.object_id = ep.major_id and c.column_id = ep.minor_id and ep.name = @{nameof(Query.CommentProperty)} and ep.class = 1
Expand All @@ -50,7 +50,7 @@ union all
select
'CHECK' as [{nameof(Result.ObjectType)}],
cc.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.tables t
inner join sys.check_constraints cc on t.object_id = cc.parent_object_id
left join sys.extended_properties ep on cc.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
Expand All @@ -62,7 +62,7 @@ union all
select
'FOREIGN KEY' as [{nameof(Result.ObjectType)}],
fk.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.tables t
inner join sys.foreign_keys fk on t.object_id = fk.parent_object_id
left join sys.extended_properties ep on fk.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
Expand All @@ -74,7 +74,7 @@ union all
select
'UNIQUE' as [{nameof(Result.ObjectType)}],
kc.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.tables t
inner join sys.key_constraints kc on t.object_id = kc.parent_object_id
left join sys.extended_properties ep on kc.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
Expand All @@ -87,7 +87,7 @@ union all
select
'PRIMARY' as [{nameof(Result.ObjectType)}],
kc.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.tables t
inner join sys.key_constraints kc on t.object_id = kc.parent_object_id
left join sys.extended_properties ep on kc.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
Expand All @@ -100,7 +100,7 @@ union all
select
'INDEX' as [{nameof(Result.ObjectType)}],
i.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.tables t
inner join sys.indexes i on t.object_id = i.object_id
left join sys.extended_properties ep on t.object_id = ep.major_id and i.index_id = ep.minor_id and ep.name = @{nameof(Query.CommentProperty)} and ep.class = 7
Expand All @@ -114,7 +114,7 @@ union all
select
'TRIGGER' as [{nameof(Result.ObjectType)}],
tr.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.tables t
inner join sys.triggers tr on t.object_id = tr.parent_id
left join sys.extended_properties ep on tr.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal sealed record Result
select
'TYPE' as [{nameof(Result.ObjectType)}],
t.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.types t
left join sys.extended_properties ep on t.user_type_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 6
where t.schema_id = SCHEMA_ID(@{nameof(Query.SchemaName)}) and t.name = @{nameof(Query.TypeName)} and t.is_user_defined = 1
Expand Down
4 changes: 2 additions & 2 deletions src/SJP.Schematic.SqlServer/Queries/GetViewComments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal sealed record Result
select
'VIEW' as [{nameof(Result.ObjectType)}],
v.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.views v
left join sys.extended_properties ep on v.object_id = ep.major_id and ep.name = @{nameof(Query.CommentProperty)} and ep.minor_id = 0 and ep.class = 1
where v.schema_id = SCHEMA_ID(@{nameof(Query.SchemaName)}) and v.name = @{nameof(Query.ViewName)} and v.is_ms_shipped = 0
Expand All @@ -38,7 +38,7 @@ union all
select
'COLUMN' as [{nameof(Result.ObjectType)}],
c.name as [{nameof(Result.ObjectName)}],
ep.value as [{nameof(Result.Comment)}]
convert(nvarchar(max), ep.value) as [{nameof(Result.Comment)}]
from sys.views v
inner join sys.columns c on v.object_id = c.object_id
left join sys.extended_properties ep on v.object_id = ep.major_id and c.column_id = ep.minor_id and ep.name = @{nameof(Query.CommentProperty)} and ep.class = 1
Expand Down