mine-prisma-sql-index-risks
Read-only mining codemod that reports possible missing-index risks in JavaScript and TypeScript source.
What It Detects
- Prisma object-literal queries on
findMany,findFirst, andfindUnique - Embedded SQL in string literals, template literals, and SQL-tagged or Prisma raw-query templates
The codemod emits warning findings with rule id possible-missing-db-index and does not modify source files.
Prisma Findings
Flags Prisma calls when either condition is present:
wherecombined withorderBy- nested
containsinsidewhere
When available, findings include:
- model name
- operation name
- predicate fields from
where - order fields from
orderBy - source location
- a compact query summary
Example:
ts
Embedded SQL Findings
Flags embedded SQL when either condition is present:
WHEREtogether withORDER BY- leading-wildcard
LIKE '%...'orILIKE '%...'
When available, findings include:
- table name from
FROM ... - obvious predicate columns from
WHERE - obvious sort columns from
ORDER BY - whether leading-wildcard matching was detected
- source location
Example:
ts
Suppressions
The codemod skips obvious test and mock paths:
__tests__testtestsfixtures__mocks__mocks- files ending in
.test.*or.spec.*
Usage
bash
Development
bash
Test Coverage
Fixtures cover:
- Prisma
findManywithwhereandorderBy - Prisma
findFirstwithcontains - Prisma
findUniquewithwhereandorderBy orderByarrays- embedded SQL strings with
WHERE ... ORDER BY - embedded SQL strings with leading-wildcard
LIKE - tagged template and Prisma raw-query usage
- suppressed test and mock paths
- no source rewrites for mining-only runs
License
MIT