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, no_headers=no_headers,
table=table, table=table,
fmt=fmt, fmt=fmt,
json_cols=json_cols,
) )

View file

@ -496,12 +496,13 @@ def test_query_json_with_json_cols(db_path):
result = CliRunner().invoke( result = CliRunner().invoke(
cli.cli, [db_path, "select id, name, friends from dogs", "--json-cols"] cli.cli, [db_path, "select id, name, friends from dogs", "--json-cols"]
) )
assert ( expected = r"""
r"""
[{"id": 1, "name": "Cleo", "friends": [{"name": "Pancakes"}, {"name": "Bailey"}]}] [{"id": 1, "name": "Cleo", "friends": [{"name": "Pancakes"}, {"name": "Bailey"}]}]
""".strip() """.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( @pytest.mark.parametrize(