System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Overview

Artifact ID: ab1a6a4d63887cc4a7b553306e2c7dd59faa4416
Ticket: f60c439a6a3117a480bb460d76314a7cef3698a4
Integers being returned as Int32 instead of Int64 resulting in incorrect data
User & Date: anonymous 2020-03-19 09:35:40
Changes

  1. foundin changed to: "1.0.112"
  2. icomment:
    Integers are being returned from queries as 32 bit integers even through the value is too big.  I am not sure if you intend for the integers to be returned as Int32 or Int64.  I expected them all to be returned as Int64, but I cast them Int32 to get the first 3 Asserts to pass.  The 4th Asserts fails and does not have the correct value.
    
    
    
            [TestMethod]
            public void Int_Sqlite()
            {
                SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
                builder.DataSource = ":memory:";
                builder.FailIfMissing = false;
                builder.JournalMode = SQLiteJournalModeEnum.Memory;
                builder.SyncMode = SynchronizationModes.Off;
    
                byte testValue8 = byte.MaxValue;
                short testValue16 = short.MaxValue;
                int testValue32 = int.MaxValue;
                long testValue64 = long.MaxValue;
    
    
                using (SQLiteConnection connection = new SQLiteConnection(builder.ConnectionString))
                {
                    connection.Open();
    
                    using (SQLiteTransaction transaction = connection.BeginTransaction())
                    {
                        using (SQLiteCommand command = connection.CreateCommand())
                        {
                            command.CommandText = "CREATE TABLE TestValues (Value8 INT NOT NULL, Value16 INT NOT NULL, Value32 INT NOT NULL, Value64 INT NOT NULL)";
                            command.Transaction = transaction;
    
                            command.ExecuteNonQuery();
                        }
    
                        transaction.Commit();
                    }
    
                    using (SQLiteTransaction transaction = connection.BeginTransaction())
                    {
                        using (SQLiteCommand command = connection.CreateCommand())
                        {
                            command.CommandText = "INSERT INTO TestValues (Value8, Value16, Value32, Value64) VALUES (@Value8, @Value16, @Value32, @Value64)";
                            command.Transaction = transaction;
    
                            command.Parameters.AddWithValue("@Value8", testValue8);
                            command.Parameters.AddWithValue("@Value16", testValue16);
                            command.Parameters.AddWithValue("@Value32", testValue32);
                            command.Parameters.AddWithValue("@Value64", testValue64);
    
                            command.ExecuteNonQuery();
                        }
                        transaction.Commit();
                    }
    
    
                    using (SQLiteTransaction transaction = connection.BeginTransaction())
                    {
                        using (SQLiteCommand command = connection.CreateCommand())
                        {
                            command.CommandText = "SELECT * from TestValues";
                            command.Transaction = transaction;
    
             
                            using (SQLiteDataReader reader = command.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    Assert.AreEqual((int)testValue8, reader[0]);
                                    Assert.AreEqual((int)testValue16, reader[1]);
                                    Assert.AreEqual((int)testValue32, reader[2]);
                                    Assert.AreEqual((long)testValue64, reader[3]);
                                }
                            }
                        }
                        transaction.Commit();
                    }
                }
            }
    
  3. login: "anonymous"
  4. mimetype: "text/plain"
  5. private_contact changed to: "66326f94cdccdf9c5e246ecc963e50c1a3e2b6b0"
  6. severity changed to: "Important"
  7. status changed to: "Open"
  8. title changed to:
    Integers being returned as Int32 instead of Int64 resulting in incorrect data
    
  9. type changed to: "Code_Defect"