Add globally unique keys option to database libs

This commit is contained in:
Matthew Campbell
2025-12-22 13:24:37 +00:00
committed by Jeff Young
parent c1a98c7dd5
commit d101e6bb19
3 changed files with 8 additions and 2 deletions
@@ -143,6 +143,8 @@ DATABASE_LIB_SETTINGS::DATABASE_LIB_SETTINGS( const std::string& aFilename ) :
m_params.emplace_back( new PARAM<int>( "cache.max_age", &m_Cache.max_age, 10 ) );
m_params.emplace_back( new PARAM<bool>( "globally_unique_keys", &m_GloballyUniqueKeys, false ) );
registerMigration( 0, 1,
[&]() -> bool
{
+4 -2
View File
@@ -137,7 +137,8 @@ LIB_SYMBOL* SCH_IO_DATABASE::LoadSymbol( const wxString& aLibraryPath,
for( const DATABASE_LIB_TABLE& tableIter : m_settings->m_Tables )
{
if( tableIter.name == tableName )
// no table means globally unique keys, try all tables
if( tableName.empty() || tableIter.name == tableName )
tablesToTry.emplace_back( &tableIter );
}
@@ -255,7 +256,8 @@ void SCH_IO_DATABASE::cacheLib()
std::string rawName = std::any_cast<std::string>( result[table.key_col] );
UTF8 sanitizedName = LIB_ID::FixIllegalChars( rawName, false );
std::string sanitizedKey = sanitizedName.c_str();
std::string prefix = table.name.empty() ? "" : fmt::format( "{}/", table.name );
std::string prefix =
( m_settings->m_GloballyUniqueKeys || table.name.empty() ) ? "" : fmt::format( "{}/", table.name );
std::string sanitizedDisplayName = fmt::format( "{}{}", prefix, sanitizedKey );
wxString name( sanitizedDisplayName );
+2
View File
@@ -116,6 +116,8 @@ public:
DATABASE_CACHE_SETTINGS m_Cache;
bool m_GloballyUniqueKeys;
protected:
wxString getFileExt() const override;
};