Repository navigation
Fix/mysql compatibility - #2769
Mooka-Mooka wants to merge 2 commits into
Conversation
Reviewer's GuideThis PR adds end-to-end MySQL/MariaDB compatibility by generating the correct Prisma client, adapting JSON paths and database-specific SQL, restoring required schema elements, and validating provider behavior through disposable-database integration tests. Sequence diagram for MySQL message and label operationssequenceDiagram
participant Service as ChannelService
participant Repository as PrismaRepository
participant Database as MySQL
Service->>Repository: jsonPath
Repository-->>Service: MySQL JSON path
Service->>Repository: message.findFirst or message.updateMany
Repository->>Database: Provider-compatible JSON query
Database-->>Repository: Message result
Repository-->>Service: Message result
Service->>Repository: $executeRaw for addLabel or removeLabel
Repository->>Database: JSON_ARRAY or JSON_SEARCH update
Database-->>Repository: Write result
Flow diagram for MySQL build and migration validationflowchart TD
Start[Configure MySQL provider and connection] --> Build[npm run build]
Build --> Generate[npm run db:generate]
Generate --> TypeCheck[tsc --noEmit]
TypeCheck --> Bundle[tsup]
Bundle --> Deploy[npm run db:deploy]
Deploy --> Migration[Restore lid and add Label compound unique index]
Migration --> Test[Run mysql-compatibility.test.cjs]
Test --> Disposable[Disposable MariaDB or MySQL database]
Disposable --> Verify[Execute service methods without WhatsApp]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="package.json" line_range="8" />
<code_context>
"type": "commonjs",
"scripts": {
- "build": "tsc --noEmit && tsup",
+"build": "npm run db:generate && tsc --noEmit && tsup",
"start": "tsx ./src/main.ts",
"start:prod": "node dist/main",
</code_context>
<issue_to_address>
**Build provider enables shell commands**
When an attacker can control `DATABASE_PROVIDER` in the build environment, `runWithProvider.js` substitutes `DATABASE_PROVIDER` into the command and passes it to `execSync`; shell metacharacters in a provider value execute attacker-chosen commands during the build, exposing or altering build-worker data.
Validate `DATABASE_PROVIDER` against the supported provider names and invoke Prisma without constructing a shell command from the value.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if a MySQL JSON filter selects the wrong messages, the read-status update can persist incorrect statuses, and label upserts can alter stored chat labels; reverting the code will not restore those values. The migration itself fails on duplicate labels rather than deleting them, but the runtime data changes may need manual repair.
Blocking findings: package.json:8
| "type": "commonjs", | ||
| "scripts": { | ||
| "build": "tsc --noEmit && tsup", | ||
| "build": "npm run db:generate && tsc --noEmit && tsup", |
There was a problem hiding this comment.
🟠 High · Build provider enables shell commands
When an attacker can control DATABASE_PROVIDER in the build environment, runWithProvider.js substitutes DATABASE_PROVIDER into the command and passes it to execSync; shell metacharacters in a provider value execute attacker-chosen commands during the build, exposing or altering build-worker data.
Validate DATABASE_PROVIDER against the supported provider names and invoke Prisma without constructing a shell command from the value.
Prompt for AI agents
In `package.json` at line 8:
**Build provider enables shell commands**
When an attacker can control `DATABASE_PROVIDER` in the build environment, `runWithProvider.js` substitutes `DATABASE_PROVIDER` into the command and passes it to `execSync`; shell metacharacters in a provider value execute attacker-chosen commands during the build, exposing or altering build-worker data.
Validate `DATABASE_PROVIDER` against the supported provider names and invoke Prisma without constructing a shell command from the value.
📋 Description
🔗 Related Issue
Closes #(issue_number)
🧪 Type of Change
🧪 Testing
📸 Screenshots (if applicable)
✅ Checklist
📝 Additional Notes
Summary by Sourcery
Enable reliable MySQL/MariaDB deployments by adding provider-compatible Prisma behavior, schema migrations, service queries, build setup, and compatibility coverage.
New Features:
Bug Fixes:
Enhancements:
Build:
Deployment:
Documentation:
Tests: