1111from piccolo .engine .finder import engine_finder
1212from piccolo .schema import SchemaManager
1313from piccolo .table import Table , create_db_tables_sync , drop_db_tables_sync
14- from tests .base import engines_skip
1514
1615engine = engine_finder ()
1716
@@ -85,11 +84,8 @@ def assertEqual(self, first, second, msg=None):
8584 def assertTrue (self , first , msg = None ):
8685 assert first is True
8786
88- @engines_skip ("cockroach" )
8987 def test_select_name (self ):
90- """
91- 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
92- """ # noqa: E501
88+
9389 response = Band .select (
9490 Band .name , Band .genres (Genre .name , as_list = True )
9591 ).run_sync ()
@@ -115,14 +111,10 @@ def test_select_name(self):
115111 ],
116112 )
117113
118- @engines_skip ("cockroach" )
119114 def test_no_related (self ):
120115 """
121116 Make sure it still works correctly if there are no related values.
122117 """
123- """
124- 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
125- """ # noqa: E501
126118
127119 GenreToBand .delete (force = True ).run_sync ()
128120
@@ -153,32 +145,33 @@ def test_no_related(self):
153145 ],
154146 )
155147
156- @engines_skip ("cockroach" )
157148 def test_select_multiple (self ):
158- """
159- 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
160- """ # noqa: E501
161149
162150 response = Band .select (
163151 Band .name , Band .genres (Genre .id , Genre .name )
164152 ).run_sync ()
165153
154+ genres = Genre .select ().run_sync ()
155+
166156 self .assertEqual (
167157 response ,
168158 [
169159 {
170160 "name" : "Pythonistas" ,
171161 "genres" : [
172- {"id" : 1 , "name" : "Rock" },
173- {"id" : 2 , "name" : "Folk" },
162+ {"id" : genres [ 0 ][ "id" ] , "name" : "Rock" },
163+ {"id" : genres [ 1 ][ "id" ] , "name" : "Folk" },
174164 ],
175165 },
176- {"name" : "Rustaceans" , "genres" : [{"id" : 2 , "name" : "Folk" }]},
166+ {
167+ "name" : "Rustaceans" ,
168+ "genres" : [{"id" : genres [1 ]["id" ], "name" : "Folk" }],
169+ },
177170 {
178171 "name" : "C-Sharps" ,
179172 "genres" : [
180- {"id" : 1 , "name" : "Rock" },
181- {"id" : 3 , "name" : "Classical" },
173+ {"id" : genres [ 0 ][ "id" ] , "name" : "Rock" },
174+ {"id" : genres [ 2 ][ "id" ] , "name" : "Classical" },
182175 ],
183176 },
184177 ],
@@ -189,72 +182,76 @@ def test_select_multiple(self):
189182 Genre .name , Genre .bands (Band .id , Band .name )
190183 ).run_sync ()
191184
185+ bands = Band .select ().run_sync ()
186+
192187 self .assertEqual (
193188 response ,
194189 [
195190 {
196191 "name" : "Rock" ,
197192 "bands" : [
198- {"id" : 1 , "name" : "Pythonistas" },
199- {"id" : 3 , "name" : "C-Sharps" },
193+ {"id" : bands [ 0 ][ "id" ] , "name" : "Pythonistas" },
194+ {"id" : bands [ 2 ][ "id" ] , "name" : "C-Sharps" },
200195 ],
201196 },
202197 {
203198 "name" : "Folk" ,
204199 "bands" : [
205- {"id" : 1 , "name" : "Pythonistas" },
206- {"id" : 2 , "name" : "Rustaceans" },
200+ {"id" : bands [ 0 ][ "id" ] , "name" : "Pythonistas" },
201+ {"id" : bands [ 1 ][ "id" ] , "name" : "Rustaceans" },
207202 ],
208203 },
209204 {
210205 "name" : "Classical" ,
211- "bands" : [{"id" : 3 , "name" : "C-Sharps" }],
206+ "bands" : [{"id" : bands [ 2 ][ "id" ] , "name" : "C-Sharps" }],
212207 },
213208 ],
214209 )
215210
216- @engines_skip ("cockroach" )
217211 def test_select_id (self ):
218- """
219- 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
220- """ # noqa: E501
221212
222213 response = Band .select (
223214 Band .name , Band .genres (Genre .id , as_list = True )
224215 ).run_sync ()
216+
217+ genres = Genre .select ().run_sync ()
218+
225219 self .assertEqual (
226220 response ,
227221 [
228- {"name" : "Pythonistas" , "genres" : [1 , 2 ]},
229- {"name" : "Rustaceans" , "genres" : [2 ]},
230- {"name" : "C-Sharps" , "genres" : [1 , 3 ]},
222+ {
223+ "name" : "Pythonistas" ,
224+ "genres" : [genres [0 ]["id" ], genres [1 ]["id" ]],
225+ },
226+ {"name" : "Rustaceans" , "genres" : [genres [1 ]["id" ]]},
227+ {
228+ "name" : "C-Sharps" ,
229+ "genres" : [genres [0 ]["id" ], genres [2 ]["id" ]],
230+ },
231231 ],
232232 )
233233
234234 # Now try it in reverse.
235235 response = Genre .select (
236236 Genre .name , Genre .bands (Band .id , as_list = True )
237237 ).run_sync ()
238+
239+ bands = Band .select ().run_sync ()
240+
238241 self .assertEqual (
239242 response ,
240243 [
241- {"name" : "Rock" , "bands" : [1 , 3 ]},
242- {"name" : "Folk" , "bands" : [1 , 2 ]},
243- {"name" : "Classical" , "bands" : [3 ]},
244+ {"name" : "Rock" , "bands" : [bands [ 0 ][ "id" ], bands [ 2 ][ "id" ] ]},
245+ {"name" : "Folk" , "bands" : [bands [ 0 ][ "id" ], bands [ 1 ][ "id" ] ]},
246+ {"name" : "Classical" , "bands" : [bands [ 2 ][ "id" ] ]},
244247 ],
245248 )
246249
247- @engines_skip ("cockroach" )
248250 def test_select_all_columns (self ):
249251 """
250252 Make sure ``all_columns`` can be passed in as an argument. ``M2M``
251253 should flatten the arguments. Reported here:
252-
253- https://github.com/piccolo-orm/piccolo/issues/728
254-
255- 🐛 Cockroach bug: https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
256-
257- """ # noqa: E501
254+ """
258255
259256 response = Band .select (
260257 Band .name , Band .genres (Genre .all_columns (exclude = (Genre .id ,)))
0 commit comments