mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 18:04:32 +02:00
New column_order= parameter for setting column order
This commit is contained in:
parent
72644b6e3f
commit
9eacd30b1d
3 changed files with 96 additions and 15 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from .fixtures import fresh_db
|
||||
from sqlite_utils.db import Index
|
||||
import collections
|
||||
import pytest
|
||||
import json
|
||||
|
||||
|
|
@ -36,6 +37,28 @@ def test_create_table_from_example(fresh_db, example, expected_columns):
|
|||
]
|
||||
|
||||
|
||||
def test_create_table_column_order(fresh_db):
|
||||
fresh_db["table"].insert(
|
||||
collections.OrderedDict(
|
||||
(
|
||||
("zzz", "third"),
|
||||
("abc", "first"),
|
||||
("ccc", "second"),
|
||||
("bbb", "second-to-last"),
|
||||
("aaa", "last"),
|
||||
)
|
||||
),
|
||||
column_order=("abc", "ccc", "zzz"),
|
||||
)
|
||||
assert [
|
||||
{"name": "abc", "type": "TEXT"},
|
||||
{"name": "ccc", "type": "TEXT"},
|
||||
{"name": "zzz", "type": "TEXT"},
|
||||
{"name": "bbb", "type": "TEXT"},
|
||||
{"name": "aaa", "type": "TEXT"},
|
||||
] == [{"name": col.name, "type": col.type} for col in fresh_db["table"].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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue