System.Data.SQLite
Check-in [229927cfce]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add DetectStringType connection flag.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-3c00ec5b52
Files: files | file ages | folders
SHA1: 229927cfcebec0246fd554f50a78a755c9fb1b6a
User & Date: mistachkin 2014-05-27 05:56:06
Context
2014-05-27
18:35
Merge updates from trunk. Closed-Leaf check-in: b48e7cb883 user: mistachkin tags: tkt-3c00ec5b52
05:56
Add DetectStringType connection flag. check-in: 229927cfce user: mistachkin tags: tkt-3c00ec5b52
05:34
Merge updates from trunk. check-in: e7d0d8c183 user: mistachkin tags: tkt-3c00ec5b52
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Doc/Extra/Provider/version.html.

    44     44       <div id="mainBody">
    45     45       <h1 class="heading">Version History</h1>
    46     46       <p><b>1.0.93.0 - June XX, 2014 <font color="red">(release scheduled)</font></b></p>
    47     47       <ul>
    48     48         <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_4_3.html">SQLite 3.8.4.3</a>.</li>
    49     49         <li>Add support for mapping transaction isolation levels to their legacy default values. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/56b42d99c1">[56b42d99c1]</a>.</li>
    50     50         <li>Add support for setting the default DbType and type name used for mappings on a per-connection basis. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/3c00ec5b52">[3c00ec5b52]</a>.</li>
    51         -      <li>Add DetectTextAffinity connection flag to enable automatic detection of column affinities, when necessary. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/3c00ec5b52">[3c00ec5b52]</a>.</li>
           51  +      <li>Add DetectTextAffinity and DetectStringType connection flags to enable automatic detection of column types, when necessary. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/3c00ec5b52">[3c00ec5b52]</a>.</li>
    52     52         <li>Add SetChunkSize method to the SQLiteConnection class. Pursuant to [d1c008fa0a].</li>
    53     53         <li>Make the ISQLiteSchemaExtensions interface public.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    54     54         <li>Have the SQLiteProviderFactory class (in the System.Data.SQLite.Linq assembly) implement the IServiceProvider interface.</li>
    55     55         <li>Fix bug in documentation generator automation that prevented some internal documentation links from working.</li>
    56     56       </ul>
    57     57       <p><b>1.0.92.0 - March 19, 2014</p>
    58     58       <ul>

Changes to System.Data.SQLite/SQLiteBase.cs.

  1063   1063         /// Enable mapping of unsupported transaction isolation levels to the
  1064   1064         /// closest supported transaction isolation level.
  1065   1065         /// </summary>
  1066   1066         MapIsolationLevels = 0x1000000,
  1067   1067   
  1068   1068         /// <summary>
  1069   1069         /// When returning column values, attempt to detect the affinity of
  1070         -      /// textual values to see if they fully conform to those of the
         1070  +      /// textual values by checking if they fully conform to those of the
  1071   1071         /// <see cref="TypeAffinity.Null" />,
  1072   1072         /// <see cref="TypeAffinity.Int64" />,
  1073   1073         /// <see cref="TypeAffinity.Double" />,
  1074   1074         /// or <see cref="TypeAffinity.DateTime" /> types.
  1075   1075         /// </summary>
  1076   1076         DetectTextAffinity = 0x2000000,
  1077   1077   
         1078  +      /// <summary>
         1079  +      /// When returning column values, attempt to detect the type of
         1080  +      /// string values by checking if they fully conform to those of
         1081  +      /// the <see cref="TypeAffinity.Null" />,
         1082  +      /// <see cref="TypeAffinity.Int64" />,
         1083  +      /// <see cref="TypeAffinity.Double" />,
         1084  +      /// or <see cref="TypeAffinity.DateTime" /> types.
         1085  +      /// </summary>
         1086  +      DetectStringType = 0x4000000,
         1087  +
  1078   1088         /// <summary>
  1079   1089         /// When binding parameter values or returning column values, always
  1080   1090         /// treat them as though they were plain text (i.e. no numeric,
  1081   1091         /// date/time, or other conversions should be attempted).
  1082   1092         /// </summary>
  1083   1093         BindAndGetAllAsText = BindAllAsText | GetAllAsText,
  1084   1094   

Changes to System.Data.SQLite/SQLiteConvert.cs.

  1313   1313               new SQLiteDbTypeMapping("UNSIGNEDINTEGER64", DbType.UInt64, false),
  1314   1314               new SQLiteDbTypeMapping("VARBINARY", DbType.Binary, false),
  1315   1315               new SQLiteDbTypeMapping("VARCHAR", DbType.AnsiString, true),
  1316   1316               new SQLiteDbTypeMapping("VARCHAR2", DbType.AnsiString, false),
  1317   1317               new SQLiteDbTypeMapping("YESNO", DbType.Boolean, false)
  1318   1318           });
  1319   1319       }
         1320  +
         1321  +    /// <summary>
         1322  +    /// Determines if a database type is considered to be a string.
         1323  +    /// </summary>
         1324  +    /// <param name="type">
         1325  +    /// The database type to check.
         1326  +    /// </param>
         1327  +    /// <returns>
         1328  +    /// Non-zero if the database type is considered to be a string, zero
         1329  +    /// otherwise.
         1330  +    /// </returns>
         1331  +    internal static bool IsStringDbType(
         1332  +        DbType type
         1333  +        )
         1334  +    {
         1335  +        switch (type)
         1336  +        {
         1337  +            case DbType.AnsiString:
         1338  +            case DbType.String:
         1339  +            case DbType.AnsiStringFixedLength:
         1340  +            case DbType.StringFixedLength:
         1341  +                return true;
         1342  +            default:
         1343  +                return false;
         1344  +        }
         1345  +    }
  1320   1346   
  1321   1347       /// <summary>
  1322   1348       /// Determines the default <see cref="DbType" /> value to be used when a
  1323   1349       /// per-connection value is not available.
  1324   1350       /// </summary>
  1325   1351       /// <returns>
  1326   1352       /// The default <see cref="DbType" /> value to use.

