Skip to content

fix: reject special characters in DB_DATABASE to prevent reinstall fa… - #405

Merged
navneetkumar-pim-webkul merged 3 commits into
unopim:masterfrom
dripar-webkul:fix/reject-special-chars-in-db-name
May 26, 2026
Merged

navneetkumar-pim-webkul merged 3 commits into
unopim:masterfrom
dripar-webkul:fix/reject-special-chars-in-db-name

Conversation

@dripar-webkul

Copy link
Copy Markdown
Collaborator

Summary

  • Reinstalling with a database name containing a dot (e.g. 1.2.3) fails on migrate:fresh with SQLSTATE[42000] ... near '.\3`.`admin_password_resets`.... Root cause: Laravel's MySQL grammar wraps each dot-separated segment of a qualified identifier in backticks, so 1.2.3.tablenamebecomes ``1.2.3.tablename` `` — parsed as a 4-segment identifier.
  • First install succeeds because CREATE TABLE doesn't qualify the table with the DB name; the bug only surfaces on reinstall when DROP TABLE wk_db.table is generated.
  • Fix validates DB_DATABASE at install time, rejecting anything outside [A-Za-z0-9_]. Same rule already enforced for DB_PREFIX. Users see a clear error instead of a half-installed state that breaks the next install.

Test plan

  • vendor/bin/pest packages/Webkul/Installer/tests/Feature/DatabaseNameValidationTest.php — 3 new tests (rejects 1.2.3, rejects my-db, accepts unopim_v2)
  • vendor/bin/pest --testsuite="Installer Feature Test" — 30 passed (115 assertions), no regressions
  • Manual: entering 1.2.3 at the DB name prompt now shows the validator error; entering unopim works as before.

Closes #862

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents failed reinstalls caused by MySQL identifier-quoting when DB_DATABASE contains special characters (notably dots), by validating the database name during the interactive installer flow and adding coverage for the new behavior.

Changes:

  • Add DB_DATABASE validation in the installer to only allow [A-Za-z0-9_] (trimmed), failing early with a clear validation message.
  • Add Pest feature tests asserting rejection of dotted/dashed DB names and acceptance of an underscore-containing name.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
packages/Webkul/Installer/src/Console/Commands/Installer.php Adds validation/transform logic for DB_DATABASE during unopim:install prompts to block problematic characters.
packages/Webkul/Installer/tests/Feature/DatabaseNameValidationTest.php Introduces feature tests covering invalid/valid DB_DATABASE values during installation.

Comment thread packages/Webkul/Installer/src/Console/Commands/Installer.php Outdated
Comment thread packages/Webkul/Installer/tests/Feature/DatabaseNameValidationTest.php Outdated
Comment thread packages/Webkul/Installer/tests/Feature/DatabaseNameValidationTest.php Outdated
@dripar-webkul
dripar-webkul changed the base branch from master to 2.1 May 25, 2026 12:38
@dripar-webkul
dripar-webkul changed the base branch from 2.1 to master May 25, 2026 13:53
…l-chars-in-db-name

# Conflicts:
#	packages/Webkul/Installer/src/Console/Commands/Installer.php

@dripar-webkul dripar-webkul left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflict fix

@navneetkumar-pim-webkul
navneetkumar-pim-webkul merged commit a88adca into unopim:master May 26, 2026
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.

3 participants