table.m2m(..., m2m_table=x) argument

This commit is contained in:
Simon Willison 2019-08-03 20:51:22 +03:00
commit b6b92980c0
2 changed files with 13 additions and 7 deletions

View file

@ -74,9 +74,14 @@ def test_m2m_requires_either_records_or_lookup(fresh_db):
people.m2m("tags", {"tag": "hello"}, lookup={"foo": "bar"})
def test_m2m_explicit_argument(fresh_db):
# .m2m("humans", ..., m2m_table="relationships")
assert False
def test_m2m_explicit_table_name_argument(fresh_db):
people = fresh_db.table("people", pk="id")
people.insert({"name": "Wahyu"}).m2m(
"tags", lookup={"tag": "Coworker"}, m2m_table="tagged"
)
assert fresh_db["tags"].exists
assert fresh_db["tagged"].exists
assert not fresh_db["people_tags"].exists
def test_uses_existing_m2m_table_if_exists(fresh_db):