Skip to content

Commit 6480b73

Browse files
committed
Fix test_shadow snapshot ordering on newer SQLite versions
pragma_table_list does not guarantee row order. Add ORDER BY name to the two shadow table queries so the snapshot is deterministic.
1 parent 05ede81 commit 6480b73

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

tests/__snapshots__/test-general.ambr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
# ---
109109
# name: test_shadow.1
110110
OrderedDict({
111-
'sql': "select * from pragma_table_list where type = 'shadow'",
111+
'sql': "select * from pragma_table_list where type = 'shadow' order by name",
112112
'rows': list([
113113
OrderedDict({
114114
'schema': 'main',
@@ -136,25 +136,25 @@
136136
}),
137137
OrderedDict({
138138
'schema': 'main',
139-
'name': 'v_rowids',
139+
'name': 'v_metadatachunks00',
140140
'type': 'shadow',
141-
'ncol': 4,
141+
'ncol': 2,
142142
'wr': 0,
143143
'strict': 0,
144144
}),
145145
OrderedDict({
146146
'schema': 'main',
147-
'name': 'v_metadatachunks00',
147+
'name': 'v_metadatatext00',
148148
'type': 'shadow',
149149
'ncol': 2,
150150
'wr': 0,
151151
'strict': 0,
152152
}),
153153
OrderedDict({
154154
'schema': 'main',
155-
'name': 'v_metadatatext00',
155+
'name': 'v_rowids',
156156
'type': 'shadow',
157-
'ncol': 2,
157+
'ncol': 4,
158158
'wr': 0,
159159
'strict': 0,
160160
}),
@@ -163,7 +163,7 @@
163163
# ---
164164
# name: test_shadow.2
165165
OrderedDict({
166-
'sql': "select * from pragma_table_list where type = 'shadow'",
166+
'sql': "select * from pragma_table_list where type = 'shadow' order by name",
167167
'rows': list([
168168
]),
169169
})

tests/test-general.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ def test_shadow(db, snapshot):
1313
)
1414
assert exec(db, "select * from sqlite_master order by name") == snapshot()
1515
assert (
16-
exec(db, "select * from pragma_table_list where type = 'shadow'") == snapshot()
16+
exec(db, "select * from pragma_table_list where type = 'shadow' order by name") == snapshot()
1717
)
1818

1919
db.execute("drop table v;")
2020
assert (
21-
exec(db, "select * from pragma_table_list where type = 'shadow'") == snapshot()
21+
exec(db, "select * from pragma_table_list where type = 'shadow' order by name") == snapshot()
2222
)
2323

2424

0 commit comments

Comments
 (0)