[PR #5878] [MERGED] DB: Updated entity scope to use models dynamic table #6589

Closed
opened 2026-02-05 10:36:13 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/5878
Author: @ssddanbrown
Created: 11/10/2025
Status: Merged
Merged: 11/11/2025
Merged by: @ssddanbrown

Base: developmentHead: fix_5877


📝 Commits (3)

  • 4eb4407 DB: Updated entity scope to use models dynamic table
  • befc645 DB: Added initial DB testing docker-based script
  • 8ab9252 DB: Added extra query tests, updated db-testing scripts

📊 Changes

6 files changed (+140 additions, -5 deletions)

View changed files

📝 app/Entities/Models/Book.php (+1 -2)
📝 app/Entities/Models/EntityScope.php (+4 -3)
dev/docker/db-testing/Dockerfile (+30 -0)
dev/docker/db-testing/run.sh (+57 -0)
tests/Entity/EntityQueryTest.php (+44 -0)
📝 tests/Uploads/ImageTest.php (+4 -0)

📄 Description

This was hardcoded since the table was always the same, but in some cases Laravel will auto-alias the table name (for example, when in sub-queries) which will break MySQL 5.7 when the scope attempts to use the table name instead of the alias.

Needs testing coverage.
For #5877

Todo

  • Full testing against supported major MySQL/MariaDB versions.
    • MySQL 5.7
    • MySQL 8.0
    • MySQL 8.4
    • MySQL 9.5
    • MariaDB 10.2
    • MariaDB 10.6
    • MariaDB 10.11
    • MariaDB 11.4
    • MariaDB 11.8
    • MariaDB 12.0
  • Coverage of this scenario in test cases if possible (Start a query and inspect it?)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/5878 **Author:** [@ssddanbrown](https://github.com/ssddanbrown) **Created:** 11/10/2025 **Status:** ✅ Merged **Merged:** 11/11/2025 **Merged by:** [@ssddanbrown](https://github.com/ssddanbrown) **Base:** `development` ← **Head:** `fix_5877` --- ### 📝 Commits (3) - [`4eb4407`](https://github.com/BookStackApp/BookStack/commit/4eb4407ef76cac144e4149e7b2ba461b168d3a3b) DB: Updated entity scope to use models dynamic table - [`befc645`](https://github.com/BookStackApp/BookStack/commit/befc6457051c914d3b0328d60d2e9e50ee2594ca) DB: Added initial DB testing docker-based script - [`8ab9252`](https://github.com/BookStackApp/BookStack/commit/8ab9252f9bd1626b87df044b14ce3469b1ca07bf) DB: Added extra query tests, updated db-testing scripts ### 📊 Changes **6 files changed** (+140 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `app/Entities/Models/Book.php` (+1 -2) 📝 `app/Entities/Models/EntityScope.php` (+4 -3) ➕ `dev/docker/db-testing/Dockerfile` (+30 -0) ➕ `dev/docker/db-testing/run.sh` (+57 -0) ➕ `tests/Entity/EntityQueryTest.php` (+44 -0) 📝 `tests/Uploads/ImageTest.php` (+4 -0) </details> ### 📄 Description This was hardcoded since the table was always the same, but in some cases Laravel will auto-alias the table name (for example, when in sub-queries) which will break MySQL 5.7 when the scope attempts to use the table name instead of the alias. Needs testing coverage. For #5877 ### Todo - [ ] Full testing against supported major MySQL/MariaDB versions. - [ ] MySQL 5.7 - [ ] MySQL 8.0 - [ ] MySQL 8.4 - [ ] MySQL 9.5 - [ ] MariaDB 10.2 - [ ] MariaDB 10.6 - [ ] MariaDB 10.11 - [ ] MariaDB 11.4 - [ ] MariaDB 11.8 - [ ] MariaDB 12.0 - [ ] Coverage of this scenario in test cases if possible (Start a query and inspect it?) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:36:13 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#6589