mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Create table now works for pure m2m where both rows are foreign keys
This commit is contained in:
parent
56e29158fe
commit
acea54877c
2 changed files with 46 additions and 27 deletions
|
|
@ -38,3 +38,19 @@ def test_create_table_from_example(fresh_db, example, expected_columns):
|
|||
assert expected_columns == [
|
||||
{"name": col.name, "type": col.type} for col in fresh_db["people"].columns
|
||||
]
|
||||
|
||||
|
||||
def test_create_table_works_for_m2m_with_only_foreign_keys(fresh_db):
|
||||
fresh_db["one"].insert({"id": 1}, pk="id")
|
||||
fresh_db["two"].insert({"id": 1}, pk="id")
|
||||
fresh_db["m2m"].insert(
|
||||
{"one_id": 1, "two_id": 1},
|
||||
foreign_keys=(
|
||||
("one_id", "INTEGER", "one", "id"),
|
||||
("two_id", "INTEGER", "two", "id"),
|
||||
),
|
||||
)
|
||||
assert [
|
||||
{"name": "one_id", "type": "INTEGER"},
|
||||
{"name": "two_id", "type": "INTEGER"},
|
||||
] == [{"name": col.name, "type": col.type} for col in fresh_db["m2m"].columns]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue