Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Revise fix for [5251bd0878] to use null for the 'COLUMN_NAME' if the original value was DBNull.Value. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tkt-5251bd0878 |
Files: | files | file ages | folders |
SHA1: |
f8c2007d480bd6b1dfcc368d1989c5b1 |
User & Date: | mistachkin 2015-12-12 01:59:14.578 |
Context
2015-12-12
| ||
02:02 | Coding style adjustment. check-in: 9b51e7a273 user: mistachkin tags: tkt-5251bd0878 | |
01:59 | Revise fix for [5251bd0878] to use null for the 'COLUMN_NAME' if the original value was DBNull.Value. check-in: f8c2007d48 user: mistachkin tags: tkt-5251bd0878 | |
2015-12-11
| ||
23:35 | Properly handle NULL values in the 'name' column of the results returned by PRAGMA index_info(). Fix for [5251bd0878]. check-in: c93b891f69 user: mistachkin tags: tkt-5251bd0878 | |
Changes
Changes to SQLite.Designer/Design/Index.cs.
︙ | ︙ | |||
389 390 391 392 393 394 395 | } internal IndexColumn(Index parent, DataRow row) { _parent = parent; if (row != null) { | > | > > > | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | } internal IndexColumn(Index parent, DataRow row) { _parent = parent; if (row != null) { if (!row.IsNull("COLUMN_NAME")) _column = row["COLUMN_NAME"].ToString(); else _column = null; if (row.IsNull("SORT_MODE") == false && (string)row["SORT_MODE"] != "ASC") _mode = ColumnSortMode.Descending; if (row.IsNull("COLLATION_NAME") == false) _collate = row["COLLATION_NAME"].ToString().ToUpperInvariant(); } } |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
4753 4754 4755 4756 4757 4758 4759 | try { using (SQLiteCommand cmdIndex = new SQLiteCommand(UnsafeNativeMethods.StringFormat(CultureInfo.InvariantCulture, "PRAGMA [{0}].index_info([{1}])", strCatalog, rdIndexes.GetString(1)), this)) using (SQLiteDataReader rdIndex = cmdIndex.ExecuteReader()) { while (rdIndex.Read()) { | | | | | 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 | try { using (SQLiteCommand cmdIndex = new SQLiteCommand(UnsafeNativeMethods.StringFormat(CultureInfo.InvariantCulture, "PRAGMA [{0}].index_info([{1}])", strCatalog, rdIndexes.GetString(1)), this)) using (SQLiteDataReader rdIndex = cmdIndex.ExecuteReader()) { while (rdIndex.Read()) { string columnName = rdIndex.IsDBNull(2) ? null : rdIndex.GetString(2); row = tbl.NewRow(); row["CONSTRAINT_CATALOG"] = strCatalog; row["CONSTRAINT_NAME"] = rdIndexes.GetString(1); row["TABLE_CATALOG"] = strCatalog; row["TABLE_NAME"] = rdIndexes.GetString(2); row["COLUMN_NAME"] = columnName; row["INDEX_NAME"] = rdIndexes.GetString(1); row["ORDINAL_POSITION"] = ordinal; // rdIndex.GetInt32(1); string collationSequence = null; int sortMode = 0; int onError = 0; if (columnName != null) _sql.GetIndexColumnExtendedInfo(strCatalog, rdIndexes.GetString(1), columnName, ref sortMode, ref onError, ref collationSequence); if (String.IsNullOrEmpty(collationSequence) == false) row["COLLATION_NAME"] = collationSequence; row["SORT_MODE"] = (sortMode == 0) ? "ASC" : "DESC"; row["CONFLICT_OPTION"] = onError; ordinal++; if ((strColumn == null) || String.Compare(strColumn, columnName, StringComparison.OrdinalIgnoreCase) == 0) tbl.Rows.Add(row); } } } catch (SQLiteException) { } |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 | } finally { if (!found && (connection != null)) connection.SetCachedSetting(name, value); } } /// <summary> /// Determines if the specified textual value appears to be a /// <see cref="DBNull" /> value. /// </summary> /// <param name="text"> /// The textual value to inspect. | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 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 1869 | } finally { if (!found && (connection != null)) connection.SetCachedSetting(name, value); } } /// <summary> /// Converts the object value, which is assumed to have originated /// from a <see cref="DataRow" />, to a string value. /// </summary> /// <param name="value"> /// The value to be converted to a string. /// </param> /// <returns> /// A null value will be returned if the original value is null -OR- /// the original value is <see cref="DBNull.Value" />. Otherwise, /// the original value will be converted to a string, using its /// (possibly overridden) <see cref="Object.ToString" /> method and /// then returned. /// </returns> public static string GetStringOrNull( object value ) { if (value == null) return null; if (value is string) return (string)value; if (Object.ReferenceEquals(value, DBNull.Value)) return null; return value.ToString(); } /// <summary> /// Determines if the specified textual value appears to be a /// <see cref="DBNull" /> value. /// </summary> /// <param name="text"> /// The textual value to inspect. |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteDataReader.cs.
︙ | ︙ | |||
1168 1169 1170 1171 1172 1173 1174 | null, (string)row[SchemaTableColumn.BaseTableName], (string)rowIndexes["INDEX_NAME"], null }); foreach (DataRow rowColumnIndex in tblIndexColumns.Rows) { | | | 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 | null, (string)row[SchemaTableColumn.BaseTableName], (string)rowIndexes["INDEX_NAME"], null }); foreach (DataRow rowColumnIndex in tblIndexColumns.Rows) { if (String.Compare(SQLiteConvert.GetStringOrNull(rowColumnIndex["COLUMN_NAME"]), strColumn, StringComparison.OrdinalIgnoreCase) == 0) { // // BUGFIX: Make sure that we only flag this column as "unique" // if we are not processing of some kind of multi-table // construct (i.e. a join) because in that case we must // allow duplicate values (refer to ticket [7e3fa93744]). // |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteKeyReader.cs.
︙ | ︙ | |||
239 240 241 242 243 244 245 246 247 248 249 250 251 252 | using (DataTable indexColumns = cnn.GetSchema("IndexColumns", new string[] { pair.Key, null, table, (string)preferredRow["INDEX_NAME"] })) { KeyQuery query = null; List<string> cols = new List<string>(); for (int x = 0; x < indexColumns.Rows.Count; x++) { bool addKey = true; // If the column in the index already appears in the query, skip it foreach (DataRow row in schema.Rows) { if (row.IsNull(SchemaTableColumn.BaseColumnName)) continue; | > > > | | | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | using (DataTable indexColumns = cnn.GetSchema("IndexColumns", new string[] { pair.Key, null, table, (string)preferredRow["INDEX_NAME"] })) { KeyQuery query = null; List<string> cols = new List<string>(); for (int x = 0; x < indexColumns.Rows.Count; x++) { string columnName = SQLiteConvert.GetStringOrNull( indexColumns.Rows[x]["COLUMN_NAME"]); bool addKey = true; // If the column in the index already appears in the query, skip it foreach (DataRow row in schema.Rows) { if (row.IsNull(SchemaTableColumn.BaseColumnName)) continue; if ((string)row[SchemaTableColumn.BaseColumnName] == columnName && (string)row[SchemaTableColumn.BaseTableName] == table && (string)row[SchemaTableOptionalColumn.BaseCatalogName] == pair.Key) { indexColumns.Rows.RemoveAt(x); x--; addKey = false; break; } } if (addKey == true) cols.Add(columnName); } // If the index is not a rowid alias, record all the columns // needed to make up the unique index and construct a SQL query for it if ((string)preferredRow["INDEX_NAME"] != "sqlite_master_PK_" + table) { // Whatever remains of the columns we need that make up the index that are not // already in the query need to be queried separately, so construct a subquery if (cols.Count > 0) { string[] querycols = new string[cols.Count]; cols.CopyTo(querycols); query = new KeyQuery(cnn, pair.Key, table, querycols); } } // Create a KeyInfo struct for each column of the index for (int x = 0; x < indexColumns.Rows.Count; x++) { string columnName = SQLiteConvert.GetStringOrNull(indexColumns.Rows[x]["COLUMN_NAME"]); KeyInfo key = new KeyInfo(); key.rootPage = rootPage; key.cursor = cursor; key.database = database; key.databaseName = pair.Key; key.tableName = table; |
︙ | ︙ |
Changes to Tests/tkt-5251bd0878.eagle.
︙ | ︙ | |||
57 58 59 60 61 62 63 | } -cleanup { unset -nocomplain dataTable dataReader cleanupDb $fileName freeDbConnection | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | } -cleanup { unset -nocomplain dataTable dataReader cleanupDb $fileName freeDbConnection unset -nocomplain column row result connection db fileName } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite} -result {{ColumnName x} {IsKey True} {ColumnName y} {IsKey\ False}}} ############################################################################### runSQLiteTestEpilogue |
︙ | ︙ |