Skip to content

fix(db): store wordpress results in postgres and mysql - #2747

Merged
Mzack9999 merged 1 commit into
devfrom
fix/db-wordpress-column
Nov 19, 2026
Merged

Mzack9999 merged 1 commit into
devfrom
fix/db-wordpress-column

Conversation

@dogancanbakir

@dogancanbakir dogancanbakir commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Fixes #2746

Adds the wordpress column to the postgres and mysql writers, with an upgrade path for existing tables.
New test fails when a Result field has no DB column, so this cannot regress like #2487.

Summary by CodeRabbit

  • New Features
    • Stored WordPress data alongside scan results in PostgreSQL and MySQL databases, including when updating existing database tables.
  • Tests
    • Added coverage to verify that database writers save every result field consistently.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PostgreSQL and MySQL writers now store each result’s WordPress data in a JSON column. The schema setup adds that column when needed. A test checks that both writers include every runner.Result field in their schemas and inserts.

Changes

SQL result persistence

Layer / File(s) Summary
WordPress schema and insert support
internal/db/postgres.go, internal/db/mysql.go, internal/db/columns_test.go
Both writers add a WordPress JSON column to new and existing schemas, marshal each result’s WordPress data, and include it in inserts. The test checks schema and insert columns against runner.Result fields and verifies the insert argument count.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: mzack9999, msecrfe

Merge Risk: Minimal · up to 8a82b

The change adds a wordpress JSON column to the PostgreSQL and MySQL writers and upgrades existing tables, so WordPress results are kept when using -rdb. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the PR adds a wordpress column so PostgreSQL and MySQL writers store wordpress results instead of dropping them under -rdb. The title uses the fix(db) prefix and match…
Linked Issues check Passed Issue #2746 requires that the PostgreSQL and MySQL writers store -wp (WordPress) results, which are currently dropped because these writers have no wordpress column. The diff against the merge bas…
Out of Scope Changes check Passed All changes support issue #2746:
- postgres.go and mysql.go: the wordpress column, its upgrade path for existing tables, and its insert handling. These are the core of the requested behavior.
- colu…
Full details: Title check

Explanation

The title names the main change: the PR adds a wordpress column so PostgreSQL and MySQL writers store wordpress results instead of dropping them under -rdb. The title uses the fix(db) prefix and matches the objectives (issue #2746 and PR #2747) and the file summaries for postgres.go and mysql.go. The title does not mention the added test, which is a secondary change and is acceptable.

Full details: Linked Issues check

Explanation

Issue #2746 requires that the PostgreSQL and MySQL writers store -wp (WordPress) results, which are currently dropped because these writers have no wordpress column. The diff against the merge base implements this:

  • internal/db/postgres.go: EnsureSchema adds wordpress JSONB to new tables and runs ALTER TABLE ... ADD COLUMN IF NOT EXISTS wordpress JSONB for existing tables. InsertBatch adds wordpress to the column list, adds a sixth placeholder $65, marshals r.WordPress to JSON, and passes it to ExecContext.
  • internal/db/mysql.go: EnsureSchema adds wordpress JSON to new tables and calls ensureColumn(ctx, "wordpress", "JSON") for existing tables, wrapping errors. InsertBatch adds wordpress with a matching ? placeholder and passes the marshaled JSON.
    Placeholder counts and argument order match the column lists in both writers. The new test TestSQLWritersStoreEveryResultField (internal/db/columns_test.go, per the summary) checks that each Result JSON field has an insert column. I did not read the test file, so its behavior rests on the summary. Mongo needs no change, as the issue states. No coding requirement is unmet.
Full details: Out of Scope Changes check

Explanation

All changes support issue #2746:

  • postgres.go and mysql.go: the wordpress column, its upgrade path for existing tables, and its insert handling. These are the core of the requested behavior.
  • columns_test.go: a test-only SQL recorder and TestSQLWritersStoreEveryResultField. It verifies that the writers store every Result field, including wordpress. This supports the objective and the regression guard described in the PR description.
    No unrelated files or behavior changes appear in the summary. I did not inspect columns_test.go directly, so this verdict relies on the summary for that file.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the rows in flight
WordPress JSON fits in right
PostgreSQL stores each leafy byte
MySQL keeps the columns tight
The test hops through each field tonight

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: b0ee7acd-2053-4b89-9687-d142a9cb3b32
Commits

Reviewing files that changed from the base of the PR and between 2226531 and 8a82bd5.

Files selected for processing: 3

  • internal/db/columns_test.go
  • internal/db/mysql.go
  • internal/db/postgres.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@Mzack9999
Mzack9999 merged commit 402fd34 into dev Nov 19, 2026
12 checks passed
@Mzack9999
Mzack9999 deleted the fix/db-wordpress-column branch November 19, 2026 16:55
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.

-wp results are not stored in postgres and mysql

2 participants