-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.Data.Sqlite Get System.OverflowException When read uint type data from sqlite #30910
Comments
@CwjXFH that seems like the right behavior, what other behavior are you expecting here? |
@roji I use uint type in my application, and store the uint type value in SQLite, but when read it from SQLite, get an overflow exception. |
@CwjXFH This should be reported to
await using var conn = new SqliteConnection("Data Source=test.db");
var entity = (await conn.QueryAsync<InfoEntity>("SELECT Id, Vol FROM InfoEntity WHERE ROWID=1")).Single();
Console.WriteLine(entity.Vol);
// using (var context = new SomeDbContext())
// {
// // context.Database.EnsureDeleted();
// // context.Database.EnsureCreated();
// //
// // context.Add(new InfoEntity { Vol = (uint)int.MaxValue + 1 });
// // context.SaveChanges();
// }
//
// using (var context = new SomeDbContext())
// {
// Console.WriteLine(context.Set<InfoEntity>().Single().Vol);
// }
public class InfoEntity
{
public int Id { get; set; }
public uint Vol { set; get; }
}
public class SomeDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlite("Data Source=test.db")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<InfoEntity>();
}
} |
I got it, thanks! The dapper team seems to have fixed this issue: DapperLib/Dapper#1795 |
I read some data from SQLite will throwing System.OverflowException when the column value is greater than
int.MaxValue
(e.g. 2950121986), column type in SQLite is INTEGER.I change the Vol type to ulong, which will be ok.
The text was updated successfully, but these errors were encountered: