Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add support for per-connection mappings between type names and DbType values. Pursuant to [e87af1d06a]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d84ccf015e852c831ef64dc9966f2b69 |
User & Date: | mistachkin 2014-02-01 00:51:38.111 |
References
2014-02-01
| ||
00:57 | • Pending ticket [e87af1d06a]: New internal mappings break some behaviour plus 5 other changes artifact: 0531f4c734 user: mistachkin | |
Context
2014-02-01
| ||
01:01 | Modify the connection string property handling to be more robust in the face of missing space characters. check-in: f0dfd8c10f user: mistachkin tags: trunk | |
00:51 | Add support for per-connection mappings between type names and DbType values. Pursuant to [e87af1d06a]. check-in: d84ccf015e user: mistachkin tags: trunk | |
2014-01-31
| ||
00:48 | Correction to expected result for the test for ticket [72905c9a77]. check-in: 9854404773 user: mistachkin tags: trunk | |
Changes
Changes to Doc/Extra/version.html.
︙ | ︙ | |||
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | <div id="mainSection"> <div id="mainBody"> <h1 class="heading">Version History</h1> <p><b>1.0.91.0 - February XX, 2014 <font color="red">(release scheduled)</font></b></p> <ul> <li>Updated to <a href="http://www.sqlite.org/src/info/trunk">SQLite 3.8.3</a>.</li> <li>Add support for <a href="http://entityframework.codeplex.com/">Entity Framework 6</a>.</li> <li>Modify the namespace used for all internal classes in the System.Data.SQLite.Linq assembly. <b>** Potentially Incompatible Change **</b></li> <li>Add SQLiteCompileOptions and InteropCompileOptions properties to the SQLiteConnection class to return the compile-time options for the SQLite core library and interop assembly, respectively.</li> <li>Add BindInvariantText and ConvertInvariantText connection flags to force the invariant culture to be used when converting parameter values to/from strings.</li> <li>Add NoConnectionPool and UseConnectionPool connection flags to disable or enable connection pooling by default.</li> <li>Modify handling of the design-time components installer to run Visual Studio <b>devenv.exe /setup</b> after installing the package. This appears to be necessary in some circumstances for Visual Studio 2013. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/a47eff2c71">[a47eff2c71]</a>.</li> <li>Modify the native library pre-loader to support reading settings from an XML configuration file and to be capable of checking more than one directory. Persuant to <a href="http://system.data.sqlite.org/index.html/info/f0246d1817">[f0246d1817]</a>.</li> <li>Change the default behavior for the native library pre-loader so it first searches the executing (i.e. System.Data.SQLite) assembly directory and then the application domain directory. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/f0246d1817">[f0246d1817]</a>. <b>** Potentially Incompatible Change **</b></li> | > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | <div id="mainSection"> <div id="mainBody"> <h1 class="heading">Version History</h1> <p><b>1.0.91.0 - February XX, 2014 <font color="red">(release scheduled)</font></b></p> <ul> <li>Updated to <a href="http://www.sqlite.org/src/info/trunk">SQLite 3.8.3</a>.</li> <li>Add support for <a href="http://entityframework.codeplex.com/">Entity Framework 6</a>.</li> <li>Add support for per-connection mappings between type names and DbType values. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/e87af1d06a">[e87af1d06a]</a>.</li> <li>Modify the namespace used for all internal classes in the System.Data.SQLite.Linq assembly. <b>** Potentially Incompatible Change **</b></li> <li>Add SQLiteCompileOptions and InteropCompileOptions properties to the SQLiteConnection class to return the compile-time options for the SQLite core library and interop assembly, respectively.</li> <li>Add BindInvariantText and ConvertInvariantText connection flags to force the invariant culture to be used when converting parameter values to/from strings.</li> <li>Add NoConnectionPool and UseConnectionPool connection flags to disable or enable connection pooling by default.</li> <li>Modify handling of the design-time components installer to run Visual Studio <b>devenv.exe /setup</b> after installing the package. This appears to be necessary in some circumstances for Visual Studio 2013. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/a47eff2c71">[a47eff2c71]</a>.</li> <li>Modify the native library pre-loader to support reading settings from an XML configuration file and to be capable of checking more than one directory. Persuant to <a href="http://system.data.sqlite.org/index.html/info/f0246d1817">[f0246d1817]</a>.</li> <li>Change the default behavior for the native library pre-loader so it first searches the executing (i.e. System.Data.SQLite) assembly directory and then the application domain directory. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/f0246d1817">[f0246d1817]</a>. <b>** Potentially Incompatible Change **</b></li> |
︙ | ︙ |
Changes to System.Data.SQLite.Linq/SQLiteProviderServices.cs.
︙ | ︙ | |||
376 377 378 379 380 381 382 | { sql.AppendFormat(CultureInfo.InvariantCulture, "CREATE TEMP TABLE {0} (", builder.QuoteIdentifier(dest)); string separator = String.Empty; SQLiteConnectionFlags flags = cnn.Flags; foreach (DataColumn dc in table.Columns) { DbType dbtypeName = SQLiteConvert.TypeToDbType(dc.DataType); | | | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | { sql.AppendFormat(CultureInfo.InvariantCulture, "CREATE TEMP TABLE {0} (", builder.QuoteIdentifier(dest)); string separator = String.Empty; SQLiteConnectionFlags flags = cnn.Flags; foreach (DataColumn dc in table.Columns) { DbType dbtypeName = SQLiteConvert.TypeToDbType(dc.DataType); string typeName = SQLiteConvert.DbTypeToTypeName(cnn, dbtypeName, flags); sql.AppendFormat(CultureInfo.InvariantCulture, "{2}{0} {1} COLLATE NOCASE", builder.QuoteIdentifier(dc.ColumnName), typeName, separator); separator = ", "; } sql.Append(")"); cmd.CommandText = sql.ToString(); |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteBase.cs.
︙ | ︙ | |||
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | /// connection string property is specified, its value will override /// this flag. The precise outcome of combining this flag with the /// <see cref="NoConnectionPool" /> flag is unspecified; however, /// one of the flags will be in effect. /// </summary> UseConnectionPool = 0x80000, /// <summary> /// When binding parameter values or returning column values, always /// treat them as though they were plain text (i.e. no numeric, /// date/time, or other conversions should be attempted). /// </summary> BindAndGetAllAsText = BindAllAsText | GetAllAsText, | > > > > > > > > > > > > > > > > > > > > > | 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 | /// connection string property is specified, its value will override /// this flag. The precise outcome of combining this flag with the /// <see cref="NoConnectionPool" /> flag is unspecified; however, /// one of the flags will be in effect. /// </summary> UseConnectionPool = 0x80000, /// <summary> /// Enable using per-connection mappings between type names and /// <see cref="DbType" /> values. Also see the /// <see cref="SQLiteConnection.ClearTypeMappings" />, /// <see cref="SQLiteConnection.GetTypeMappings" />, and /// <see cref="SQLiteConnection.AddTypeMapping" /> methods. These /// per-connection mappings, when present, override the corresponding /// global mappings. /// </summary> UseConnectionTypes = 0x100000, /// <summary> /// Disable using global mappings between type names and /// <see cref="DbType" /> values. This may be useful in some very narrow /// cases; however, if there are no per-connection type mappings, the /// fallback defaults will be used for both type names and their /// associated <see cref="DbType" /> values. Therefore, use of this flag /// is not recommended. /// </summary> NoGlobalTypes = 0x200000, /// <summary> /// When binding parameter values or returning column values, always /// treat them as though they were plain text (i.e. no numeric, /// date/time, or other conversions should be attempted). /// </summary> BindAndGetAllAsText = BindAllAsText | GetAllAsText, |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
430 431 432 433 434 435 436 437 438 439 440 441 442 443 | #if !PLATFORM_COMPACTFRAMEWORK /// <summary> /// Whether or not the connection is enlisted in a distrubuted transaction /// </summary> internal SQLiteEnlistment _enlistment; #endif /// <summary> /// The base SQLite object to interop with /// </summary> internal SQLiteBase _sql; /// <summary> /// The database filename minus path and extension /// </summary> | > > > > > > | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | #if !PLATFORM_COMPACTFRAMEWORK /// <summary> /// Whether or not the connection is enlisted in a distrubuted transaction /// </summary> internal SQLiteEnlistment _enlistment; #endif /// <summary> /// The per-connection mappings between type names and <see cref="DbType" /> /// values. These mappings override the corresponding global mappings. /// </summary> internal SQLiteDbTypeMap _typeNames; /// <summary> /// The base SQLite object to interop with /// </summary> internal SQLiteBase _sql; /// <summary> /// The database filename minus path and extension /// </summary> |
︙ | ︙ | |||
599 600 601 602 603 604 605 606 607 608 609 610 611 612 | if (UnsafeNativeMethods.sqlite3_config_log_interop() == SQLiteErrorCode.Ok) { UnsafeNativeMethods.sqlite3_log( SQLiteErrorCode.Ok, SQLiteConvert.ToUTF8("logging initialized.")); } #endif _parseViaFramework = parseViaFramework; _flags = SQLiteConnectionFlags.Default; _connectionState = ConnectionState.Closed; _connectionString = null; if (connectionString != null) ConnectionString = connectionString; | > | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | if (UnsafeNativeMethods.sqlite3_config_log_interop() == SQLiteErrorCode.Ok) { UnsafeNativeMethods.sqlite3_log( 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; |
︙ | ︙ | |||
878 879 880 881 882 883 884 885 886 887 888 889 890 891 | finally { if (backup != null) sqliteBase.FinishBackup(backup); /* throw */ } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Attempts to bind the specified <see cref="SQLiteFunction" /> object /// instance to this connection. /// </summary> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 | finally { if (backup != null) sqliteBase.FinishBackup(backup); /* throw */ } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region Per-Connection Type Mappings /// <summary> /// Clears the per-connection type mappings. /// </summary> /// <returns> /// The total number of per-connection type mappings cleared. /// </returns> public int ClearTypeMappings() { CheckDisposed(); int result = -1; /* NO MAPPINGS */ if (_typeNames != null) result = _typeNames.Clear(); return result; } /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Returns the per-connection type mappings. /// </summary> /// <returns> /// The per-connection type mappings -OR- null if they are unavailable. /// </returns> public Dictionary<string, object> GetTypeMappings() { CheckDisposed(); Dictionary<string, object> result = null; if (_typeNames != null) { result = new Dictionary<string, object>(_typeNames.Count, _typeNames.Comparer); foreach (KeyValuePair<string, SQLiteDbTypeMapping> pair in _typeNames) { SQLiteDbTypeMapping mapping = pair.Value; object typeName = null; /* System.String */ object dataType = null; /* System.Data.DbType */ object primary = null; /* System.Boolean */ if (mapping != null) { typeName = mapping.typeName; dataType = mapping.dataType; primary = mapping.primary; } result.Add(pair.Key, new object[] { typeName, dataType, primary }); } } return result; } /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Adds a per-connection type mapping, possibly replacing one or more /// that already exist. /// </summary> /// <param name="typeName"> /// The case-insensitive database type name (e.g. "MYDATE"). The value /// of this parameter cannot be null. Using an empty string value (or /// a string value consisting entirely of whitespace) for this parameter /// is not recommended. /// </param> /// <param name="dataType"> /// The <see cref="DbType" /> value that should be associated with the /// specified type name. /// </param> /// <param name="primary"> /// Non-zero if this mapping should be considered to be the primary one /// for the specified <see cref="DbType" />. /// </param> /// <returns> /// A negative value if nothing was done. Zero if no per-connection type /// mappings were replaced (i.e. it was a pure add operation). More than /// zero if some per-connection type mappings were replaced. /// </returns> public int AddTypeMapping( string typeName, DbType dataType, bool primary ) { CheckDisposed(); if (typeName == null) throw new ArgumentNullException("typeName"); int result = -1; /* NO MAPPINGS */ if (_typeNames != null) { result = 0; if (primary && _typeNames.ContainsKey(dataType)) result += _typeNames.Remove(dataType) ? 1 : 0; if (_typeNames.ContainsKey(typeName)) result += _typeNames.Remove(typeName) ? 1 : 0; _typeNames.Add(new SQLiteDbTypeMapping(typeName, dataType, primary)); } return result; } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Attempts to bind the specified <see cref="SQLiteFunction" /> object /// instance to this connection. /// </summary> |
︙ | ︙ | |||
3357 3358 3359 3360 3361 3362 3363 | row["COLUMN_NAME"] = schemaRow[SchemaTableColumn.ColumnName]; row["TABLE_CATALOG"] = strCatalog; row["ORDINAL_POSITION"] = schemaRow[SchemaTableColumn.ColumnOrdinal]; row["COLUMN_HASDEFAULT"] = (schemaRow[SchemaTableOptionalColumn.DefaultValue] != DBNull.Value); row["COLUMN_DEFAULT"] = schemaRow[SchemaTableOptionalColumn.DefaultValue]; row["IS_NULLABLE"] = schemaRow[SchemaTableColumn.AllowDBNull]; row["DATA_TYPE"] = schemaRow["DataTypeName"].ToString().ToLower(CultureInfo.InvariantCulture); | | | 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 | row["COLUMN_NAME"] = schemaRow[SchemaTableColumn.ColumnName]; row["TABLE_CATALOG"] = strCatalog; row["ORDINAL_POSITION"] = schemaRow[SchemaTableColumn.ColumnOrdinal]; row["COLUMN_HASDEFAULT"] = (schemaRow[SchemaTableOptionalColumn.DefaultValue] != DBNull.Value); row["COLUMN_DEFAULT"] = schemaRow[SchemaTableOptionalColumn.DefaultValue]; row["IS_NULLABLE"] = schemaRow[SchemaTableColumn.AllowDBNull]; row["DATA_TYPE"] = schemaRow["DataTypeName"].ToString().ToLower(CultureInfo.InvariantCulture); row["EDM_TYPE"] = SQLiteConvert.DbTypeToTypeName(this, (DbType)schemaRow[SchemaTableColumn.ProviderType], _flags).ToString().ToLower(CultureInfo.InvariantCulture); row["CHARACTER_MAXIMUM_LENGTH"] = schemaRow[SchemaTableColumn.ColumnSize]; row["TABLE_SCHEMA"] = schemaRow[SchemaTableColumn.BaseSchemaName]; row["PRIMARY_KEY"] = schemaRow[SchemaTableColumn.IsKey]; row["AUTOINCREMENT"] = schemaRow[SchemaTableOptionalColumn.IsAutoIncrement]; row["COLLATION_NAME"] = schemaRow["CollationType"]; row["UNIQUE"] = schemaRow[SchemaTableColumn.IsUnique]; tbl.Rows.Add(row); |
︙ | ︙ | |||
4048 4049 4050 4051 4052 4053 4054 | row["COLUMN_NAME"] = schemaRow[SchemaTableColumn.BaseColumnName]; row["VIEW_COLUMN_NAME"] = viewRow[SchemaTableColumn.ColumnName]; row["COLUMN_HASDEFAULT"] = (viewRow[SchemaTableOptionalColumn.DefaultValue] != DBNull.Value); row["COLUMN_DEFAULT"] = viewRow[SchemaTableOptionalColumn.DefaultValue]; row["ORDINAL_POSITION"] = viewRow[SchemaTableColumn.ColumnOrdinal]; row["IS_NULLABLE"] = viewRow[SchemaTableColumn.AllowDBNull]; row["DATA_TYPE"] = viewRow["DataTypeName"]; // SQLiteConvert.DbTypeToType((DbType)viewRow[SchemaTableColumn.ProviderType]).ToString(); | | | 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 | row["COLUMN_NAME"] = schemaRow[SchemaTableColumn.BaseColumnName]; row["VIEW_COLUMN_NAME"] = viewRow[SchemaTableColumn.ColumnName]; row["COLUMN_HASDEFAULT"] = (viewRow[SchemaTableOptionalColumn.DefaultValue] != DBNull.Value); row["COLUMN_DEFAULT"] = viewRow[SchemaTableOptionalColumn.DefaultValue]; row["ORDINAL_POSITION"] = viewRow[SchemaTableColumn.ColumnOrdinal]; row["IS_NULLABLE"] = viewRow[SchemaTableColumn.AllowDBNull]; row["DATA_TYPE"] = viewRow["DataTypeName"]; // SQLiteConvert.DbTypeToType((DbType)viewRow[SchemaTableColumn.ProviderType]).ToString(); row["EDM_TYPE"] = SQLiteConvert.DbTypeToTypeName(this, (DbType)viewRow[SchemaTableColumn.ProviderType], _flags).ToString().ToLower(CultureInfo.InvariantCulture); row["CHARACTER_MAXIMUM_LENGTH"] = viewRow[SchemaTableColumn.ColumnSize]; row["TABLE_SCHEMA"] = viewRow[SchemaTableColumn.BaseSchemaName]; row["PRIMARY_KEY"] = viewRow[SchemaTableColumn.IsKey]; row["AUTOINCREMENT"] = viewRow[SchemaTableOptionalColumn.IsAutoIncrement]; row["COLLATION_NAME"] = viewRow["CollationType"]; row["UNIQUE"] = viewRow[SchemaTableColumn.IsUnique]; tbl.Rows.Add(row); |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
983 984 985 986 987 988 989 | DBNull.Value, // ?? (24) DBNull.Value // Xml (25) }; /// <summary> /// Determines the type name for the given database value type. /// </summary> | > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < | | 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | DBNull.Value, // ?? (24) DBNull.Value // Xml (25) }; /// <summary> /// Determines the type name for the given database value type. /// </summary> /// <param name="connection">The connection context for custom type mappings, if any.</param> /// <param name="dbType">The database value type.</param> /// <param name="flags">The flags associated with the parent connection object.</param> /// <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(); SQLiteDbTypeMapping value; if (_typeNames.TryGetValue(dbType, out value)) return value.typeName; } #if !NET_COMPACT_20 && TRACE_WARNING if ((flags & SQLiteConnectionFlags.TraceWarning) == SQLiteConnectionFlags.TraceWarning) { Trace.WriteLine(String.Format( CultureInfo.CurrentCulture, "WARNING: Type mapping failed, returning default name \"{0}\" for type {1}.", defaultTypeName, dbType)); } #endif return defaultTypeName; } /// <summary> |
︙ | ︙ | |||
1182 1183 1184 1185 1186 1187 1188 | new SQLiteDbTypeMapping("YESNO", DbType.Boolean, false) }); } /// <summary> /// For a given type name, return a closest-match .NET type /// </summary> | > | | > > > > > > > | > | > | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 | new SQLiteDbTypeMapping("YESNO", DbType.Boolean, false) }); } /// <summary> /// For a given type name, return a closest-match .NET type /// </summary> /// <param name="connection">The connection context for custom type mappings, if any.</param> /// <param name="name">The name of the type to match</param> /// <param name="flags">The flags associated with the parent connection object.</param> /// <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; if (connectionTypeNames != null) { if (name != null) { SQLiteDbTypeMapping value; if (connectionTypeNames.TryGetValue(name, out value)) { return value.dataType; } else { int index = name.IndexOf('('); if ((index > 0) && 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(); if (name != null) { SQLiteDbTypeMapping value; if (_typeNames.TryGetValue(name, out value)) { return value.dataType; } else { int index = name.IndexOf('('); if ((index > 0) && _typeNames.TryGetValue(name.Substring(0, index).TrimEnd(), out value)) { return value.dataType; } } } } #if !NET_COMPACT_20 && TRACE_WARNING if (!String.IsNullOrEmpty(name) && ((flags & SQLiteConnectionFlags.TraceWarning) == SQLiteConnectionFlags.TraceWarning)) { Trace.WriteLine(String.Format( CultureInfo.CurrentCulture, "WARNING: Type mapping failed, returning default type {0} for name \"{1}\".", defaultDbType, name)); } #endif return defaultDbType; } #endregion |
︙ | ︙ | |||
1550 1551 1552 1553 1554 1555 1556 | /// No longer used. /// </summary> Copy = 0, /// <summary> /// An index will be created. The action-specific arguments are the /// index name and the table name. | | | 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 | /// No longer used. /// </summary> Copy = 0, /// <summary> /// An index will be created. The action-specific arguments are the /// index name and the table name. /// /// </summary> CreateIndex = 1, /// <summary> /// A table will be created. The action-specific arguments are the /// table name and a null value. /// </summary> |
︙ | ︙ | |||
1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 | } ///////////////////////////////////////////////////////////////////////////// internal sealed class SQLiteDbTypeMap : Dictionary<string, SQLiteDbTypeMapping> { private Dictionary<DbType, SQLiteDbTypeMapping> reverse; ///////////////////////////////////////////////////////////////////////// | > > > | > > > > > > > > > > > > > > > > > > > > > > | 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 | } ///////////////////////////////////////////////////////////////////////////// internal sealed class SQLiteDbTypeMap : Dictionary<string, SQLiteDbTypeMapping> { #region Private Data private Dictionary<DbType, SQLiteDbTypeMapping> reverse; #endregion ///////////////////////////////////////////////////////////////////////// #region Public Constructors public SQLiteDbTypeMap() : base(new TypeNameStringComparer()) { reverse = new Dictionary<DbType, SQLiteDbTypeMapping>(); } ///////////////////////////////////////////////////////////////////////// public SQLiteDbTypeMap( IEnumerable<SQLiteDbTypeMapping> collection ) : this() { Add(collection); } #endregion ///////////////////////////////////////////////////////////////////////// #region System.Collections.Generic.Dictionary "Overrides" public new int Clear() { int result = 0; if (reverse != null) { result += reverse.Count; reverse.Clear(); } result += base.Count; base.Clear(); return result; } #endregion ///////////////////////////////////////////////////////////////////////// #region SQLiteDbTypeMapping Helper Methods public void Add( IEnumerable<SQLiteDbTypeMapping> collection ) { if (collection == null) throw new ArgumentNullException("collection"); |
︙ | ︙ | |||
1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 | throw new ArgumentException("item type name cannot be null"); base.Add(item.typeName, item); if (item.primary) reverse.Add(item.dataType, item); } ///////////////////////////////////////////////////////////////////////// public bool TryGetValue(DbType key, out SQLiteDbTypeMapping value) { if (reverse == null) { value = null; return false; } return reverse.TryGetValue(key, out value); } } ///////////////////////////////////////////////////////////////////////////// internal sealed class SQLiteDbTypeMapping { internal SQLiteDbTypeMapping( | > > > > > > > > > > > > > > > > > > > > > > > | 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 | throw new ArgumentException("item type name cannot be null"); base.Add(item.typeName, item); if (item.primary) reverse.Add(item.dataType, item); } #endregion ///////////////////////////////////////////////////////////////////////// #region DbType Helper Methods public bool ContainsKey(DbType key) { if (reverse == null) return false; return reverse.ContainsKey(key); } ///////////////////////////////////////////////////////////////////////// public bool TryGetValue(DbType key, out SQLiteDbTypeMapping value) { if (reverse == null) { value = null; return false; } return reverse.TryGetValue(key, out value); } ///////////////////////////////////////////////////////////////////////// public bool Remove(DbType key) { if (reverse == null) return false; return reverse.Remove(key); } #endregion } ///////////////////////////////////////////////////////////////////////////// internal sealed class SQLiteDbTypeMapping { internal SQLiteDbTypeMapping( |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteDataReader.cs.
︙ | ︙ | |||
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 | if ((_commandBehavior & CommandBehavior.KeyInfo) != 0) LoadKeyInfo(); return true; } } /// <summary> /// This method attempts to query the flags associated with the database /// connection in use. If the database connection is disposed, the default /// flags will be returned. /// </summary> /// <param name="dataReader"> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 | if ((_commandBehavior & CommandBehavior.KeyInfo) != 0) LoadKeyInfo(); return true; } } /// <summary> /// This method attempts to query the database connection associated with /// the data reader in use. If the underlying command or connection is /// unavailable, a null value will be returned. /// </summary> /// <returns> /// The connection object -OR- null if it is unavailable. /// </returns> private static SQLiteConnection GetConnection( SQLiteDataReader dataReader ) { try { if (dataReader != null) { SQLiteCommand command = dataReader._command; if (command != null) { SQLiteConnection connection = command.Connection; if (connection != null) return connection; } } } catch (ObjectDisposedException) { // do nothing. } return null; } /// <summary> /// This method attempts to query the flags associated with the database /// connection in use. If the database connection is disposed, the default /// flags will be returned. /// </summary> /// <param name="dataReader"> |
︙ | ︙ | |||
1345 1346 1347 1348 1349 1350 1351 | if (_fieldTypeArray[i] == null) _fieldTypeArray[i] = new SQLiteType(); typ = _fieldTypeArray[i]; // If not initialized, then fetch the declared column datatype and attempt to convert it // to a known DbType. if (typ.Affinity == TypeAffinity.Uninitialized) | | | 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 | if (_fieldTypeArray[i] == null) _fieldTypeArray[i] = new SQLiteType(); typ = _fieldTypeArray[i]; // If not initialized, then fetch the declared column datatype and attempt to convert it // to a known DbType. if (typ.Affinity == TypeAffinity.Uninitialized) typ.Type = SQLiteConvert.TypeNameToDbType(GetConnection(this), _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity), GetFlags(this)); else typ.Affinity = _activeStatement._sql.ColumnAffinity(_activeStatement, i); return typ; } /// <summary> |
︙ | ︙ |
Changes to Tests/basic.eagle.
︙ | ︙ | |||
2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 | cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {0 4 0 1.75}} ############################################################################### reportSQLiteResources $test_channel ############################################################################### | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 | cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {0 4 0 1.75}} ############################################################################### runTest {test data-1.60 {per-connection type mappings} -setup { setupDb [set fileName data-1.60.db] "" "" "" UseConnectionTypes } -body { set connection [getDbConnection] set result [list] lappend result [sql execute $db \ "CREATE TABLE t1(x DATE, y MYDATE);"] set dateTime [clock format [clock scan "2014-02-01 12:34:56Z"] \ -format yyyyMMddHHmmss -gmt true] lappend result [sql execute $db [appendArgs \ "INSERT INTO t1 (x, y) VALUES('" $dateTime "', '" $dateTime "');"]] lappend result [sql execute -verbatim -execute reader -format list \ -datetimeformat [getDateTimeFormat] $db "SELECT x, y FROM t1;"] lappend result [$connection ClearTypeMappings]; # 0 lappend result [$connection AddTypeMapping MYDATE DateTime false]; # 0 lappend result [$connection AddTypeMapping MYDATE DateTime true]; # 1 lappend result [$connection AddTypeMapping MYDATE DateTime false]; # 1 lappend result [$connection AddTypeMapping MYDATE DateTime true]; # 2 lappend result [$connection ClearTypeMappings]; # 2 lappend result [$connection AddTypeMapping MYDATE DateTime true]; # 0 set typeMappings [$connection GetTypeMappings] object foreach -alias pair $typeMappings { set typeMapping [$pair Value] lappend result [list [$pair Key] [enumerableToList $typeMapping]] } lappend result [sql execute -verbatim -execute reader -format list \ -datetimeformat [getDateTimeFormat] $db "SELECT x, y FROM t1;"] set result } -cleanup { freeDbConnection unset -nocomplain typeMapping typeMappings pair result connection cleanupDb $fileName unset -nocomplain dateTime db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {0 1 {{2014-02-01 12:34:56} 20140201123456} 0 0 1 1 2 2 0 {MYDATE {MYDATE\ DateTime True}} {{2014-02-01 12:34:56} {2014-02-01 12:34:56}}}} ############################################################################### reportSQLiteResources $test_channel ############################################################################### |
︙ | ︙ |
Changes to readme.htm.
︙ | ︙ | |||
210 211 212 213 214 215 216 217 218 219 220 221 222 223 | <p> <b>1.0.91.0 - February XX, 2014 <font color="red">(release scheduled)</font></b> </p> <ul> <li>Updated to <a href="http://www.sqlite.org/src/info/trunk">SQLite 3.8.3</a>.</li> <li>Add support for <a href="http://entityframework.codeplex.com/">Entity Framework 6</a>.</li> <li>Modify the namespace used for all internal classes in the System.Data.SQLite.Linq assembly. <b>** Potentially Incompatible Change **</b></li> <li>Add SQLiteCompileOptions and InteropCompileOptions properties to the SQLiteConnection class to return the compile-time options for the SQLite core library and interop assembly, respectively.</li> <li>Add BindInvariantText and ConvertInvariantText connection flags to force the invariant culture to be used when converting parameter values to/from strings.</li> <li>Add NoConnectionPool and UseConnectionPool connection flags to disable or enable connection pooling by default.</li> <li>Modify handling of the design-time components installer to run Visual Studio <b>devenv.exe /setup</b> after installing the package. This appears to be necessary in some circumstances for Visual Studio 2013. Pursuant to [a47eff2c71].</li> <li>Modify the native library pre-loader to support reading settings from an XML configuration file and to be capable of checking more than one directory. Persuant to [f0246d1817].</li> <li>Change the default behavior for the native library pre-loader so it first searches the executing (i.e. System.Data.SQLite) assembly directory and then the application domain directory. Pursuant to [f0246d1817]. <b>** Potentially Incompatible Change **</b></li> | > | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | <p> <b>1.0.91.0 - February XX, 2014 <font color="red">(release scheduled)</font></b> </p> <ul> <li>Updated to <a href="http://www.sqlite.org/src/info/trunk">SQLite 3.8.3</a>.</li> <li>Add support for <a href="http://entityframework.codeplex.com/">Entity Framework 6</a>.</li> <li>Add support for per-connection mappings between type names and DbType values. Pursuant to [e87af1d06a].</li> <li>Modify the namespace used for all internal classes in the System.Data.SQLite.Linq assembly. <b>** Potentially Incompatible Change **</b></li> <li>Add SQLiteCompileOptions and InteropCompileOptions properties to the SQLiteConnection class to return the compile-time options for the SQLite core library and interop assembly, respectively.</li> <li>Add BindInvariantText and ConvertInvariantText connection flags to force the invariant culture to be used when converting parameter values to/from strings.</li> <li>Add NoConnectionPool and UseConnectionPool connection flags to disable or enable connection pooling by default.</li> <li>Modify handling of the design-time components installer to run Visual Studio <b>devenv.exe /setup</b> after installing the package. This appears to be necessary in some circumstances for Visual Studio 2013. Pursuant to [a47eff2c71].</li> <li>Modify the native library pre-loader to support reading settings from an XML configuration file and to be capable of checking more than one directory. Persuant to [f0246d1817].</li> <li>Change the default behavior for the native library pre-loader so it first searches the executing (i.e. System.Data.SQLite) assembly directory and then the application domain directory. Pursuant to [f0246d1817]. <b>** Potentially Incompatible Change **</b></li> |
︙ | ︙ |
Changes to www/news.wiki.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <title>News</title> <b>Version History</b> <p> <b>1.0.91.0 - February XX, 2014 <font color="red">(release scheduled)</font></b> </p> <ul> <li>Updated to [http://www.sqlite.org/src/info/trunk|SQLite 3.8.3].</li> <li>Add support for [http://entityframework.codeplex.com/|Entity Framework 6].</li> <li>Modify the namespace used for all internal classes in the System.Data.SQLite.Linq assembly. <b>** Potentially Incompatible Change **</b></li> <li>Add SQLiteCompileOptions and InteropCompileOptions properties to the SQLiteConnection class to return the compile-time options for the SQLite core library and interop assembly, respectively.</li> <li>Add BindInvariantText and ConvertInvariantText connection flags to force the invariant culture to be used when converting parameter values to/from strings.</li> <li>Add NoConnectionPool and UseConnectionPool connection flags to disable or enable connection pooling by default.</li> <li>Modify handling of the design-time components installer to run Visual Studio <b>devenv.exe /setup</b> after installing the package. This appears to be necessary in some circumstances for Visual Studio 2013. Pursuant to [a47eff2c71].</li> <li>Modify the native library pre-loader to support reading settings from an XML configuration file and to be capable of checking more than one directory. Persuant to [f0246d1817].</li> <li>Change the default behavior for the native library pre-loader so it first searches the executing (i.e. System.Data.SQLite) assembly directory and then the application domain directory. Pursuant to [f0246d1817]. <b>** Potentially Incompatible Change **</b></li> | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <title>News</title> <b>Version History</b> <p> <b>1.0.91.0 - February XX, 2014 <font color="red">(release scheduled)</font></b> </p> <ul> <li>Updated to [http://www.sqlite.org/src/info/trunk|SQLite 3.8.3].</li> <li>Add support for [http://entityframework.codeplex.com/|Entity Framework 6].</li> <li>Add support for per-connection mappings between type names and DbType values. Pursuant to [e87af1d06a].</li> <li>Modify the namespace used for all internal classes in the System.Data.SQLite.Linq assembly. <b>** Potentially Incompatible Change **</b></li> <li>Add SQLiteCompileOptions and InteropCompileOptions properties to the SQLiteConnection class to return the compile-time options for the SQLite core library and interop assembly, respectively.</li> <li>Add BindInvariantText and ConvertInvariantText connection flags to force the invariant culture to be used when converting parameter values to/from strings.</li> <li>Add NoConnectionPool and UseConnectionPool connection flags to disable or enable connection pooling by default.</li> <li>Modify handling of the design-time components installer to run Visual Studio <b>devenv.exe /setup</b> after installing the package. This appears to be necessary in some circumstances for Visual Studio 2013. Pursuant to [a47eff2c71].</li> <li>Modify the native library pre-loader to support reading settings from an XML configuration file and to be capable of checking more than one directory. Persuant to [f0246d1817].</li> <li>Change the default behavior for the native library pre-loader so it first searches the executing (i.e. System.Data.SQLite) assembly directory and then the application domain directory. Pursuant to [f0246d1817]. <b>** Potentially Incompatible Change **</b></li> |
︙ | ︙ |