🧪 Quality assurance

Testing Methodology

137 end-to-end tests validate every generated SQL query matches Prisma's output exactly

137
E2E tests
Every query validated
100%
Parity coverage
Byte-for-byte match
2
Database engines
PostgreSQL & SQLite
3
ORM benchmarks
Prisma v6/v7, Drizzle

हम correctness कैसे validate करते हैं

हर test एक rigorous 5-step validation process follow करता है ताकि generated SQL Prisma के समान results दे

1

Prisma query से SQL generate करें

Prisma query arguments parse करें और वही models व schema उपयोग करके equivalent SQL generate करें। Generated SQL security और performance के लिए parameterized queries उपयोग करता है।

2

दोनों queries parallel में execute करें

Generated SQL को postgres.js या better-sqlite3 से direct चलाएँ और वही query Prisma के जरिए चलाएँ। दोनों same database state hit करती हैं।

3

Results normalize करें

Type differences (BigInt vs Number, Decimal precision, Date serialization) handle करें और fair comparison के लिए object key ordering normalize करें।

4

Deep equality check

Results बिल्कुल match हों: rows की संख्या, field values, nested relations, ordering। कोई mismatch हो तो test fail।

5

Performance benchmark

5 warmup runs के साथ execution time measure करें, फिर हर test पर 10-50 iterations average करें। Prisma v6, Prisma v7 और Drizzle ORM के खिलाफ compare करें।

Advanced validation techniques

Data type normalization

  • BigInt conversion: JavaScript BigInt → Number for comparison
  • Decimal handling: Prisma Decimal → Float with 10-digit precision
  • Date normalization: All DateTime values → null (focus on data, not timestamps)
  • JSON parsing: Automatic detection and parsing of JSON strings
  • Object key sorting: Alphabetical ordering for consistent comparison

Performance benchmarking

  • Warmup phase: 5 iterations to prime caches and JIT
  • Adaptive iterations: 5-50 runs based on query complexity
  • Isolated measurement: Each query type measured independently
  • Multi-ORM comparison: Prisma v6, v7, Drizzle, Generated SQL
  • SQL generation time: Separate timing for query generation overhead

Comprehensive test coverage

Tests cover every Prisma read operation across multiple complexity levels

Query operations

  • findMany with complex filters
  • findFirst with skip & pagination
  • findUnique by ID & unique fields
  • count with WHERE conditions
  • aggregate (sum, avg, min, max)
  • groupBy with HAVING clauses

Complex scenarios

  • Nested includes (4 levels deep)
  • Relation filters (some/every/none)
  • Distinct with window functions
  • Cursor pagination
  • Select + include combined
  • Relation counts (_count)

Filter types

  • Comparison (lt/lte/gt/gte)
  • Logical (AND/OR/NOT)
  • String ops (contains/startsWith)
  • NULL checks (is/isNot)
  • IN/NOT IN arrays
  • Case sensitivity modes

PostgreSQL testing

  • ✓ ILIKE case-insensitive searches
  • ✓ JSON/JSONB operations
  • ✓ Array field handling
  • ✓ Composite type support
  • ✓ Window function validation
  • ✓ Transaction isolation testing

SQLite testing

  • ✓ LIKE pattern matching
  • ✓ JSON1 extension validation
  • ✓ Window function emulation
  • ✓ DISTINCT optimization
  • ✓ Subquery correlation
  • ✓ Text affinity handling

Example test case

देखें हम relation filters के साथ complex nested query कैसे validate करते हैं

tests/e2e/postgres.test.ts
it('nested relation filter', () =>
  runParityTest(
    db,
    benchmarkResults,
    'findMany nested relation',
    'Organization',
    {
      method: 'findMany',
      where: {
        projects: {
          some: {
            tasks: { some: { status: 'DONE' } }
          }
        }
      }
    },
    () => db.prisma.organization.findMany({
      where: {
        projects: {
          some: {
            tasks: { some: { status: 'DONE' } }
          }
        }
      },
      orderBy: { id: 'asc' }
    }),
  )
)

// runParityTest internally:
// 1. Calls generateSQL() with the args
// 2. Executes generated SQL directly
// 3. Executes Prisma query
// 4. Normalizes both results
// 5. Deep equality check - fails if any difference
// 6. Benchmarks execution time

Test execution के दौरान क्या होता है

1. Query generation (microseconds)

generateSQL() Prisma args parse करके parameterized SQL बनाता है। इस step को अलग से benchmark किया जाता है ताकि query generation overhead मापा जा सके।

2. Parallel execution (milliseconds)

दोनों queries Promise.all() से एक साथ same database state hit करती हैं, ताकि fair comparison और identical data conditions रहें।

3. Deep normalization

Results recursive normalization से गुजरते हैं: BigInt→Number, Decimal→Float(10), Date→null, JSON parse, key sorting। इससे byte-for-byte comparison accuracy सुनिश्चित होती है।

4. Strict equality

Zero tolerance के साथ JSON stringify comparison। rows, field values, nested objects या ordering में कोई mismatch हो तो detailed diff output के साथ fail।

5. Performance measurement

Validation के बाद, 5-50 iterations average execution time measure करते हैं। Results में शामिल: Prisma v6, Prisma v7, Drizzle ORM, Generated SQL, और SQL generation overhead।

Multi-version validation

हर test Prisma v6 और v7 दोनों पर चलता है ताकि versions के बीच compatibility रहे:

Prisma v6 (6.16.3)

  • • Direct PrismaClient usage
  • • Legacy engine architecture
  • • Baseline performance metrics

Prisma v7 (7.2.0)

  • • Adapter-based architecture
  • • @prisma/adapter-pg & adapter-better-sqlite3
  • • New engine optimizations

Automated benchmark reports

सभी benchmark results अपने आप generate होकर JSON files के रूप में store होते हैं ताकि पूरी transparency रहे:

benchmark-results/v6-postgres-latest.json
benchmark-results/v7-postgres-latest.json
benchmark-results/v6-sqlite-latest.json
benchmark-results/v7-sqlite-latest.json

हर file में: test name, Prisma execution time, generated SQL time, Drizzle time, speedup ratios, और ISO timestamp।

Full test suite explore करें

137 tests open source हैं। Test code, benchmarks, और validation logic review करें।