System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: c5cc2fb334c9a9c920d156d8ae16d825b1ea32b7
Title: Duplicate test for DbType.SByte in SQLiteDataReader.VerifyType()
Status: Closed Type: Code_Defect
Severity: Minor Priority: Medium
Subsystem: Data_Reader Resolution: Fixed
Last Modified: 2014-09-22 20:10:04
Version Found In: trunk
User Comments:
anonymous added on 2014-09-22 16:46:43:
In SQLiteDataReader.VerifyType(int i, DbType typ) DbType.SByte is tested for twice for TypeAffinity.Text:

...
        case TypeAffinity.Text:
-->       if (typ == DbType.SByte) return affinity;
          if (typ == DbType.String) return affinity;
-->       if (typ == DbType.SByte) return affinity;
          if (typ == DbType.Guid) return affinity;
          if (typ == DbType.DateTime) return affinity;
          if (typ == DbType.Decimal) return affinity;
          break;
...

Given that the combination of TypeAffinity.Text and DbType.String is more likely than TypeAffinity.Text and DbType.SByte, I would suggest removing the first test for DbType.SByte. In fact I would probably reorder the tests like this:

        case TypeAffinity.Text:
          if (typ == DbType.String) return affinity;
          if (typ == DbType.DateTime) return affinity;
          if (typ == DbType.Decimal) return affinity;
          if (typ == DbType.Guid) return affinity;
          if (typ == DbType.SByte) return affinity;
          break;

Maybe the other case statements could be optimized too...

mistachkin added on 2014-09-22 17:56:26:
Note: This duplicate check has existed since the file was originally added, here:
[0cd344ea4924e4aabe9ee63cd85450c98c0f6ae7].

mistachkin added on 2014-09-22 17:59:06:
Also, I'm starting to think that the SByte case should be part of the Int64
affinity.  There is a small risk of breaking compatibility; however, I think
the risk is quite small (i.e. it should be limited to columns that are
explicitly declared with SQL data types that mapped to SByte).

mistachkin added on 2014-09-22 20:10:04:
Fixed on trunk via check-in [24b429ba4d].