Invental/Review lessons/Tests that can never fail

Tests that can never fail

Fix the SQL dialect bug in every dialect

When one SQL dialect breaks on user input, check every dialect that builds the same string by hand: the bug is in the shared pattern, not the one driver someone tested.

01 · Before and afterThe pattern

One tokenizer for every dialect instead of string concatenation per driver.

TypeScript
// before (in several dialect files): const jsonPath = '$' + userPath;
export function toJsonPath(userPath: string): string {
  return tokenize(userPath)                     // e.g. lodash toPath
    .filter((part) => part !== '')              // ".a..b." → ["a","b"]
    .reduce((acc, part) => /^\d+$/.test(part) ? `${acc}[${part}]` : `${acc}.${part}`, '$');
}

02 · Run it on your appThe check

If your app supports more than one database, does every dialect run the same input-normalisation code, with tests that run on each one?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.