|
1 | 1 | using FluentAssertions;
|
| 2 | +using ksqlDb.RestApi.Client.FluentAPI.Builders; |
2 | 3 | using ksqlDB.RestApi.Client.KSql.Linq.PullQueries;
|
3 | 4 | using ksqlDB.RestApi.Client.KSql.Query.Context;
|
4 | 5 | using ksqlDB.RestApi.Client.KSql.Query.Functions;
|
@@ -245,4 +246,39 @@ public string SelectColumnsUsingPullQueryThatHaveJsonPropertyNameAndWhere(Identi
|
245 | 246 | //Assert
|
246 | 247 | return ksql.ReplaceLineEndings();
|
247 | 248 | }
|
| 249 | + |
| 250 | + private class Record |
| 251 | + { |
| 252 | + public long? RowOffset { get; set; } |
| 253 | + public short? RowPartition { get; set; } |
| 254 | + public long RowTime { get; set; } |
| 255 | + } |
| 256 | + |
| 257 | + private class Test : Record |
| 258 | + { |
| 259 | + public string Name { get; set; } |
| 260 | + } |
| 261 | + |
| 262 | + [TestCase(Never, ExpectedResult = $"SELECT RowTime, RowOffset, RowPartition, Name FROM {nameof(Test)};")] |
| 263 | + [TestCase(Keywords, ExpectedResult = $"SELECT RowTime, RowOffset, RowPartition, Name FROM {nameof(Test)};")] |
| 264 | + [TestCase(Always, ExpectedResult = $"SELECT RowTime, RowOffset, RowPartition, `Name` FROM `{nameof(Test)}`;")] |
| 265 | + public string SelectColumnsUsingModelBuilderWithPseudoColum(IdentifierEscaping escaping) |
| 266 | + { |
| 267 | + //Arrange |
| 268 | + var modelBuilder = new ModelBuilder(); |
| 269 | + modelBuilder.Entity<JsonPropertyNameTestData>().Property(i => i.RowOffset).AsPseudoColumn(); |
| 270 | + modelBuilder.Entity<JsonPropertyNameTestData>().Property(i => i.RowPartition).AsPseudoColumn(); |
| 271 | + modelBuilder.Entity<JsonPropertyNameTestData>().Property(i => i.RowTime).AsPseudoColumn(); |
| 272 | + |
| 273 | + var dbContext = new KSqlDBContext(new KSqlDBContextOptions(TestParameters.KsqlDbUrl) |
| 274 | + { IdentifierEscaping = escaping, ShouldPluralizeFromItemName = false }, modelBuilder); |
| 275 | + |
| 276 | + //Act |
| 277 | + var ksql = dbContext.CreatePullQuery<Test>() |
| 278 | + .Select(c => new { c.RowTime, c.RowOffset, c.RowPartition, c.Name }) |
| 279 | + .ToQueryString(); |
| 280 | + |
| 281 | + //Assert |
| 282 | + return ksql.ReplaceLineEndings(); |
| 283 | + } |
248 | 284 | }
|
0 commit comments