Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Some further related cleanup in the GetSchemaTable method. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tkt-baf42ee135 |
Files: | files | file ages | folders |
SHA1: |
36be86807a01c4475884595917844073 |
User & Date: | mistachkin 2018-03-08 16:23:13.973 |
Context
2018-03-08
| ||
18:13 | Prevent GetSchemaTable from throwing InvalidCastException. Fix for [baf42ee135]. check-in: c956230a3c user: mistachkin tags: trunk | |
16:23 | Some further related cleanup in the GetSchemaTable method. Closed-Leaf check-in: 36be86807a user: mistachkin tags: tkt-baf42ee135 | |
16:09 | Add tests for ticket [baf42ee135] and get them passing. check-in: d0b0a52b9a user: mistachkin tags: tkt-baf42ee135 | |
Changes
Changes to System.Data.SQLite/SQLiteDataReader.cs.
︙ | ︙ | |||
1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 | baseCatalogName = (string)row[SchemaTableOptionalColumn.BaseCatalogName]; string baseTableName = String.Empty; if (row[SchemaTableColumn.BaseTableName] != DBNull.Value) baseTableName = (string)row[SchemaTableColumn.BaseTableName]; string collSeq = null; bool bNotNull = false; bool bPrimaryKey = false; bool bAutoIncrement = false; string[] arSize; // Get the column meta data _command.Connection._sql.ColumnMetaData( baseCatalogName, baseTableName, strColumn, ref dataType, ref collSeq, ref bNotNull, ref bPrimaryKey, ref bAutoIncrement); if (bNotNull || bPrimaryKey) row[SchemaTableColumn.AllowDBNull] = false; row[SchemaTableColumn.IsKey] = bPrimaryKey && CountParents(parentToColumns) <= 1; row[SchemaTableOptionalColumn.IsAutoIncrement] = bAutoIncrement; row["CollationType"] = collSeq; // For types like varchar(50) and such, extract the size arSize = dataType.Split('('); | > > > > > > | 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 | baseCatalogName = (string)row[SchemaTableOptionalColumn.BaseCatalogName]; string baseTableName = String.Empty; if (row[SchemaTableColumn.BaseTableName] != DBNull.Value) baseTableName = (string)row[SchemaTableColumn.BaseTableName]; string baseColumnName = String.Empty; if (row[SchemaTableColumn.BaseColumnName] != DBNull.Value) baseColumnName = (string)row[SchemaTableColumn.BaseColumnName]; string collSeq = null; bool bNotNull = false; bool bPrimaryKey = false; bool bAutoIncrement = false; string[] arSize; // Get the column meta data _command.Connection._sql.ColumnMetaData( baseCatalogName, baseTableName, strColumn, ref dataType, ref collSeq, ref bNotNull, ref bPrimaryKey, ref bAutoIncrement); if (bNotNull || bPrimaryKey) row[SchemaTableColumn.AllowDBNull] = false; bool allowDbNull = (bool)row[SchemaTableColumn.AllowDBNull]; row[SchemaTableColumn.IsKey] = bPrimaryKey && CountParents(parentToColumns) <= 1; row[SchemaTableOptionalColumn.IsAutoIncrement] = bAutoIncrement; row["CollationType"] = collSeq; // For types like varchar(50) and such, extract the size arSize = dataType.Split('('); |
︙ | ︙ | |||
1544 1545 1546 1547 1548 1549 1550 | baseTableName ), _command.Connection)) using (DbDataReader rdTable = cmdTable.ExecuteReader()) { // Find the matching column while (rdTable.Read()) { | | | 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 | baseTableName ), _command.Connection)) using (DbDataReader rdTable = cmdTable.ExecuteReader()) { // Find the matching column while (rdTable.Read()) { if (String.Compare(baseColumnName, rdTable.GetString(1), StringComparison.OrdinalIgnoreCase) == 0) { if (rdTable.IsDBNull(4) == false) row[SchemaTableOptionalColumn.DefaultValue] = rdTable[4]; break; } } |
︙ | ︙ | |||
1590 1591 1592 1593 1594 1595 1596 | { // // 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]). // | | | 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 | { // // 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]). // if (parentToColumns.Count == 1 && tblIndexColumns.Rows.Count == 1 && allowDbNull == false) row[SchemaTableColumn.IsUnique] = rowIndexes["UNIQUE"]; // If its an integer primary key and the only primary key in the table, then its a rowid alias and is autoincrement // NOTE: Currently commented out because this is not always the desired behavior. For example, a 1:1 relationship with // another table, where the other table is autoincrement, but this one is not, and uses the rowid from the other. // It is safer to only set Autoincrement on tables where we're SURE the user specified AUTOINCREMENT, even if its a rowid column. |
︙ | ︙ |