Replace `int` with `long` as ID type in samples/docs/tests
This project originally used int (32-bit) as the ID type in resources. While that's not wrong, I believe we should default to long (64-bit) in docs, samples and most tests. With many database transactions, the 2 billion limit can be reached earlier than expected, requiring a costly database migration and possible outage. A 64-bit auto-incrementing number doesn't have this limitation. Users can always choose their own ID type, but for anyone who doesn't care, this sounds like the safer default.
We should keep a few tests around, though, that still use int, so it remains covered. Models in JsonApiDotNetCoreTests/IntegrationTests/ReadWrite and JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations should not be updated, as they cover scenarios with varying ID types.
The change is basically from, for example:
public sealed class TelevisionBroadcast : Identifiable<int>
to:
public sealed class TelevisionBroadcast : Identifiable<long>
Likewise, tests that parse the ID should be updated accordingly, from:
int newShopId = int.Parse(responseDocument.Data.SingleValue.Id);
to:
long newShopId = long.Parse(responseDocument.Data.SingleValue.Id);
As well as usages to unknown IDs in tests, such as from:
int id = Unknown.StringId.Int32;
to:
long id = Unknown.StringId.Int64;
Hi @ziagham,
I’d be happy to help with this task. Please let me know if you’d like me to take this on.
Thanks!
Hi @niteshsinghal85, you're welcome to pick this up. Looking forward to your contribution!
@bkoelman a quick question, about the benchmark , i see that in the benchmark also Identifiable<int> is used.
do you want to update the benchmark also to Identifiable<long>
Yes