Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When translating a DbType to a type name, be sure to prioritize the type names supported by the EDMX components. Fix for [47f4bac575]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4aa236088586925e892f367ac8cc5cbc |
User & Date: | mistachkin 2013-05-28 09:34:15.126 |
Context
2013-05-28
| ||
09:55 | Bump all versions to 1.0.87.0. check-in: 01ae5e862f user: mistachkin tags: trunk | |
09:34 | When translating a DbType to a type name, be sure to prioritize the type names supported by the EDMX components. Fix for [47f4bac575]. check-in: 4aa2360885 user: mistachkin tags: trunk | |
08:19 | Fix incorrect comment. check-in: 3a98512a05 user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
867 868 869 870 871 872 873 | DBNull.Value // Xml (25) }; internal static string DbTypeToTypeName(DbType typ) { for (int n = 0; n < _dbtypeNames.Length; n++) { | > > | | | | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | DBNull.Value // Xml (25) }; internal static string DbTypeToTypeName(DbType typ) { for (int n = 0; n < _dbtypeNames.Length; n++) { SQLiteTypeName typeName = _dbtypeNames[n]; if ((typeName.dataType == typ) && typeName.primary) return typeName.typeName; } string defaultTypeName = String.Empty; #if !NET_COMPACT_20 && TRACE_WARNING Trace.WriteLine(String.Format( "WARNING: Type mapping failed, returning default name \"{0}\" for type {1}.", defaultTypeName, typ)); #endif return defaultTypeName; } private static SQLiteTypeName[] _dbtypeNames = GetSQLiteTypeNames(); /// <summary> /// Convert a DbType to a Type /// </summary> /// <param name="typ">The DbType to convert from</param> /// <returns>The closest-match .NET type</returns> internal static Type DbTypeToType(DbType typ) |
︙ | ︙ | |||
971 972 973 974 975 976 977 | /// Builds and returns an array containing the database column types /// recognized by this provider. /// </summary> /// <returns> /// An array containing the database column types recognized by this /// provider. /// </returns> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 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 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 | /// Builds and returns an array containing the database column types /// recognized by this provider. /// </summary> /// <returns> /// An array containing the database column types recognized by this /// provider. /// </returns> private static SQLiteTypeName[] GetSQLiteTypeNames() { return new SQLiteTypeName[] { new SQLiteTypeName("BIGINT", DbType.Int64, false), new SQLiteTypeName("BIGUINT", DbType.UInt64, false), new SQLiteTypeName("BINARY", DbType.Binary, false), new SQLiteTypeName("BIT", DbType.Boolean, true), new SQLiteTypeName("BLOB", DbType.Binary, true), new SQLiteTypeName("BOOL", DbType.Boolean, false), new SQLiteTypeName("BOOLEAN", DbType.Boolean, false), new SQLiteTypeName("CHAR", DbType.AnsiStringFixedLength, true), new SQLiteTypeName("COUNTER", DbType.Int64, false), new SQLiteTypeName("CURRENCY", DbType.Decimal, false), new SQLiteTypeName("DATE", DbType.DateTime, false), new SQLiteTypeName("DATETIME", DbType.DateTime, true), new SQLiteTypeName("DECIMAL", DbType.Decimal, true), new SQLiteTypeName("DOUBLE", DbType.Double, false), new SQLiteTypeName("FLOAT", DbType.Double, false), new SQLiteTypeName("GENERAL", DbType.Binary, false), new SQLiteTypeName("GUID", DbType.Guid, false), new SQLiteTypeName("IDENTITY", DbType.Int64, false), new SQLiteTypeName("IMAGE", DbType.Binary, false), new SQLiteTypeName("INT", DbType.Int32, true), new SQLiteTypeName("INT8", DbType.SByte, false), new SQLiteTypeName("INT16", DbType.Int16, false), new SQLiteTypeName("INT32", DbType.Int32, false), new SQLiteTypeName("INT64", DbType.Int64, false), new SQLiteTypeName("INTEGER", DbType.Int64, true), new SQLiteTypeName("INTEGER8", DbType.SByte, false), new SQLiteTypeName("INTEGER16", DbType.Int16, false), new SQLiteTypeName("INTEGER32", DbType.Int32, false), new SQLiteTypeName("INTEGER64", DbType.Int64, false), new SQLiteTypeName("LOGICAL", DbType.Boolean, false), new SQLiteTypeName("LONG", DbType.Int64, false), new SQLiteTypeName("LONGCHAR", DbType.String, false), new SQLiteTypeName("LONGTEXT", DbType.String, false), new SQLiteTypeName("LONGVARCHAR", DbType.String, false), new SQLiteTypeName("MEMO", DbType.String, false), new SQLiteTypeName("MONEY", DbType.Decimal, false), new SQLiteTypeName("NCHAR", DbType.StringFixedLength, true), new SQLiteTypeName("NOTE", DbType.String, false), new SQLiteTypeName("NTEXT", DbType.String, false), new SQLiteTypeName("NUMERIC", DbType.Decimal, false), new SQLiteTypeName("NVARCHAR", DbType.String, true), new SQLiteTypeName("OLEOBJECT", DbType.Binary, false), new SQLiteTypeName("REAL", DbType.Double, true), new SQLiteTypeName("SINGLE", DbType.Single, true), new SQLiteTypeName("SMALLDATE", DbType.DateTime, false), new SQLiteTypeName("SMALLINT", DbType.Int16, true), new SQLiteTypeName("SMALLUINT", DbType.UInt16, true), new SQLiteTypeName("STRING", DbType.String, false), new SQLiteTypeName("TEXT", DbType.String, false), new SQLiteTypeName("TIME", DbType.DateTime, false), new SQLiteTypeName("TIMESTAMP", DbType.DateTime, false), new SQLiteTypeName("TINYINT", DbType.Byte, true), new SQLiteTypeName("TINYSINT", DbType.SByte, true), new SQLiteTypeName("UINT", DbType.UInt32, true), new SQLiteTypeName("UINT8", DbType.Byte, false), new SQLiteTypeName("UINT16", DbType.UInt16, false), new SQLiteTypeName("UINT32", DbType.UInt32, false), new SQLiteTypeName("UINT64", DbType.UInt64, false), new SQLiteTypeName("ULONG", DbType.UInt64, false), new SQLiteTypeName("UNIQUEIDENTIFIER", DbType.Guid, true), new SQLiteTypeName("UNSIGNEDINTEGER", DbType.UInt64, true), new SQLiteTypeName("UNSIGNEDINTEGER8", DbType.Byte, false), new SQLiteTypeName("UNSIGNEDINTEGER16", DbType.UInt16, false), new SQLiteTypeName("UNSIGNEDINTEGER32", DbType.UInt32, false), new SQLiteTypeName("UNSIGNEDINTEGER64", DbType.UInt64, false), new SQLiteTypeName("VARBINARY", DbType.Binary, false), new SQLiteTypeName("VARCHAR", DbType.AnsiString, true), new SQLiteTypeName("YESNO", DbType.Boolean, false) }; } /// <summary> /// For a given type name, return a closest-match .NET type /// </summary> /// <param name="Name">The name of the type to match</param> /// <returns>The .NET DBType the text evaluates to.</returns> internal static DbType TypeNameToDbType(string Name) { lock (_syncRoot) { if (_typeNames == null) { _typeNames = new Dictionary<string, SQLiteTypeName>( new TypeNameStringComparer()); foreach (SQLiteTypeName typeName in GetSQLiteTypeNames()) _typeNames.Add(typeName.typeName, typeName); } } if (String.IsNullOrEmpty(Name)) return DbType.Object; SQLiteTypeName value; if (_typeNames.TryGetValue(Name, out value)) { return value.dataType; } else { |
︙ | ︙ | |||
1095 1096 1097 1098 1099 1100 1101 | #endif return defaultDbType; } #endregion private static object _syncRoot = new object(); | | | 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 | #endif return defaultDbType; } #endregion private static object _syncRoot = new object(); private static Dictionary<string, SQLiteTypeName> _typeNames = null; } /// <summary> /// SQLite has very limited types, and is inherently text-based. The first 5 types below represent the sum of all types SQLite /// understands. The DateTime extension to the spec is for internal use only. /// </summary> public enum TypeAffinity |
︙ | ︙ | |||
1390 1391 1392 1393 1394 1395 1396 | internal DbType Type; /// <summary> /// The affinity of a column, used for expressions or when Type is DbType.Object /// </summary> internal TypeAffinity Affinity; } | | | | | > > | 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 | internal DbType Type; /// <summary> /// The affinity of a column, used for expressions or when Type is DbType.Object /// </summary> internal TypeAffinity Affinity; } internal struct SQLiteTypeName { internal SQLiteTypeName(string newTypeName, DbType newDataType, bool newPrimary) { typeName = newTypeName; dataType = newDataType; primary = newPrimary; } internal string typeName; internal DbType dataType; internal bool primary; } internal class TypeNameStringComparer : IEqualityComparer<string> { #region IEqualityComparer<string> Members public bool Equals( string left, |
︙ | ︙ |
Added Tests/tkt-47f4bac575.eagle.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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 45 46 | ############################################################################### # # tkt-47f4bac575.eagle -- # # Written by Joe Mistachkin. # Released to the public domain, use at your own risk! # ############################################################################### package require Eagle package require Eagle.Library package require Eagle.Test runTestPrologue ############################################################################### package require System.Data.SQLite.Test runSQLiteTestPrologue ############################################################################### runTest {test tkt-47f4bac575-1.1 {SQLiteConvert DbTypeToTypeName} -body { foreach dbType [list \ AnsiString Binary Byte Boolean Currency Date DateTime Decimal \ Double Guid Int16 Int32 Int64 Object SByte Single String Time \ UInt16 UInt32 UInt64 VarNumeric AnsiStringFixedLength \ StringFixedLength Xml DateTime2 DateTimeOffset] { lappend result [list $dbType [object invoke -flags +NonPublic \ System.Data.SQLite.SQLiteConvert DbTypeToTypeName $dbType]] } set result } -cleanup { unset -nocomplain result dbType } -constraints {eagle System.Data.SQLite} -result {{AnsiString VARCHAR} {Binary\ BLOB} {Byte TINYINT} {Boolean BIT} {Currency {}} {Date {}} {DateTime DATETIME}\ {Decimal DECIMAL} {Double REAL} {Guid UNIQUEIDENTIFIER} {Int16 SMALLINT} {Int32\ INT} {Int64 INTEGER} {Object {}} {SByte TINYSINT} {Single SINGLE} {String\ NVARCHAR} {Time {}} {UInt16 SMALLUINT} {UInt32 UINT} {UInt64 UNSIGNEDINTEGER}\ {VarNumeric {}} {AnsiStringFixedLength CHAR} {StringFixedLength NCHAR} {Xml {}}\ {DateTime2 {}} {DateTimeOffset {}}}} ############################################################################### runSQLiteTestEpilogue runTestEpilogue |