mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-11-25 11:29:48 +01:00
Applied latest Black
This commit is contained in:
parent
f045d8559a
commit
c7e5dd6451
2 changed files with 43 additions and 34 deletions
|
|
@ -1773,7 +1773,12 @@ class Table(Queryable):
|
||||||
return pk
|
return pk
|
||||||
|
|
||||||
def m2m(
|
def m2m(
|
||||||
self, other_table, record_or_iterable=None, pk=DEFAULT, lookup=None, m2m_table=None
|
self,
|
||||||
|
other_table,
|
||||||
|
record_or_iterable=None,
|
||||||
|
pk=DEFAULT,
|
||||||
|
lookup=None,
|
||||||
|
m2m_table=None,
|
||||||
):
|
):
|
||||||
if isinstance(other_table, str):
|
if isinstance(other_table, str):
|
||||||
other_table = self.db.table(other_table, pk=pk)
|
other_table = self.db.table(other_table, pk=pk)
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,16 @@ def test_insert_m2m_list(fresh_db):
|
||||||
humans.rows
|
humans.rows
|
||||||
)
|
)
|
||||||
assert [
|
assert [
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
table="dogs_humans", column="dogs_id", other_table="dogs", other_column="id"
|
table="dogs_humans", column="dogs_id", other_table="dogs", other_column="id"
|
||||||
),
|
),
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
table="dogs_humans",
|
table="dogs_humans",
|
||||||
column="humans_id",
|
column="humans_id",
|
||||||
other_table="humans",
|
other_table="humans",
|
||||||
other_column="id",
|
other_column="id",
|
||||||
),
|
),
|
||||||
] == dogs_humans.foreign_keys
|
] == dogs_humans.foreign_keys
|
||||||
|
|
||||||
|
|
||||||
def test_insert_m2m_iterable(fresh_db):
|
def test_insert_m2m_iterable(fresh_db):
|
||||||
|
|
@ -60,23 +60,27 @@ def test_insert_m2m_iterable(fresh_db):
|
||||||
assert {"platypuses", "humans", "humans_platypuses"} == set(fresh_db.table_names())
|
assert {"platypuses", "humans", "humans_platypuses"} == set(fresh_db.table_names())
|
||||||
humans = fresh_db["humans"]
|
humans = fresh_db["humans"]
|
||||||
humans_platypuses = fresh_db["humans_platypuses"]
|
humans_platypuses = fresh_db["humans_platypuses"]
|
||||||
assert [{"humans_id": 1, "platypuses_id": 1}, {"humans_id": 2, "platypuses_id": 1}] == list(
|
assert [
|
||||||
humans_platypuses.rows
|
{"humans_id": 1, "platypuses_id": 1},
|
||||||
)
|
{"humans_id": 2, "platypuses_id": 1},
|
||||||
|
] == list(humans_platypuses.rows)
|
||||||
assert [{"id": 1, "name": "Phineas"}, {"id": 2, "name": "Ferb"}] == list(
|
assert [{"id": 1, "name": "Phineas"}, {"id": 2, "name": "Ferb"}] == list(
|
||||||
humans.rows
|
humans.rows
|
||||||
)
|
)
|
||||||
assert [
|
assert [
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
table="humans_platypuses", column="platypuses_id", other_table="platypuses", other_column="id"
|
table="humans_platypuses",
|
||||||
),
|
column="platypuses_id",
|
||||||
ForeignKey(
|
other_table="platypuses",
|
||||||
table="humans_platypuses",
|
other_column="id",
|
||||||
column="humans_id",
|
),
|
||||||
other_table="humans",
|
ForeignKey(
|
||||||
other_column="id",
|
table="humans_platypuses",
|
||||||
),
|
column="humans_id",
|
||||||
] == humans_platypuses.foreign_keys
|
other_table="humans",
|
||||||
|
other_column="id",
|
||||||
|
),
|
||||||
|
] == humans_platypuses.foreign_keys
|
||||||
|
|
||||||
|
|
||||||
def test_m2m_with_table_objects(fresh_db):
|
def test_m2m_with_table_objects(fresh_db):
|
||||||
|
|
@ -100,16 +104,16 @@ def test_m2m_lookup(fresh_db):
|
||||||
assert people_tags.exists()
|
assert people_tags.exists()
|
||||||
assert tags.exists()
|
assert tags.exists()
|
||||||
assert [
|
assert [
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
table="people_tags",
|
table="people_tags",
|
||||||
column="people_id",
|
column="people_id",
|
||||||
other_table="people",
|
other_table="people",
|
||||||
other_column="id",
|
other_column="id",
|
||||||
),
|
),
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
table="people_tags", column="tags_id", other_table="tags", other_column="id"
|
table="people_tags", column="tags_id", other_table="tags", other_column="id"
|
||||||
),
|
),
|
||||||
] == people_tags.foreign_keys
|
] == people_tags.foreign_keys
|
||||||
assert [{"people_id": 1, "tags_id": 1}] == list(people_tags.rows)
|
assert [{"people_id": 1, "tags_id": 1}] == list(people_tags.rows)
|
||||||
assert [{"id": 1, "name": "Wahyu"}] == list(people.rows)
|
assert [{"id": 1, "name": "Wahyu"}] == list(people.rows)
|
||||||
assert [{"id": 1, "tag": "Coworker"}] == list(tags.rows)
|
assert [{"id": 1, "tag": "Coworker"}] == list(tags.rows)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue