Cross-dialect audit
Overview
A cross-dialect audit separates portable SQL intent from engine-specific implementation. Specify the result contract, schema invariants, error behavior, driver type mapping and transaction boundaries. Record evidence per engine, never infer compatibility from a single passing engine.
First example
SELECT o.tenant,SUM(l.qty*l.cents) AS revenue FROM cp_order o JOIN cp_line l ON l.tenant=o.tenant AND l.order_id=o.id WHERE o.status='paid' GROUP BY o.tenant ORDER BY o.tenant;Observed SQLite result (rows in JSON):
[ [ 1, 400 ], [ 2, 900 ]]How it works
The shared paid-revenue query uses a composite join, integer arithmetic and explicit ordering. A second query uses LEFT JOIN and COUNT of a non-null line key to include the cancelled order with zero lines. Compare results and types, then adapt constraints, pagination, plan inspection, roles and backup tools. SQLite PRAGMA and INDEXED BY are not portable. The audit matrix identifies four unexecuted native engines.
Practical example
SELECT o.tenant,o.id,COUNT(l.product_id) FROM cp_order o LEFT JOIN cp_line l ON l.tenant=o.tenant AND l.order_id=o.id GROUP BY o.tenant,o.id ORDER BY o.tenant,o.id;Observed SQLite result (rows in JSON):
[ [ 1, 1, 2 ], [ 1, 2, 0 ], [ 2, 1, 1 ]]Practice and mistakes
Practice: run the shared contract in independently provisioned PostgreSQL, MySQL, SQL Server and Oracle test databases. Hint 1: adapt setup and types explicitly. Hint 2: retain actual rows and version information. Mistake: treating an unexecuted target as passing. Submit the schema, tests, security findings, restore evidence and compatibility report as the capstone portfolio.
PostgreSQL 17 example — NOT RUN
SELECT o.tenant,SUM(l.qty*l.cents) AS revenue FROM cp_order o JOIN cp_line l ON l.tenant=o.tenant AND l.order_id=o.id WHERE o.status='paid' GROUP BY o.tenant ORDER BY o.tenant;Expected result, not executed: "Rows (1,400),(2,900)."