Skip to content

Feature: add addTableFromClass() and addTablesFromClasses()#150

Merged
usernane merged 1 commit into
mainfrom
dev
May 13, 2026
Merged

Feature: add addTableFromClass() and addTablesFromClasses()#150
usernane merged 1 commit into
mainfrom
dev

Conversation

@usernane

Copy link
Copy Markdown
Member

Summary

Add convenience methods to register tables from a class-string, supporting both attribute-based classes and Table subclasses with automatic engine conversion.

Motivation

Registering attribute-based tables required 3 verbose steps (instantiate builder, get table, add table). This reduces it to a single call. Fixes #138.

Changes

  • Added Database::addTableFromClass(string $className): Table
  • Added Database::addTablesFromClasses(array $classNames): array
  • Fixed missing Column import in TableFactory that broke cross-engine map() conversion
  • Added 17 unit tests covering happy paths, error cases, and engine conversion

How to Test / Verify

Unit tests via PHPUnit:

php vendor/bin/phpunit -c tests/phpunit10.xml --testsuite "Common Tests" --filter "AddTableFromClass"

All 17 tests pass. Full Common and MySQL suites also pass with no regressions.

Breaking Changes and Migration Steps

None

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • The title of the pull request follows Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed)
  • I ran lint/cs-fixer (if applicable)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #138

…thods

Register tables from class-string in a single call. Supports both
attribute-based classes (#[Table]/#[Column]) and Table subclasses
(MySQLTable/MSSQLTable). Automatically converts tables to the
connection engine via TableFactory::map().

Also fixes a bug in TableFactory where the missing Column import
caused cross-engine table conversion to fail with a TypeError.

Closes #138
@usernane usernane changed the title feat(database): add addTableFromClass() and addTablesFromClasses() Feature: add addTableFromClass() and addTablesFromClasses() May 13, 2026
@usernane usernane self-assigned this May 13, 2026
@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.06%. Comparing base (8108546) to head (3f25b82).
⚠️ Report is 34 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #150      +/-   ##
============================================
+ Coverage     74.72%   75.06%   +0.34%     
- Complexity     2167     2174       +7     
============================================
  Files            54       54              
  Lines          5384     5403      +19     
============================================
+ Hits           4023     4056      +33     
+ Misses         1361     1347      -14     
Flag Coverage Δ
php-8.1 75.78% <100.00%> (+0.36%) ⬆️
php-8.2 ?
php-8.3 74.87% <90.00%> (+0.31%) ⬆️
php-8.4 74.87% <90.00%> (+0.31%) ⬆️
php-8.5 74.87% <90.00%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@usernane
usernane merged commit 1dc6be1 into main May 13, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(database): Add addTableFromClass() method to register tables via class-string

1 participant