Bug #117722 Forward Engineer - Filter Not Working
Submitted: 17 Mar 3:37 Modified: 13 May 12:45
Reporter: Stan Banash Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:8.0.42 OS:Windows (Microsoft Windows 11 Pro)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[17 Mar 3:37] Stan Banash
Description:
----[For better reports, please attach the log file after submitting. You can find it in C:\Users\sbanash\AppData\Roaming\MySQL\Workbench\log\wb.log]
In the Forward Engineer Database menu dialog. The filter controls (include and exclude) for the tables, routines, view, and trigger are not working. The include shows all the tables but when you select a table and try to move it to the exclude, it shows up in the exclude list but remains in the include list. Also, you can add the same table multiple times to the exclude list.

How to repeat:
1) Open the Database->Forward Engineer Dialog.
2) Navigate to the Select Objects step.
3) Click the show filter button for the tables.
4) Select a table in the include list and the > (move) to move it to the exclude list.
5) Repeat step 4 and the table will be excluded multiple times while still appearing in the include list.
[17 Mar 5:02] MySQL Verification Team
HelloStan Banash,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[13 May 12:45] Stan Banash
This is still occurring in version 8.0.42.
Any updates?
[31 Oct 19:11] Md Asaduzzaman
Hello Stan Banash,
I am also facing the same problem.
[23 Nov 15:19] 승호 한
**Root Cause Identified**

I have analyzed the MySQL Workbench 8.0.44 source code and found the root cause of this bug.

**File:** `backend/wbpublic/grtdb/grt_string_list_model.cpp`
**Function:** `GrtStringListModel::process_mask()`
**Line:** ~280

**Bug:**
```cpp
if (*i && itemsSize < n) {  // ❌ WRONG: condition reversed
```

**Fix:**
```cpp
if (*i && n < itemsSize) {  // ✅ CORRECT: proper bounds check
```

**Explanation:**
The condition `itemsSize < n` is always FALSE since itemsSize (total items) will never be less than n (loop counter). This causes the entire filtering logic to be skipped, leaving items in both include and exclude lists.

**Impact:** 
All filtering operations are broken in Forward Engineer dialog.

**Patch (unified diff):**
```diff
--- a/backend/wbpublic/grtdb/grt_string_list_model.cpp
+++ b/backend/wbpublic/grtdb/grt_string_list_model.cpp
@@ -277,7 +277,7 @@
   size_t n = 0;
   size_t itemsSize = _items.size();
   for (std::vector<bool>::iterator i = items.begin(); i != items.end(); ++i, ++n) {
-    if (*i && itemsSize < n) {
+    if (*i && n < itemsSize) {
       const Item_handler &item = _items[n];
```

This is a simple one-line fix that should resolve the issue completely.

**Testing:**
After applying the fix:
1. Open Forward Engineer dialog
2. Select a table and click ">" to exclude
3. Table should disappear from left list and appear only once in right list

Hope this helps expedite the fix!