6 releases (stable)

new 1.4.0 Apr 15, 2025
1.3.0 Apr 4, 2025
0.1.0 Apr 2, 2025

#651 in Database interfaces

Download history 617/week @ 2025-04-01 47/week @ 2025-04-08

664 downloads per month

MIT license

21KB
460 lines

sql-fingerprint

Documentation Changelog CI Crates.io pre-commit

A SQL fingerprinter.

sql-fingerprint reduces SQL queries to recognizable fingerprints for easier comparison. The goal is to provide readable traces from queries captured during tests, so that changes can be tracked over time.

For example, given a query like:

SELECT name, age /* computed */ FROM cheeses WHERE origin = 'France'

…it will output a fingerprint like:

SELECT ... FROM cheeses WHERE ...

The fingerprinting process applies these changes:

  • Comments are dropped.
  • Whitespace is normalized to a single space.
  • Identifier and value lists are reduced to '...'.
  • Identifiers consisting of letters, numbers, and underscores have any quoting removed.
  • Savepoint IDs are replaced with 's1', 's2', etc.
  • Unparseable SQL is returned unchanged.

Dependencies

~2.5MB
~57K SLoC