Skip to content

Conversation

@dereuromark
Copy link
Member

@dereuromark dereuromark commented Jan 11, 2026

Summary

  • Adds descriptive error messages for composite unique constraints in generated buildRules() methods
  • Messages are wrapped in __() for i18n support
  • Only applied to multi-column unique constraints (single-column constraints unchanged)

Before

$rules->add($rules->isUnique(['field_1', 'field_2']), ['errorField' => 'field_1']);

After

$rules->add($rules->isUnique(['field_1', 'field_2']), ['errorField' => 'field_1', 'message' => __('This combination of field_1 and field_2 already exists')]);

Additional fixes included

  • Fix schema.php: use int for length fields instead of strings (was causing bootstrap errors)
  • Fix EntryCommandTest to work with both old and new CakePHP help output formats
  • Fix testGetEntityPropertySchema to handle PostgreSQL returning timestampfractional instead of timestamp
  • Add plugin classes for all test plugins to fix CakePHP 5.3.0 deprecation warnings
  • Update composer.json autoload-dev to include all test plugin namespaces
  • Add ignore rules for generic type PHPStan errors from CakePHP 5.3.0
  • Fix writeFile method name casing in ModelCommand (was writefile)

Test plan

  • All existing model bake tests pass
  • Tests verify composite unique constraints get descriptive messages
  • Single-column unique constraints remain unaffected
  • Works on MySQL, PostgreSQL, and SQLite
  • Works with both CakePHP "lowest" and "highest" dependency versions

When baking models with composite unique constraints (multiple columns),
the generated buildRules() now includes a descriptive error message that
explains which fields must be unique together.

Before:
$rules->add($rules->isUnique(['field_1', 'field_2']), ['errorField' => 'field_1']);

After:
$rules->add($rules->isUnique(['field_1', 'field_2']), ['errorField' => 'field_1', 'message' => __('This combination of field_1 and field_2 already exists')]);

This improves user experience by providing clearer validation messages
for composite unique constraints.
- Update EntryCommandTest to match new CakePHP help output format
  (changed from 'Available Commands' to 'bake:')
- Add plugin classes for all test plugins to fix CakePHP 5.3.0
  deprecation warnings about loading plugins without a plugin class
- Update composer.json autoload-dev to include all test plugin namespaces
@dereuromark dereuromark marked this pull request as ready for review January 11, 2026 04:24
@markstory markstory merged commit c8dc9c6 into 3.x Jan 12, 2026
9 checks passed
@markstory markstory deleted the composite-unique-messages branch January 12, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants