Skip to content

Commit

Permalink
fix generated reader bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Aug 8, 2024
1 parent 5ff91ba commit 6f27712
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/FluentCommand.Generators/DataReaderFactoryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ private static string GetReaderName(string propertyType)
"long" => "GetInt64",
"string" => "GetString",
"FluentCommand.ConcurrencyToken" => "GetBytes",
_ => $"GetValue<{propertyType}>"
_ => $"GetValue<{type}>"
};
}

Expand Down
18 changes: 17 additions & 1 deletion test/FluentCommand.SqlServer.Tests/DataQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public async System.Threading.Tasks.Task SqlTransactionQuery()

await using var transaction = await session.BeginTransactionAsync(IsolationLevel.ReadCommitted);

var id = Guid.NewGuid();
var id = Guid.NewGuid();
var user = new User
{
Id = id,
Expand Down Expand Up @@ -437,5 +437,21 @@ public async System.Threading.Tasks.Task SqlTransactionQuery()
await transaction.RollbackAsync();
}

[Fact]
public async System.Threading.Tasks.Task SqlQueryDataTypeAsync()
{
await using var session = Services.GetRequiredService<IDataSession>();
session.Should().NotBeNull();

var results = await session
.Sql(builder => builder
.Select<DataType>()
.OrderBy(p => p.Id)
.Limit(0, 10)
)
.QueryAsync<DataType>();

results.Should().NotBeNull();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ CREATE TABLE [dbo].[DataType] (
[Long] bigint NOT NULL,
[Float] real NOT NULL,
[Double] float NOT NULL,
[Decimal] decimal NOT NULL,
[Decimal] decimal(19, 4) NOT NULL,
[DateTime] datetime NOT NULL,
[DateTimeOffset] datetimeoffset NOT NULL,
[Guid] uniqueidentifier NOT NULL,
Expand All @@ -175,7 +175,7 @@ CREATE TABLE [dbo].[DataType] (
[LongNull] bigint NULL,
[FloatNull] real NULL,
[DoubleNull] float NULL,
[DecimalNull] decimal NULL,
[DecimalNull] decimal(19, 4) NULL,
[DateTimeNull] datetime NULL,
[DateTimeOffsetNull] datetimeoffset NULL,
[GuidNull] uniqueidentifier NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,21 @@ WHEN NOT MATCHED BY TARGET THEN
VALUES (s.[UserId], s.[RoleId])
OUTPUT $action as [Action];

/* Table [dbo].[DataType] data */

MERGE INTO [dbo].[DataType] AS t
USING
(
VALUES
(1, N'Testing', 1, 123, 132123, 123.12, 123.12, 123.1000, '2024-01-30 00:00:00.000', '2024-01-30 00:00:00.000000-06:00', '744f7775-5369-4809-994b-62abfae17724', '11:30:15', '2024-01-30 00:00:00.000', '13:30:15', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(2, N'Full', 0, 222, 2353, 563.23, 456.56, 2552.1000, '2024-02-15 00:00:00.000', '2024-02-15 00:00:00.000000-06:00', 'cca7e4a4-446f-4f24-9c3a-9d2a5b547877', '15:15:30', '2024-02-06 00:00:00.000', '01:23:11', 0, 333, 454, 563.23, 456.56, 2552.0130, '2024-02-15 00:00:00.000', '2024-02-15 00:00:00.000000-06:00', 'cca7e4a4-446f-4f24-9c3a-9d2a5b547877', '15:15:30', '2024-02-06 00:00:00.000', '01:23:11')
)
AS s
([Id], [Name], [Boolean], [Short], [Long], [Float], [Double], [Decimal], [DateTime], [DateTimeOffset], [Guid], [TimeSpan], [DateOnly], [TimeOnly], [BooleanNull], [ShortNull], [LongNull], [FloatNull], [DoubleNull], [DecimalNull], [DateTimeNull], [DateTimeOffsetNull], [GuidNull], [TimeSpanNull], [DateOnlyNull], [TimeOnlyNull])
ON (t.[Id] = s.[Id])
WHEN NOT MATCHED BY TARGET THEN
INSERT ([Id], [Name], [Boolean], [Short], [Long], [Float], [Double], [Decimal], [DateTime], [DateTimeOffset], [Guid], [TimeSpan], [DateOnly], [TimeOnly], [BooleanNull], [ShortNull], [LongNull], [FloatNull], [DoubleNull], [DecimalNull], [DateTimeNull], [DateTimeOffsetNull], [GuidNull], [TimeSpanNull], [DateOnlyNull], [TimeOnlyNull])
VALUES (s.[Id], s.[Name], s.[Boolean], s.[Short], s.[Long], s.[Float], s.[Double], s.[Decimal], s.[DateTime], s.[DateTimeOffset], s.[Guid], s.[TimeSpan], s.[DateOnly], s.[TimeOnly], s.[BooleanNull], s.[ShortNull], s.[LongNull], s.[FloatNull], s.[DoubleNull], s.[DecimalNull], s.[DateTimeNull], s.[DateTimeOffsetNull], s.[GuidNull], s.[TimeSpanNull], s.[DateOnlyNull], s.[TimeOnlyNull])
WHEN MATCHED THEN
UPDATE SET t.[Name] = s.[Name], t.[Boolean] = s.[Boolean], t.[Short] = s.[Short], t.[Long] = s.[Long], t.[Float] = s.[Float], t.[Double] = s.[Double], t.[Decimal] = s.[Decimal], t.[DateTime] = s.[DateTime], t.[DateTimeOffset] = s.[DateTimeOffset], t.[Guid] = s.[Guid], t.[TimeSpan] = s.[TimeSpan], t.[DateOnly] = s.[DateOnly], t.[TimeOnly] = s.[TimeOnly], t.[BooleanNull] = s.[BooleanNull], t.[ShortNull] = s.[ShortNull], t.[LongNull] = s.[LongNull], t.[FloatNull] = s.[FloatNull], t.[DoubleNull] = s.[DoubleNull], t.[DecimalNull] = s.[DecimalNull], t.[DateTimeNull] = s.[DateTimeNull], t.[DateTimeOffsetNull] = s.[DateTimeOffsetNull], t.[GuidNull] = s.[GuidNull], t.[TimeSpanNull] = s.[TimeSpanNull], t.[DateOnlyNull] = s.[DateOnlyNull], t.[TimeOnlyNull] = s.[TimeOnlyNull]
OUTPUT $action as MergeAction;

0 comments on commit 6f27712

Please sign in to comment.