Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use the declared column size for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for [3113734605]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
9531731b986479db9f63d3b219ff3050 |
User & Date: | mistachkin 2013-08-29 07:08:46.911 |
Context
2013-08-29
| ||
09:08 | Update SQLite core library to the latest trunk. check-in: fec273cc1d user: mistachkin tags: trunk | |
07:08 | Use the declared column size for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for [3113734605]. check-in: 9531731b98 user: mistachkin tags: trunk | |
2013-08-27
| ||
00:52 | Add MS KB article link about the Visual C++ Runtime Library downloads to the download page. check-in: 3824d3fd20 user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteDataReader.cs.
1 2 3 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) | | | 1 2 3 4 5 6 7 8 9 10 11 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { using System; using System.Collections.Generic; |
︙ | ︙ | |||
307 308 309 310 311 312 313 | return _fieldCount; } } /// <summary> /// SQLite is inherently un-typed. All datatypes in SQLite are natively strings. The definition of the columns of a table /// and the affinity of returned types are all we have to go on to type-restrict data in the reader. | | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | return _fieldCount; } } /// <summary> /// SQLite is inherently un-typed. All datatypes in SQLite are natively strings. The definition of the columns of a table /// and the affinity of returned types are all we have to go on to type-restrict data in the reader. /// /// This function attempts to verify that the type of data being requested of a column matches the datatype of the column. In /// the case of columns that are not backed into a table definition, we attempt to match up the affinity of a column (int, double, string or blob) /// to a set of known types that closely match that affinity. It's not an exact science, but its the best we can do. /// </summary> /// <returns> /// This function throws an InvalidTypeCast() exception if the requested type doesn't match the column's definition or affinity. /// </returns> |
︙ | ︙ | |||
915 916 917 918 919 920 921 922 923 | tbl.Columns.Add(SchemaTableOptionalColumn.DefaultValue, typeof(object)); tbl.Columns.Add("DataTypeName", typeof(string)); tbl.Columns.Add("CollationType", typeof(string)); tbl.BeginLoadData(); for (int n = 0; n < _fieldCount; n++) { row = tbl.NewRow(); | > > | | | 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 | tbl.Columns.Add(SchemaTableOptionalColumn.DefaultValue, typeof(object)); tbl.Columns.Add("DataTypeName", typeof(string)); tbl.Columns.Add("CollationType", typeof(string)); tbl.BeginLoadData(); for (int n = 0; n < _fieldCount; n++) { SQLiteType sqlType = GetSQLiteType(n); row = tbl.NewRow(); DbType typ = sqlType.Type; // Default settings for the column row[SchemaTableColumn.ColumnName] = GetName(n); row[SchemaTableColumn.ColumnOrdinal] = n; row[SchemaTableColumn.ColumnSize] = SQLiteConvert.DbTypeToColumnSize(typ); row[SchemaTableColumn.NumericPrecision] = SQLiteConvert.DbTypeToNumericPrecision(typ); row[SchemaTableColumn.NumericScale] = SQLiteConvert.DbTypeToNumericScale(typ); row[SchemaTableColumn.ProviderType] = sqlType.Type; row[SchemaTableColumn.IsLong] = false; row[SchemaTableColumn.AllowDBNull] = true; row[SchemaTableOptionalColumn.IsReadOnly] = false; row[SchemaTableOptionalColumn.IsRowVersion] = false; row[SchemaTableColumn.IsUnique] = false; row[SchemaTableColumn.IsKey] = false; row[SchemaTableOptionalColumn.IsAutoIncrement] = false; |
︙ | ︙ | |||
981 982 983 984 985 986 987 | if (arSize.Length > 1) { dataType = arSize[0]; arSize = arSize[1].Split(')'); if (arSize.Length > 1) { arSize = arSize[0].Split(',', '.'); | | > | 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 | if (arSize.Length > 1) { dataType = arSize[0]; arSize = arSize[1].Split(')'); if (arSize.Length > 1) { arSize = arSize[0].Split(',', '.'); if (sqlType.Type == DbType.Binary || sqlType.Type == DbType.String || sqlType.Type == DbType.AnsiStringFixedLength || sqlType.Type == DbType.StringFixedLength) { row[SchemaTableColumn.ColumnSize] = Convert.ToInt32(arSize[0], CultureInfo.InvariantCulture); } else { row[SchemaTableColumn.NumericPrecision] = Convert.ToInt32(arSize[0], CultureInfo.InvariantCulture); if (arSize.Length > 1) |
︙ | ︙ | |||
1331 1332 1333 1334 1335 1336 1337 | _fieldTypeArray = new SQLiteType[VisibleFieldCount]; // Initialize this column's field type instance if (_fieldTypeArray[i] == null) _fieldTypeArray[i] = new SQLiteType(); typ = _fieldTypeArray[i]; | | | 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 | _fieldTypeArray = new SQLiteType[VisibleFieldCount]; // Initialize this column's field type instance 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(_activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity)); else typ.Affinity = _activeStatement._sql.ColumnAffinity(_activeStatement, i); return typ; |
︙ | ︙ |
Added Tests/tkt-3113734605.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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | ############################################################################### # # tkt-3113734605.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-3113734605-1.1 {ColumnSize and NumericPrecision} -setup { setupDb [set fileName tkt-3113734605-1.1.db] } -body { set connection [getDbConnection] set result [list] sql execute $db "CREATE TABLE t1 (x CHAR(3));" sql execute $db "CREATE VIEW v1 AS SELECT * FROM t1;" foreach collectionName [list TABLECOLUMNS VIEWCOLUMNS] { set dataTable [object invoke -alias $connection GetSchema $collectionName] if {[string length $dataTable] > 0} then { set dataRows [$dataTable Rows] object foreach -alias dataRow $dataRows { lappend result [set value [$dataRow get_Item TABLE_NAME]] lappend result [set value [$dataRow get_Item COLUMN_NAME]] lappend result [set value [$dataRow get_Item CHARACTER_MAXIMUM_LENGTH]] lappend result [set value [$dataRow get_Item NUMERIC_PRECISION]] } } } set result } -cleanup { cleanupDb $fileName freeDbConnection unset -nocomplain value dataRow dataRows dataTable collectionName result \ connection db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \ regexp -result {^t1 x 3 System#DBNull#\d+ v1 x 3 System#DBNull#\d+ t1 x 3\ System#DBNull#\d+$}} ############################################################################### runSQLiteTestEpilogue runTestEpilogue |