github neilotoole/sq v0.48.1

latest releases: v0.48.3, v0.48.2
2 months ago

This release features significant improvements to sq diff.

Added

  • Previously sq diff --data diffed every row, which could get crazy with a large table. Now the command stops after N differences, where N is controlled by the --stop (-n) flag, or the new config option diff.stop. The default stop-after value is 3; set to 0 to show all differences.

    # Stop on first difference
    $ sq diff @prod.actor @staging.actor --data --stop 1
    
    # Stop after 5 differences, using the -n shorthand flag
    $ sq diff @prod.actor @staging.actor --data -n5
  • [#353]: The performance of sq diff has been significantly improved. There's still more to do.

  • Previously, sq diff --data compared the rendered (text) representation of each value. This could lead to inaccurate results, for example with two timestamp values in different time zones, but the text rendering omitted the time zone. Now, sq diff --data compares the raw values, not the rendered text. Note in particular with time values that both time and location components are compared.

  • sq can now handle a SQLite DB on stdin. This is useful for testing, or for working with SQLite DBs in a pipeline.

    $ cat sakila.db | sq '.actor | .first_name, .last_name'

    It's also surprisingly handy in daily life, because there are sneaky SQLite DBs all around us. Let's see how many text messages I've sent and received over the years:

    $ cat ~/Library/Messages/chat.db | sq '.message | count'
    count
    215439

    I'm sure that number makes me an amateur with these millenials 👴🏻.

    Note that you'll need to enable macOS Full Disk Access to read the chat.db file.

  • sq now allows you to use true and false literals in queries. Which, in hindsight, does seem like a bit of an oversight 😳. (Although previously you could usually get away with using 1 and 0).

    $ sq '.people | where(.is_alive == false)'
    name        is_alive
    Kubla Khan  false
    
    $ sq '.people | where(.is_alive == true)'
    name         is_alive
    Kaiser Soze  true

Changed

  • ☢️ Previously, sq diff only exited non-zero on an error. Now, sq diff exits 0 when no differences, exits 1 if differences are found, and exits 2 on any error. This aligns with the behavior of GNU diff:

    Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
    
  • Minor fiddling with the color scheme for some command output.

Don't miss a new sq release

NewReleases is sending notifications on new releases.