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 optiondiff.stop
. The default stop-after value is3
; set to0
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 onstdin
. 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 usetrue
andfalse
literals in queries. Which, in hindsight, does seem like a bit of an oversight 😳. (Although previously you could usually get away with using1
and0
).$ 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
exits0
when no differences, exits1
if differences are found, and exits2
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.