diff --git a/tests/fixtures.py b/tests/fixtures.py
index 0539b7c8..5f65566f 100644
--- a/tests/fixtures.py
+++ b/tests/fixtures.py
@@ -404,7 +404,7 @@ METADATA = {
TABLES = (
"""
CREATE TABLE simple_primary_key (
- id varchar(30) primary key,
+ id integer primary key,
content text
);
@@ -441,8 +441,8 @@ CREATE INDEX idx_compound_three_primary_keys_content ON compound_three_primary_k
CREATE TABLE foreign_key_references (
pk varchar(30) primary key,
- foreign_key_with_label varchar(30),
- foreign_key_with_blank_label varchar(30),
+ foreign_key_with_label integer,
+ foreign_key_with_blank_label integer,
foreign_key_with_no_label varchar(30),
foreign_key_compound_pk1 varchar(30),
foreign_key_compound_pk2 varchar(30),
@@ -492,9 +492,9 @@ CREATE TABLE "table/with/slashes.csv" (
CREATE TABLE "complex_foreign_keys" (
pk varchar(30) primary key,
- f1 text,
- f2 text,
- f3 text,
+ f1 integer,
+ f2 integer,
+ f3 integer,
FOREIGN KEY ("f1") REFERENCES [simple_primary_key](id),
FOREIGN KEY ("f2") REFERENCES [simple_primary_key](id),
FOREIGN KEY ("f3") REFERENCES [simple_primary_key](id)
diff --git a/tests/test_api.py b/tests/test_api.py
index 91f07563..6f7cf0c5 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -708,7 +708,7 @@ async def test_invalid_custom_sql(ds_client):
async def test_row(ds_client):
response = await ds_client.get("/fixtures/simple_primary_key/1.json?_shape=objects")
assert response.status_code == 200
- assert response.json()["rows"] == [{"id": "1", "content": "hello"}]
+ assert response.json()["rows"] == [{"id": 1, "content": "hello"}]
@pytest.mark.asyncio
diff --git a/tests/test_csv.py b/tests/test_csv.py
index f6d2a6b2..b4a71169 100644
--- a/tests/test_csv.py
+++ b/tests/test_csv.py
@@ -99,7 +99,19 @@ async def test_table_csv_with_nullable_labels(ds_client):
@pytest.mark.asyncio
async def test_table_csv_with_invalid_labels():
# https://github.com/simonw/datasette/issues/2214
- ds = Datasette()
+ ds = Datasette(
+ config={
+ "databases": {
+ "db_2214": {
+ "tables": {
+ "t2": {
+ "label_column": "name",
+ }
+ }
+ }
+ }
+ }
+ )
await ds.invoke_startup()
db = ds.add_memory_database("db_2214")
await db.execute_write_script(
diff --git a/tests/test_html.py b/tests/test_html.py
index 3fd5f1f5..7ff6295d 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -355,7 +355,7 @@ async def test_row_html_simple_primary_key(ds_client):
assert ["id", "content"] == [th.string.strip() for th in table.select("thead th")]
assert [
[
- '
1 | ',
+ '1 | ',
'hello | ',
]
] == [[str(td) for td in tr.select("td")] for tr in table.select("tbody tr")]
diff --git a/tests/test_plugins.py b/tests/test_plugins.py
index 639e6677..93575ffa 100644
--- a/tests/test_plugins.py
+++ b/tests/test_plugins.py
@@ -194,7 +194,7 @@ async def test_hook_render_cell_demo(ds_client):
soup = Soup(response.text, "html.parser")
td = soup.find("td", {"class": "col-content"})
assert json.loads(td.string) == {
- "row": {"id": "4", "content": "RENDER_CELL_DEMO"},
+ "row": {"id": 4, "content": "RENDER_CELL_DEMO"},
"column": "content",
"table": "simple_primary_key",
"database": "fixtures",
diff --git a/tests/test_table_api.py b/tests/test_table_api.py
index 615b36eb..0b722519 100644
--- a/tests/test_table_api.py
+++ b/tests/test_table_api.py
@@ -24,11 +24,11 @@ async def test_table_json(ds_client):
)
assert data["query"]["params"] == {}
assert data["rows"] == [
- {"id": "1", "content": "hello"},
- {"id": "2", "content": "world"},
- {"id": "3", "content": ""},
- {"id": "4", "content": "RENDER_CELL_DEMO"},
- {"id": "5", "content": "RENDER_CELL_ASYNC"},
+ {"id": 1, "content": "hello"},
+ {"id": 2, "content": "world"},
+ {"id": 3, "content": ""},
+ {"id": 4, "content": "RENDER_CELL_DEMO"},
+ {"id": 5, "content": "RENDER_CELL_ASYNC"},
]
@@ -46,11 +46,11 @@ async def test_table_not_exists_json(ds_client):
async def test_table_shape_arrays(ds_client):
response = await ds_client.get("/fixtures/simple_primary_key.json?_shape=arrays")
assert response.json()["rows"] == [
- ["1", "hello"],
- ["2", "world"],
- ["3", ""],
- ["4", "RENDER_CELL_DEMO"],
- ["5", "RENDER_CELL_ASYNC"],
+ [1, "hello"],
+ [2, "world"],
+ [3, ""],
+ [4, "RENDER_CELL_DEMO"],
+ [5, "RENDER_CELL_ASYNC"],
]
@@ -78,11 +78,11 @@ async def test_table_shape_arrayfirst(ds_client):
async def test_table_shape_objects(ds_client):
response = await ds_client.get("/fixtures/simple_primary_key.json?_shape=objects")
assert response.json()["rows"] == [
- {"id": "1", "content": "hello"},
- {"id": "2", "content": "world"},
- {"id": "3", "content": ""},
- {"id": "4", "content": "RENDER_CELL_DEMO"},
- {"id": "5", "content": "RENDER_CELL_ASYNC"},
+ {"id": 1, "content": "hello"},
+ {"id": 2, "content": "world"},
+ {"id": 3, "content": ""},
+ {"id": 4, "content": "RENDER_CELL_DEMO"},
+ {"id": 5, "content": "RENDER_CELL_ASYNC"},
]
@@ -90,11 +90,11 @@ async def test_table_shape_objects(ds_client):
async def test_table_shape_array(ds_client):
response = await ds_client.get("/fixtures/simple_primary_key.json?_shape=array")
assert response.json() == [
- {"id": "1", "content": "hello"},
- {"id": "2", "content": "world"},
- {"id": "3", "content": ""},
- {"id": "4", "content": "RENDER_CELL_DEMO"},
- {"id": "5", "content": "RENDER_CELL_ASYNC"},
+ {"id": 1, "content": "hello"},
+ {"id": 2, "content": "world"},
+ {"id": 3, "content": ""},
+ {"id": 4, "content": "RENDER_CELL_DEMO"},
+ {"id": 5, "content": "RENDER_CELL_ASYNC"},
]
@@ -106,11 +106,11 @@ async def test_table_shape_array_nl(ds_client):
lines = response.text.split("\n")
results = [json.loads(line) for line in lines]
assert [
- {"id": "1", "content": "hello"},
- {"id": "2", "content": "world"},
- {"id": "3", "content": ""},
- {"id": "4", "content": "RENDER_CELL_DEMO"},
- {"id": "5", "content": "RENDER_CELL_ASYNC"},
+ {"id": 1, "content": "hello"},
+ {"id": 2, "content": "world"},
+ {"id": 3, "content": ""},
+ {"id": 4, "content": "RENDER_CELL_DEMO"},
+ {"id": 5, "content": "RENDER_CELL_ASYNC"},
] == results
@@ -129,11 +129,11 @@ async def test_table_shape_invalid(ds_client):
async def test_table_shape_object(ds_client):
response = await ds_client.get("/fixtures/simple_primary_key.json?_shape=object")
assert response.json() == {
- "1": {"id": "1", "content": "hello"},
- "2": {"id": "2", "content": "world"},
- "3": {"id": "3", "content": ""},
- "4": {"id": "4", "content": "RENDER_CELL_DEMO"},
- "5": {"id": "5", "content": "RENDER_CELL_ASYNC"},
+ "1": {"id": 1, "content": "hello"},
+ "2": {"id": 2, "content": "world"},
+ "3": {"id": 3, "content": ""},
+ "4": {"id": 4, "content": "RENDER_CELL_DEMO"},
+ "5": {"id": 5, "content": "RENDER_CELL_ASYNC"},
}
@@ -522,27 +522,27 @@ async def test_searchable_invalid_column(ds_client):
[
(
"/fixtures/simple_primary_key.json?_shape=arrays&content=hello",
- [["1", "hello"]],
+ [[1, "hello"]],
),
(
"/fixtures/simple_primary_key.json?_shape=arrays&content__contains=o",
[
- ["1", "hello"],
- ["2", "world"],
- ["4", "RENDER_CELL_DEMO"],
+ [1, "hello"],
+ [2, "world"],
+ [4, "RENDER_CELL_DEMO"],
],
),
(
"/fixtures/simple_primary_key.json?_shape=arrays&content__exact=",
- [["3", ""]],
+ [[3, ""]],
),
(
"/fixtures/simple_primary_key.json?_shape=arrays&content__not=world",
[
- ["1", "hello"],
- ["3", ""],
- ["4", "RENDER_CELL_DEMO"],
- ["5", "RENDER_CELL_ASYNC"],
+ [1, "hello"],
+ [3, ""],
+ [4, "RENDER_CELL_DEMO"],
+ [5, "RENDER_CELL_ASYNC"],
],
),
],
@@ -558,9 +558,9 @@ async def test_table_filter_queries_multiple_of_same_type(ds_client):
"/fixtures/simple_primary_key.json?_shape=arrays&content__not=world&content__not=hello"
)
assert [
- ["3", ""],
- ["4", "RENDER_CELL_DEMO"],
- ["5", "RENDER_CELL_ASYNC"],
+ [3, ""],
+ [4, "RENDER_CELL_DEMO"],
+ [5, "RENDER_CELL_ASYNC"],
] == response.json()["rows"]
@@ -1100,8 +1100,8 @@ async def test_expand_label(ds_client):
assert response.json() == {
"1": {
"pk": "1",
- "foreign_key_with_label": {"value": "1", "label": "hello"},
- "foreign_key_with_blank_label": "3",
+ "foreign_key_with_label": {"value": 1, "label": "hello"},
+ "foreign_key_with_blank_label": 3,
"foreign_key_with_no_label": "1",
"foreign_key_compound_pk1": "a",
"foreign_key_compound_pk2": "b",
@@ -1163,8 +1163,8 @@ async def test_null_and_compound_foreign_keys_are_not_expanded(ds_client):
assert response.json() == [
{
"pk": "1",
- "foreign_key_with_label": {"value": "1", "label": "hello"},
- "foreign_key_with_blank_label": {"value": "3", "label": ""},
+ "foreign_key_with_label": {"value": 1, "label": "hello"},
+ "foreign_key_with_blank_label": {"value": 3, "label": ""},
"foreign_key_with_no_label": {"value": "1", "label": "1"},
"foreign_key_compound_pk1": "a",
"foreign_key_compound_pk2": "b",
diff --git a/tests/test_table_html.py b/tests/test_table_html.py
index b7c52e01..0b152d54 100644
--- a/tests/test_table_html.py
+++ b/tests/test_table_html.py
@@ -615,8 +615,8 @@ async def test_table_html_foreign_key_links(ds_client):
assert actual == [
[
'1 | ',
- 'hello\xa01 | ',
- '-\xa03 | ',
+ 'hello\xa01 | ',
+ '-\xa03 | ',
'1 | ',
'a | ',
'b | ',
@@ -655,8 +655,8 @@ async def test_table_html_disable_foreign_key_links_with_labels(ds_client):
assert actual == [
[
'1 | ',
- '1 | ',
- '3 | ',
+ '1 | ',
+ '3 | ',
'1 | ',
'a | ',
'b | ',