System.Data.SQLite
Check-in [9c5dda4992]
Not logged in

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

Overview
Comment:Work in progress for feature request [3c00ec5b52].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-3c00ec5b52
Files: files | file ages | folders
SHA1: 9c5dda49922c1c2f4392e48112713559ae40d971
User & Date: mistachkin 2014-05-14 18:45:18
References
2014-05-14
18:54 Ticket [3c00ec5b52] Columns without defined type are not identified as text status still Pending with 3 other changes artifact: 5c4d0a5405 user: mistachkin
Context
2014-05-14
20:13
Add tests and update version history docs. Closed-Leaf check-in: c09a345694 user: mistachkin tags: tkt-3c00ec5b52
18:45
Work in progress for feature request [3c00ec5b52]. check-in: 9c5dda4992 user: mistachkin tags: tkt-3c00ec5b52
2014-05-12
22:23
Update the Visual C++ 2013 redistributable packages in externals to Visual Studio 2013 Update 2. check-in: cdce870cee user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

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

469
470
471
472
473
474
475














476
477
478
479
480
481
482
...
612
613
614
615
616
617
618


619
620
621
622
623
624
625
....
2254
2255
2256
2257
2258
2259
2260




2261
2262
2263
2264
2265
2266
2267
....
2561
2562
2563
2564
2565
2566
2567






















2568
2569
2570
2571
2572
2573
2574
    /// <summary>
    /// The extra behavioral flags for this connection, if any.  See the
    /// <see cref="SQLiteConnectionFlags" /> enumeration for a list of
    /// possible values.
    /// </summary>
    private SQLiteConnectionFlags _flags;















    /// <summary>
    /// Default command timeout
    /// </summary>
    private int _defaultTimeout = 30;

    /// <summary>
    /// Non-zero if the built-in (i.e. framework provided) connection string
................................................................................
              SQLiteErrorCode.Ok, SQLiteConvert.ToUTF8("logging initialized."));
      }
#endif

      _typeNames = new SQLiteDbTypeMap();
      _parseViaFramework = parseViaFramework;
      _flags = SQLiteConnectionFlags.Default;


      _connectionState = ConnectionState.Closed;
      _connectionString = null;

      if (connectionString != null)
        ConnectionString = connectionString;
    }

................................................................................
          null, _connectionString, new object[] { opts }));

      object enumValue;

      enumValue = TryParseEnum(typeof(SQLiteConnectionFlags), FindKey(opts, "Flags", DefaultFlags.ToString()), true);
      _flags = (enumValue is SQLiteConnectionFlags) ? (SQLiteConnectionFlags)enumValue : DefaultFlags;





#if !NET_COMPACT_20 && TRACE_WARNING
      bool uri = false;
#endif
      bool fullUri = false;
      string fileName;

      if (Convert.ToInt32(FindKey(opts, "Version", DefaultVersion.ToString()), CultureInfo.InvariantCulture) != DefaultVersion)
................................................................................
    /// possible values.
    /// </summary>
    public SQLiteConnectionFlags Flags
    {
      get { CheckDisposed(); return _flags; }
      set { CheckDisposed(); _flags = value; }
    }























    /// <summary>
    /// Returns non-zero if the underlying native connection handle is
    /// owned by this instance.
    /// </summary>
    public bool OwnHandle
    {







>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>







 







>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
...
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
....
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
....
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
    /// <summary>
    /// The extra behavioral flags for this connection, if any.  See the
    /// <see cref="SQLiteConnectionFlags" /> enumeration for a list of
    /// possible values.
    /// </summary>
    private SQLiteConnectionFlags _flags;

    /// <summary>
    /// The default databse type for this connection.  This value will only
    /// be used if the <see cref="SQLiteConnectionFlags.UseConnectionTypes" />
    /// flag is set.
    /// </summary>
    private DbType _defaultDbType;

    /// <summary>
    /// The default databse type name for this connection.  This value will only
    /// be used if the <see cref="SQLiteConnectionFlags.UseConnectionTypes" />
    /// flag is set.
    /// </summary>
    private string _defaultTypeName;

    /// <summary>
    /// Default command timeout
    /// </summary>
    private int _defaultTimeout = 30;

    /// <summary>
    /// Non-zero if the built-in (i.e. framework provided) connection string
................................................................................
              SQLiteErrorCode.Ok, SQLiteConvert.ToUTF8("logging initialized."));
      }
#endif

      _typeNames = new SQLiteDbTypeMap();
      _parseViaFramework = parseViaFramework;
      _flags = SQLiteConnectionFlags.Default;
      _defaultDbType = SQLiteConvert.FallbackDefaultDbType;
      _defaultTypeName = SQLiteConvert.FallbackDefaultTypeName;
      _connectionState = ConnectionState.Closed;
      _connectionString = null;

      if (connectionString != null)
        ConnectionString = connectionString;
    }

................................................................................
          null, _connectionString, new object[] { opts }));

      object enumValue;

      enumValue = TryParseEnum(typeof(SQLiteConnectionFlags), FindKey(opts, "Flags", DefaultFlags.ToString()), true);
      _flags = (enumValue is SQLiteConnectionFlags) ? (SQLiteConnectionFlags)enumValue : DefaultFlags;

      enumValue = TryParseEnum(typeof(DbType), FindKey(opts, "DefaultDbType", SQLiteConvert.FallbackDefaultDbType.ToString()), true);
      _defaultDbType = (enumValue is DbType) ? (DbType)enumValue : SQLiteConvert.FallbackDefaultDbType;
      _defaultTypeName = FindKey(opts, "DefaultTypeName", SQLiteConvert.FallbackDefaultTypeName);

#if !NET_COMPACT_20 && TRACE_WARNING
      bool uri = false;
#endif
      bool fullUri = false;
      string fileName;

      if (Convert.ToInt32(FindKey(opts, "Version", DefaultVersion.ToString()), CultureInfo.InvariantCulture) != DefaultVersion)
