|
| 1 | +using System.Numerics; |
1 | 2 | #if BASELINE
|
2 | 3 | using MySql.Data.Types;
|
3 | 4 | #endif
|
@@ -387,6 +388,52 @@ public void InsertStringBuilder(bool prepare)
|
387 | 388 | Assert.Equal(expected, reader.GetValue(0));
|
388 | 389 | }
|
389 | 390 |
|
| 391 | + [Theory] |
| 392 | + [InlineData(false)] |
| 393 | + [InlineData(true)] |
| 394 | + public void InsertBigInteger(bool prepare) |
| 395 | + { |
| 396 | + using var connection = new MySqlConnection(AppConfig.ConnectionString); |
| 397 | + connection.Open(); |
| 398 | + connection.Execute(@"drop table if exists insert_big_integer; |
| 399 | +create table insert_big_integer(rowid integer not null primary key auto_increment, value bigint);"); |
| 400 | + |
| 401 | + var value = 1_000_000_000_000_000L; |
| 402 | + using var cmd = connection.CreateCommand(); |
| 403 | + cmd.CommandText = @"insert into insert_big_integer(value) values(@value);"; |
| 404 | + cmd.Parameters.AddWithValue("@value", new BigInteger(value)); |
| 405 | + if (prepare) |
| 406 | + cmd.Prepare(); |
| 407 | + cmd.ExecuteNonQuery(); |
| 408 | + |
| 409 | + using var reader = connection.ExecuteReader(@"select value from insert_big_integer order by rowid;"); |
| 410 | + Assert.True(reader.Read()); |
| 411 | + Assert.Equal(value, reader.GetValue(0)); |
| 412 | + } |
| 413 | + |
| 414 | + [Theory] |
| 415 | + [InlineData(false)] |
| 416 | + [InlineData(true)] |
| 417 | + public void InsertBigIntegerAsDecimal(bool prepare) |
| 418 | + { |
| 419 | + using var connection = new MySqlConnection(AppConfig.ConnectionString); |
| 420 | + connection.Open(); |
| 421 | + connection.Execute(@"drop table if exists insert_big_integer; |
| 422 | +create table insert_big_integer(rowid integer not null primary key auto_increment, value decimal(40, 2));"); |
| 423 | + |
| 424 | + var value = long.MaxValue * 1000m; |
| 425 | + using var cmd = connection.CreateCommand(); |
| 426 | + cmd.CommandText = @"insert into insert_big_integer(value) values(@value);"; |
| 427 | + cmd.Parameters.AddWithValue("@value", new BigInteger(value)); |
| 428 | + if (prepare) |
| 429 | + cmd.Prepare(); |
| 430 | + cmd.ExecuteNonQuery(); |
| 431 | + |
| 432 | + using var reader = connection.ExecuteReader(@"select value from insert_big_integer order by rowid;"); |
| 433 | + Assert.True(reader.Read()); |
| 434 | + Assert.Equal(value, reader.GetValue(0)); |
| 435 | + } |
| 436 | + |
390 | 437 | [Fact]
|
391 | 438 | public void InsertOldGuid()
|
392 | 439 | {
|
|
0 commit comments