Skip to content

Commit 379ea68

Browse files
klesta490Vladimír Kleštinec
and
Vladimír Kleštinec
authored
Repro for possible bug in Primary key order (#154)
* Repro for possible bug in Primary key order * Repro for possible bug in Primary key order --------- Co-authored-by: Vladimír Kleštinec <[email protected]>
1 parent 831029a commit 379ea68

File tree

1 file changed

+56
-18
lines changed

1 file changed

+56
-18
lines changed

BTDB.SourceGenerator.Test/RelationTests.cs

+56-18
Original file line numberDiff line numberDiff line change
@@ -250,28 +250,66 @@ public Task ComplexSkymambaExample()
250250
{
251251
// language=cs
252252
return VerifySourceGenerator("""
253-
using System.Collections.Generic;
254-
using BTDB.ODBLayer;
253+
using System.Collections.Generic;
254+
using BTDB.ODBLayer;
255255
256-
public class ContinentMigrationInfo
257-
{
258-
[PrimaryKey(1)]
259-
public ulong CompanyId { get; set; }
260-
}
256+
public class ContinentMigrationInfo
257+
{
258+
[PrimaryKey(1)]
259+
public ulong CompanyId { get; set; }
260+
}
261261
262-
public interface ICompanyTableBase<T> : ICovariantCompanyTableBase<T>, IRelation<T>
263-
where T : class
264-
{
265-
}
262+
public interface ICompanyTableBase<T> : ICovariantCompanyTableBase<T>, IRelation<T>
263+
where T : class
264+
{
265+
}
266266
267-
public interface ICovariantCompanyTableBase<out T> : ICovariantRelation<T> where T : class
268-
{
269-
}
267+
public interface ICovariantCompanyTableBase<out T> : ICovariantRelation<T> where T : class
268+
{
269+
}
270270
271-
public interface IPeripheryMigrationInfoTable : ICompanyTableBase<ContinentMigrationInfo>
272-
{
273-
}
271+
public interface IPeripheryMigrationInfoTable : ICompanyTableBase<ContinentMigrationInfo>
272+
{
273+
}
274274
275-
""");
275+
""");
276+
}
277+
278+
[Fact]
279+
public Task ComplexSkymambaExample_OrderError()
280+
{
281+
// language=cs
282+
return VerifySourceGenerator("""
283+
using System.Collections.Generic;
284+
using BTDB.ODBLayer;
285+
286+
public class Item : ICompanyRecord
287+
{
288+
[PrimaryKey(1)]
289+
public ulong CompanyId { get; set; }
290+
291+
[PrimaryKey(2)]
292+
public string Queue { get; set; }
293+
294+
[PrimaryKey(3)]
295+
public Guid ItemId { get; set; }
296+
297+
[SecondaryKey(nameof(LockDeadline), IncludePrimaryKeyOrder = 2, Order = 3)]
298+
public int Priority { get; set; }
299+
300+
/// <summary>
301+
/// The deadline by which the worker should renew lock or complete the work;
302+
/// after deadline work item is available to other worker.
303+
/// </summary>
304+
[SecondaryKey(nameof(LockDeadline), Order = 4)]
305+
public DateTime LockDeadline { get; set; }
306+
}
307+
308+
309+
public interface IItemTable : IRelation<Item>
310+
{
311+
}
312+
313+
""");
276314
}
277315
}

0 commit comments

Comments
 (0)