mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 02:14:31 +02:00
--convert function can now modify row in place, closes #371
This commit is contained in:
parent
b8c134059e
commit
22c8d10dd3
5 changed files with 49 additions and 38 deletions
|
|
@ -434,3 +434,22 @@ def test_insert_convert_lines(db_path):
|
|||
db = Database(db_path)
|
||||
rows = list(db.query("select [line] from [all]"))
|
||||
assert rows == [{"line": "THIS IS TEXT"}, {"line": "WILL BE UPPER NOW"}]
|
||||
|
||||
|
||||
def test_insert_convert_row_modifying_in_place(db_path):
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
[
|
||||
"insert",
|
||||
db_path,
|
||||
"rows",
|
||||
"-",
|
||||
"--convert",
|
||||
'row["is_chicken"] = True',
|
||||
],
|
||||
input='{"name": "Azi"}',
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
db = Database(db_path)
|
||||
rows = list(db.query("select name, is_chicken from rows"))
|
||||
assert rows == [{"name": "Azi", "is_chicken": 1}]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue