sqlite-utils rows now obeys --json-cols

This commit is contained in:
Simon Willison 2019-05-27 17:47:59 -07:00
commit cec8c3c482
2 changed files with 6 additions and 4 deletions

View file

@ -386,6 +386,7 @@ def rows(ctx, path, dbtable, nl, arrays, csv, no_headers, table, fmt, json_cols)
no_headers=no_headers,
table=table,
fmt=fmt,
json_cols=json_cols,
)

View file

@ -496,12 +496,13 @@ def test_query_json_with_json_cols(db_path):
result = CliRunner().invoke(
cli.cli, [db_path, "select id, name, friends from dogs", "--json-cols"]
)
assert (
r"""
expected = r"""
[{"id": 1, "name": "Cleo", "friends": [{"name": "Pancakes"}, {"name": "Bailey"}]}]
""".strip()
== result.output.strip()
)
assert expected == result.output.strip()
# Test rows command too
result_rows = CliRunner().invoke(cli.cli, ["rows", db_path, "dogs", "--json-cols"])
assert expected == result_rows.output.strip()
@pytest.mark.parametrize(