System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
2014-09-22
20:10 Closed ticket [c5cc2fb334]: Duplicate test for DbType.SByte in SQLiteDataReader.VerifyType() plus 4 other changes artifact: 8cc8e5440c user: mistachkin
20:09
In SQLiteDataReader.VerifyType method, remove duplicate 'if' statement for the DbType.SByte value and move the remaining 'if' to the Int64 affinity. Fix for [c5cc2fb334]. check-in: 24b429ba4d user: mistachkin tags: trunk
17:59 Ticket [c5cc2fb334] Duplicate test for DbType.SByte in SQLiteDataReader.VerifyType() status still Verified with 3 other changes artifact: 2e627696c2 user: mistachkin
17:56 Verified ticket [c5cc2fb334]. artifact: efac6f7c10 user: mistachkin
17:56 Ticket [c5cc2fb334]: 6 changes artifact: 123111f4d0 user: mistachkin
16:46 New ticket [c5cc2fb334]. artifact: ed7c953514 user: anonymous

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].