fix: Trial Pairing Simulator — correct SQLite string quoting for sex filter #43

Merged
jason merged 1 commits from fix/trial-pairing-sex-quote into master 2026-03-10 14:39:17 -05:00
Owner

Bug

The Trial Pairing Simulator returns no such column: male when clicking Simulate Pairing.

Root Cause

In server/routes/pedigree.js (lines 164–165), the trial-pairing POST handler used double quotes around the string literals "male" and "female" in the SQL queries:

// BROKEN
db.prepare('SELECT * FROM dogs WHERE id = ? AND sex = "male"').get(sire_id);
db.prepare('SELECT * FROM dogs WHERE id = ? AND sex = "female"').get(dam_id);

SQLite follows the SQL standard where double quotes denote identifiers (column/table names), not string values. So SQLite interpreted "male" as a column name, throwing no such column: male.

Fix

Changed to single-quoted string literals, which SQLite correctly treats as values:

// FIXED
db.prepare("SELECT * FROM dogs WHERE id = ? AND sex = 'male'").get(sire_id);
db.prepare("SELECT * FROM dogs WHERE id = ? AND sex = 'female'").get(dam_id);

Files Changed

  • server/routes/pedigree.js — lines 164–165 only
## Bug The Trial Pairing Simulator returns `no such column: male` when clicking **Simulate Pairing**. ## Root Cause In `server/routes/pedigree.js` (lines 164–165), the `trial-pairing` POST handler used **double quotes** around the string literals `"male"` and `"female"` in the SQL queries: ```js // BROKEN db.prepare('SELECT * FROM dogs WHERE id = ? AND sex = "male"').get(sire_id); db.prepare('SELECT * FROM dogs WHERE id = ? AND sex = "female"').get(dam_id); ``` SQLite follows the SQL standard where **double quotes denote identifiers** (column/table names), not string values. So SQLite interpreted `"male"` as a column name, throwing `no such column: male`. ## Fix Changed to single-quoted string literals, which SQLite correctly treats as values: ```js // FIXED db.prepare("SELECT * FROM dogs WHERE id = ? AND sex = 'male'").get(sire_id); db.prepare("SELECT * FROM dogs WHERE id = ? AND sex = 'female'").get(dam_id); ``` ## Files Changed - `server/routes/pedigree.js` — lines 164–165 only
jason added 1 commit 2026-03-10 14:38:33 -05:00
jason merged commit c7c0ec6530 into master 2026-03-10 14:39:17 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jason/breedr#43