Changes to System.Data.SQLite/SQLiteDataReader.cs.

   988    988             if (arSize.Length > 1)
   989    989             {
   990    990               dataType = arSize[0];
   991    991               arSize = arSize[1].Split(')');
   992    992               if (arSize.Length > 1)
   993    993               {
   994    994                 arSize = arSize[0].Split(',', '.');
   995         -              if (sqlType.Type == DbType.AnsiString || sqlType.Type == DbType.Binary ||
   996         -                  sqlType.Type == DbType.String || sqlType.Type == DbType.AnsiStringFixedLength ||
   997         -                  sqlType.Type == DbType.StringFixedLength)
          995  +              if (sqlType.Type == DbType.Binary || SQLiteConvert.IsStringDbType(sqlType.Type))
   998    996                 {
   999    997                   row[SchemaTableColumn.ColumnSize] = Convert.ToInt32(arSize[0], CultureInfo.InvariantCulture);
  1000    998                 }
  1001    999                 else
  1002   1000                 {
  1003   1001                   row[SchemaTableColumn.NumericPrecision] = Convert.ToInt32(arSize[0], CultureInfo.InvariantCulture);
  1004   1002                   if (arSize.Length > 1)
................................................................................
  1137   1135   
  1138   1136         SQLiteConnectionFlags flags = SQLiteCommand.GetFlags(_command);
  1139   1137         SQLiteType typ = GetSQLiteType(flags, i);
  1140   1138   
  1141   1139         if (((flags & SQLiteConnectionFlags.DetectTextAffinity) == SQLiteConnectionFlags.DetectTextAffinity) &&
  1142   1140             ((typ == null) || (typ.Affinity == TypeAffinity.Text)))
  1143   1141         {
         1142  +          typ = GetSQLiteType(
         1143  +              typ, _activeStatement._sql.GetText(_activeStatement, i));
         1144  +      }
         1145  +      else if (((flags & SQLiteConnectionFlags.DetectStringType) == SQLiteConnectionFlags.DetectStringType) &&
         1146  +          ((typ == null) || SQLiteConvert.IsStringDbType(typ.Type)))
         1147  +      {
  1144   1148             typ = GetSQLiteType(
  1145   1149                 typ, _activeStatement._sql.GetText(_activeStatement, i));
  1146   1150         }
  1147   1151   
  1148   1152         return _activeStatement._sql.GetValue(_activeStatement, flags, i, typ);
  1149   1153       }
  1150   1154   

Changes to readme.htm.

   211    211   <p>
   212    212       <b>1.0.93.0 - June XX, 2014 <font color="red">(release scheduled)</font></b>
   213    213   </p>
   214    214   <ul>
   215    215       <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_4_3.html">SQLite 3.8.4.3</a>.</li>
   216    216       <li>Add support for mapping transaction isolation levels to their legacy default values. Pursuant to [56b42d99c1].</li>
   217    217       <li>Add support for setting the default DbType and type name used for mappings on a per-connection basis. Pursuant to [3c00ec5b52].</li>
   218         -    <li>Add DetectTextAffinity connection flag to enable automatic detection of column affinities, when necessary. Pursuant to [3c00ec5b52].</li>
          218  +    <li>Add DetectTextAffinity and DetectStringType connection flags to enable automatic detection of column types, when necessary. Pursuant to [3c00ec5b52].</li>
   219    219       <li>Add SetChunkSize method to the SQLiteConnection class. Pursuant to [d1c008fa0a].</li>
   220    220       <li>Make the ISQLiteSchemaExtensions interface public.&nbsp;<b>** Potentially Incompatible Change **</b></li>
   221    221       <li>Have the SQLiteProviderFactory class (in the System.Data.SQLite.Linq assembly) implement the IServiceProvider interface.</li>
   222    222       <li>Fix bug in documentation generator automation that prevented some internal documentation links from working.</li>
   223    223   </ul>
   224    224   <p>
   225    225       <b>1.0.92.0 - March 19, 2014</b>

Changes to www/news.wiki.

     5      5   <p>
     6      6       <b>1.0.93.0 - June XX, 2014 <font color="red">(release scheduled)</font></b>
     7      7   </p>
     8      8   <ul>
     9      9       <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_4_3.html">SQLite 3.8.4.3</a>.</li>
    10     10       <li>Add support for mapping transaction isolation levels to their legacy default values. Pursuant to [56b42d99c1].</li>
    11     11       <li>Add support for setting the default DbType and type name used for mappings on a per-connection basis. Pursuant to [3c00ec5b52].</li>
    12         -    <li>Add DetectTextAffinity connection flag to enable automatic detection of column affinities, when necessary. Pursuant to [3c00ec5b52].</li>
           12  +    <li>Add DetectTextAffinity and DetectStringType connection flags to enable automatic detection of column types, when necessary. Pursuant to [3c00ec5b52].</li>
    13     13       <li>Add SetChunkSize method to the SQLiteConnection class. Pursuant to [d1c008fa0a].</li>
    14     14       <li>Make the ISQLiteSchemaExtensions interface public.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    15     15       <li>Have the SQLiteProviderFactory class (in the System.Data.SQLite.Linq assembly) implement the IServiceProvider interface.</li>
    16     16       <li>Fix bug in documentation generator automation that prevented some internal documentation links from working.</li>
    17     17   </ul>
    18     18   <p>
    19     19       <b>1.0.92.0 - March 19, 2014</b>