@@ -266,6 +266,127 @@ public function test_extracting_with_duplicate_key_values_and_tiebreaker() : voi
266266 );
267267 }
268268
269+ public function test_extraction_when_key_is_ambiguous_column () : void
270+ {
271+ $ this ->pgsqlDatabaseContext ->createTable (
272+ to_dbal_schema_table (
273+ schema (
274+ int_schema ('id ' , metadata: DbalMetadata::primaryKey ()),
275+ str_schema ('name ' , metadata: DbalMetadata::length (255 )),
276+ ),
277+ $ table = 'flow_key_set_extractor_test_01 ' ,
278+ )
279+ );
280+
281+ $ this ->pgsqlDatabaseContext ->createTable (
282+ to_dbal_schema_table (
283+ schema (
284+ int_schema ('id ' , metadata: DbalMetadata::primaryKey ()),
285+ int_schema ('id_01 ' ),
286+ str_schema ('name ' , metadata: DbalMetadata::length (255 )),
287+ ),
288+ 'flow_key_set_extractor_test_02 ' ,
289+ )
290+ );
291+
292+ for ($ i = 1 ; $ i <= 25 ; $ i ++) {
293+ $ this ->pgsqlDatabaseContext ->insert ($ table , ['id ' => $ i , 'name ' => 'name_ ' . $ i ]);
294+
295+ $ this ->pgsqlDatabaseContext ->insert ('flow_key_set_extractor_test_02 ' , ['id ' => $ i , 'id_01 ' => $ i , 'name ' => 'name_ ' . $ i ]);
296+ }
297+
298+ $ rows = data_frame ()
299+ ->extract (
300+ from_dbal_key_set_qb (
301+ $ this ->pgsqlDatabaseContext ->connection (),
302+ $ this ->pgsqlDatabaseContext ->connection ()->createQueryBuilder ()
303+ ->from ($ table )
304+ ->select ('flow_key_set_extractor_test_01.id as id ' )
305+ ->leftJoin (
306+ 'flow_key_set_extractor_test_01 ' ,
307+ 'flow_key_set_extractor_test_02 ' ,
308+ 'flow_key_set_extractor_test_02 ' ,
309+ 'flow_key_set_extractor_test_01.id = flow_key_set_extractor_test_02.id_01 '
310+ ),
311+ pagination_key_set (pagination_key_desc ('flow_key_set_extractor_test_01.id ' ))
312+ )
313+ ->withSchema (schema (int_schema ('id ' )))
314+ ->withPageSize (5 )
315+ ->withMaximum (5 )
316+ )
317+ ->fetch ()
318+ ->toArray ();
319+
320+ self ::assertSame ([
321+ ['id ' => 25 ],
322+ ['id ' => 24 ],
323+ ['id ' => 23 ],
324+ ['id ' => 22 ],
325+ ['id ' => 21 ],
326+ ], $ rows );
327+ }
328+
329+ public function test_extraction_when_key_is_ambiguous_column_with_custom_key_column_alias_suffix () : void
330+ {
331+ $ this ->pgsqlDatabaseContext ->createTable (
332+ to_dbal_schema_table (
333+ schema (
334+ int_schema ('id ' , metadata: DbalMetadata::primaryKey ()),
335+ str_schema ('name ' , metadata: DbalMetadata::length (255 )),
336+ ),
337+ $ table = 'flow_key_set_extractor_test_01 ' ,
338+ )
339+ );
340+
341+ $ this ->pgsqlDatabaseContext ->createTable (
342+ to_dbal_schema_table (
343+ schema (
344+ int_schema ('id ' , metadata: DbalMetadata::primaryKey ()),
345+ int_schema ('id_01 ' ),
346+ str_schema ('name ' , metadata: DbalMetadata::length (255 )),
347+ ),
348+ 'flow_key_set_extractor_test_02 ' ,
349+ )
350+ );
351+
352+ for ($ i = 1 ; $ i <= 25 ; $ i ++) {
353+ $ this ->pgsqlDatabaseContext ->insert ($ table , ['id ' => $ i , 'name ' => 'name_ ' . $ i ]);
354+
355+ $ this ->pgsqlDatabaseContext ->insert ('flow_key_set_extractor_test_02 ' , ['id ' => $ i , 'id_01 ' => $ i , 'name ' => 'name_ ' . $ i ]);
356+ }
357+
358+ $ rows = data_frame ()
359+ ->extract (
360+ from_dbal_key_set_qb (
361+ $ this ->pgsqlDatabaseContext ->connection (),
362+ $ this ->pgsqlDatabaseContext ->connection ()->createQueryBuilder ()
363+ ->from ($ table )
364+ ->select ('flow_key_set_extractor_test_01.id as id ' )
365+ ->leftJoin (
366+ 'flow_key_set_extractor_test_01 ' ,
367+ 'flow_key_set_extractor_test_02 ' ,
368+ 'flow_key_set_extractor_test_02 ' ,
369+ 'flow_key_set_extractor_test_01.id = flow_key_set_extractor_test_02.id_01 '
370+ ),
371+ pagination_key_set (pagination_key_desc ('flow_key_set_extractor_test_01.id ' ))
372+ )
373+ ->withKeyAliasSuffix ('_something_custom ' )
374+ ->withSchema (schema (int_schema ('id ' )))
375+ ->withPageSize (5 )
376+ ->withMaximum (5 )
377+ )
378+ ->fetch ()
379+ ->toArray ();
380+
381+ self ::assertSame ([
382+ ['id ' => 25 ],
383+ ['id ' => 24 ],
384+ ['id ' => 23 ],
385+ ['id ' => 22 ],
386+ ['id ' => 21 ],
387+ ], $ rows );
388+ }
389+
269390 public function test_throws_exception_for_empty_key_set () : void
270391 {
271392 $ this ->pgsqlDatabaseContext ->createTable (
0 commit comments