filter only tables with rows

This commit is contained in:
SPRINX0\prochazka
2025-09-25 09:23:52 +02:00
parent 6747280964
commit 9d77cac4bb
3 changed files with 14 additions and 1 deletions

View File

@@ -4,7 +4,17 @@
export const extractKey = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName); export const extractKey = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName);
export const createMatcher = export const createMatcher =
(filter, cfg = DEFAULT_OBJECT_SEARCH_SETTINGS) => (filter, cfg = DEFAULT_OBJECT_SEARCH_SETTINGS) =>
({ schemaName, pureName, objectComment, tableEngine, columns, objectTypeField, tableName, createSql }) => { ({
schemaName,
pureName,
objectComment,
tableEngine,
columns,
objectTypeField,
tableName,
createSql,
tableRowCount,
}) => {
const mainArgs = []; const mainArgs = [];
const childArgs = []; const childArgs = [];
if (cfg.schemaName) mainArgs.push(schemaName); if (cfg.schemaName) mainArgs.push(schemaName);
@@ -12,6 +22,7 @@
if (objectTypeField == 'tables') { if (objectTypeField == 'tables') {
if (cfg.tableComment) mainArgs.push(objectComment); if (cfg.tableComment) mainArgs.push(objectComment);
if (cfg.tableEngine) mainArgs.push(tableEngine); if (cfg.tableEngine) mainArgs.push(tableEngine);
if (cfg.tablesWithRows && !tableRowCount) return 'none';
for (const column of columns || []) { for (const column of columns || []) {
if (cfg.columnName) childArgs.push(column.columnName); if (cfg.columnName) childArgs.push(column.columnName);

View File

@@ -195,6 +195,7 @@ export const DEFAULT_OBJECT_SEARCH_SETTINGS = {
columnComment: false, columnComment: false,
sqlObjectText: false, sqlObjectText: false,
tableEngine: false, tableEngine: false,
tablesWithRows: false,
}; };
export const DEFAULT_CONNECTION_SEARCH_SETTINGS = { export const DEFAULT_CONNECTION_SEARCH_SETTINGS = {

View File

@@ -143,6 +143,7 @@
res.push({ label: 'Column comment', switchValue: 'columnComment' }); res.push({ label: 'Column comment', switchValue: 'columnComment' });
res.push({ label: 'View/procedure/trigger text', switchValue: 'sqlObjectText' }); res.push({ label: 'View/procedure/trigger text', switchValue: 'sqlObjectText' });
res.push({ label: 'Table engine', switchValue: 'tableEngine' }); res.push({ label: 'Table engine', switchValue: 'tableEngine' });
res.push({ label: 'Only tables with rows', switchValue: 'tablesWithRows' });
} }
return res.map(item => ({ return res.map(item => ({
...item, ...item,