................................................................................
    /// possible values.
    /// </summary>
    public SQLiteConnectionFlags Flags
    {
      get { CheckDisposed(); return _flags; }
      set { CheckDisposed(); _flags = value; }
    }

    /// <summary>
    /// Gets/sets the default database type for this connection.  This value
    /// will only be used if the <see cref="SQLiteConnectionFlags.UseConnectionTypes" />
    /// flag is set.
    /// </summary>
    public DbType DefaultDbType
    {
      get { CheckDisposed(); return _defaultDbType; }
      set { CheckDisposed(); _defaultDbType = value; }
    }

    /// <summary>
    /// Gets/sets the default database type name for this connection.  This value
    /// will only be used if the <see cref="SQLiteConnectionFlags.UseConnectionTypes" />
    /// flag is set.
    /// </summary>
    public string DefaultTypeName
    {
      get { CheckDisposed(); return _defaultTypeName; }
      set { CheckDisposed(); _defaultTypeName = value; }
    }

    /// <summary>
    /// Returns non-zero if the underlying native connection handle is
    /// owned by this instance.
    /// </summary>
    public bool OwnHandle
    {

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

19
20
21
22
23
24
25












26
27
28
29
30
31
32
...
993
994
995
996
997
998
999


1000
1001
1002
1003
1004
1005
1006
....
1008
1009
1010
1011
1012
1013
1014





1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
....
1218
1219
1220
1221
1222
1223
1224


1225
1226
1227
1228
1229
1230
1231
....
1248
1249
1250
1251
1252
1253
1254





1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
  using System.Text;

  /// <summary>
  /// This base class provides datatype conversion services for the SQLite provider.
  /// </summary>
  public abstract class SQLiteConvert
  {












    /// <summary>
    /// The value for the Unix epoch (e.g. January 1, 1970 at midnight, in UTC).
    /// </summary>
    protected static readonly DateTime UnixEpoch =
        new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

    /// <summary>
................................................................................
    /// <returns>The type name or an empty string if it cannot be determined.</returns>
    internal static string DbTypeToTypeName(
        SQLiteConnection connection,
        DbType dbType,
        SQLiteConnectionFlags flags
        )
    {


        if (connection != null)
        {
            flags |= connection.Flags;

            if ((flags & SQLiteConnectionFlags.UseConnectionTypes) == SQLiteConnectionFlags.UseConnectionTypes)
            {
                SQLiteDbTypeMap connectionTypeNames = connection._typeNames;
................................................................................
                if (connectionTypeNames != null)
                {
                    SQLiteDbTypeMapping value;

                    if (connectionTypeNames.TryGetValue(dbType, out value))
                        return value.typeName;
                }





            }
        }

        string defaultTypeName = String.Empty;

        if ((flags & SQLiteConnectionFlags.NoGlobalTypes) == SQLiteConnectionFlags.NoGlobalTypes)
            return defaultTypeName;

        lock (_syncRoot)
        {
            if (_typeNames == null)
                _typeNames = GetSQLiteDbTypeMap();
................................................................................
    /// <returns>The .NET DBType the text evaluates to.</returns>
    internal static DbType TypeNameToDbType(
        SQLiteConnection connection,
        string name,
        SQLiteConnectionFlags flags
        )
    {


        if (connection != null)
        {
            flags |= connection.Flags;

            if ((flags & SQLiteConnectionFlags.UseConnectionTypes) == SQLiteConnectionFlags.UseConnectionTypes)
            {
                SQLiteDbTypeMap connectionTypeNames = connection._typeNames;
................................................................................
                                connectionTypeNames.TryGetValue(name.Substring(0, index).TrimEnd(), out value))
                            {
                                return value.dataType;
                            }
                        }
                    }
                }





            }
        }

        DbType defaultDbType = DbType.Object;

        if ((flags & SQLiteConnectionFlags.NoGlobalTypes) == SQLiteConnectionFlags.NoGlobalTypes)
            return defaultDbType;

        lock (_syncRoot)
        {
            if (_typeNames == null)
                _typeNames = GetSQLiteDbTypeMap();







>
>
>
>
>
>
>
>
>
>
>
>







 







>
>







 







>
>
>
>
>



<
<







 







>
>







 







>
>
>
>
>



<
<







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
....
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
....
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036


1037
1038
1039
1040
1041
1042
1043
....
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
....
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281


1282
1283
1284
1285
1286
1287
1288
  using System.Text;

  /// <summary>
  /// This base class provides datatype conversion services for the SQLite provider.
  /// </summary>
  public abstract class SQLiteConvert
  {
    /// <summary>
    /// The fallback default database type when one cannot be obtained from an
    /// existing connection instance.
    /// </summary>
    internal static readonly DbType FallbackDefaultDbType = DbType.Object;

    /// <summary>
    /// The fallback default database type name when one cannot be obtained from
    /// an existing connection instance.
    /// </summary>
    internal static readonly string FallbackDefaultTypeName = String.Empty;

    /// <summary>
    /// The value for the Unix epoch (e.g. January 1, 1970 at midnight, in UTC).
    /// </summary>
    protected static readonly DateTime UnixEpoch =
        new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

    /// <summary>
................................................................................
    /// <returns>The type name or an empty string if it cannot be determined.</returns>
    internal static string DbTypeToTypeName(
        SQLiteConnection connection,
        DbType dbType,
        SQLiteConnectionFlags flags
        )
    {
        string defaultTypeName = FallbackDefaultTypeName;

        if (connection != null)
        {
            flags |= connection.Flags;

            if ((flags & SQLiteConnectionFlags.UseConnectionTypes) == SQLiteConnectionFlags.UseConnectionTypes)
            {
                SQLiteDbTypeMap connectionTypeNames = connection._typeNames;
................................................................................
                if (connectionTypeNames != null)
                {
                    SQLiteDbTypeMapping value;

                    if (connectionTypeNames.TryGetValue(dbType, out value))
                        return value.typeName;
                }

                //
                // NOTE: Use the default database type name for the connection.
                //
                defaultTypeName = connection.DefaultTypeName;
            }
        }



        if ((flags & SQLiteConnectionFlags.NoGlobalTypes) == SQLiteConnectionFlags.NoGlobalTypes)
            return defaultTypeName;

        lock (_syncRoot)
        {
            if (_typeNames == null)
                _typeNames = GetSQLiteDbTypeMap();
................................................................................
    /// <returns>The .NET DBType the text evaluates to.</returns>
    internal static DbType TypeNameToDbType(
        SQLiteConnection connection,
        string name,
        SQLiteConnectionFlags flags
        )
    {
        DbType defaultDbType = FallbackDefaultDbType;

        if (connection != null)
        {
            flags |= connection.Flags;

            if ((flags & SQLiteConnectionFlags.UseConnectionTypes) == SQLiteConnectionFlags.UseConnectionTypes)
            {
                SQLiteDbTypeMap connectionTypeNames = connection._typeNames;
................................................................................
                                connectionTypeNames.TryGetValue(name.Substring(0, index).TrimEnd(), out value))
                            {
                                return value.dataType;
                            }
                        }
                    }
                }

                //
                // NOTE: Use the default database type for the connection.
                //
                defaultDbType = connection.DefaultDbType;
            }
        }



        if ((flags & SQLiteConnectionFlags.NoGlobalTypes) == SQLiteConnectionFlags.NoGlobalTypes)
            return defaultDbType;

        lock (_syncRoot)
        {
            if (_typeNames == null)
                _typeNames = GetSQLiteDbTypeMap();