DbLib: Use case-insensitive lookup for column caching

This commit is contained in:
Jon Evans 2025-01-02 12:54:52 -05:00
parent 48bb6b137c
commit bdb2c3a025
2 changed files with 19 additions and 12 deletions

View File

@ -18,6 +18,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <boost/algorithm/string.hpp>
#include <boost/locale.hpp> #include <boost/locale.hpp>
#include <fmt/core.h> #include <fmt/core.h>
#include <nanodbc/nanodbc.h> #include <nanodbc/nanodbc.h>
@ -236,7 +237,7 @@ bool DATABASE_CONNECTION::CacheTableInfo( const std::string& aTable,
{ {
std::string columnKey = toUTF8( columns.column_name() ); std::string columnKey = toUTF8( columns.column_name() );
if( aColumns.count( columnKey ) ) if( aColumns.count( boost::to_lower_copy( columnKey ) ) )
m_columnCache[key][columnKey] = columns.data_type(); m_columnCache[key][columnKey] = columns.data_type();
} }
@ -627,7 +628,13 @@ bool DATABASE_CONNECTION::selectAllAndCache( const std::string& aTable, const st
} }
} }
wxASSERT( result.count( aKey ) ); if( !result.count( aKey ) )
{
wxLogTrace( traceDatabase,
wxT( "selectAllAndCache: warning: key %s not found in result set" ), aKey );
continue;
}
std::string keyStr = std::any_cast<std::string>( result.at( aKey ) ); std::string keyStr = std::any_cast<std::string>( result.at( aKey ) );
cacheEntry[keyStr] = result; cacheEntry[keyStr] = result;
} }

View File

@ -343,19 +343,19 @@ void SCH_IO_DATABASE::connect()
{ {
std::set<std::string> columns; std::set<std::string> columns;
columns.insert( tableIter.key_col ); columns.insert( boost::to_lower_copy( tableIter.key_col ) );
columns.insert( tableIter.footprints_col ); columns.insert( boost::to_lower_copy( tableIter.footprints_col ) );
columns.insert( tableIter.symbols_col ); columns.insert( boost::to_lower_copy( tableIter.symbols_col ) );
columns.insert( tableIter.properties.description ); columns.insert( boost::to_lower_copy( tableIter.properties.description ) );
columns.insert( tableIter.properties.footprint_filters ); columns.insert( boost::to_lower_copy( tableIter.properties.footprint_filters ) );
columns.insert( tableIter.properties.keywords ); columns.insert( boost::to_lower_copy( tableIter.properties.keywords ) );
columns.insert( tableIter.properties.exclude_from_sim ); columns.insert( boost::to_lower_copy( tableIter.properties.exclude_from_sim ) );
columns.insert( tableIter.properties.exclude_from_bom ); columns.insert( boost::to_lower_copy( tableIter.properties.exclude_from_bom ) );
columns.insert( tableIter.properties.exclude_from_board ); columns.insert( boost::to_lower_copy( tableIter.properties.exclude_from_board ) );
for( const DATABASE_FIELD_MAPPING& field : tableIter.fields ) for( const DATABASE_FIELD_MAPPING& field : tableIter.fields )
columns.insert( field.column ); columns.insert( boost::to_lower_copy( field.column ) );
m_conn->CacheTableInfo( tableIter.table, columns ); m_conn->CacheTableInfo( tableIter.table, columns );
} }