@@ -457,6 +457,209 @@ drop type int4_range$0;
457457 " ) ;
458458 }
459459
460+ #[ test]
461+ fn goto_drop_view ( ) {
462+ assert_snapshot ! ( goto( "
463+ create view v as select 1;
464+ drop view v$0;
465+ " ) , @r"
466+ ββΈ
467+ 2 β create view v as select 1;
468+ β β 2. destination
469+ 3 β drop view v;
470+ β°β΄ β 1. source
471+ " ) ;
472+ }
473+
474+ #[ test]
475+ fn goto_drop_view_with_schema ( ) {
476+ assert_snapshot ! ( goto( "
477+ create view public.v as select 1;
478+ drop view v$0;
479+ " ) , @r"
480+ ββΈ
481+ 2 β create view public.v as select 1;
482+ β β 2. destination
483+ 3 β drop view v;
484+ β°β΄ β 1. source
485+ " ) ;
486+
487+ assert_snapshot ! ( goto( "
488+ create view foo.v as select 1;
489+ drop view foo.v$0;
490+ " ) , @r"
491+ ββΈ
492+ 2 β create view foo.v as select 1;
493+ β β 2. destination
494+ 3 β drop view foo.v;
495+ β°β΄ β 1. source
496+ " ) ;
497+
498+ goto_not_found (
499+ "
500+ create view v as select 1;
501+ drop view foo.v$0;
502+ " ,
503+ ) ;
504+ }
505+
506+ #[ test]
507+ fn goto_drop_temp_view ( ) {
508+ assert_snapshot ! ( goto( "
509+ create temp view v as select 1;
510+ drop view v$0;
511+ " ) , @r"
512+ ββΈ
513+ 2 β create temp view v as select 1;
514+ β β 2. destination
515+ 3 β drop view v;
516+ β°β΄ β 1. source
517+ " ) ;
518+ }
519+
520+ #[ test]
521+ fn goto_select_from_view ( ) {
522+ assert_snapshot ! ( goto( "
523+ create view v as select 1;
524+ select * from v$0;
525+ " ) , @r"
526+ ββΈ
527+ 2 β create view v as select 1;
528+ β β 2. destination
529+ 3 β select * from v;
530+ β°β΄ β 1. source
531+ " ) ;
532+ }
533+
534+ #[ test]
535+ fn goto_select_from_view_with_schema ( ) {
536+ assert_snapshot ! ( goto( "
537+ create view public.v as select 1;
538+ select * from public.v$0;
539+ " ) , @r"
540+ ββΈ
541+ 2 β create view public.v as select 1;
542+ β β 2. destination
543+ 3 β select * from public.v;
544+ β°β΄ β 1. source
545+ " ) ;
546+ }
547+
548+ #[ test]
549+ fn goto_view_column ( ) {
550+ assert_snapshot ! ( goto( "
551+ create view v as select 1 as a;
552+ select a$0 from v;
553+ " ) , @r"
554+ ββΈ
555+ 2 β create view v as select 1 as a;
556+ β β 2. destination
557+ 3 β select a from v;
558+ β°β΄ β 1. source
559+ " ) ;
560+ }
561+
562+ #[ test]
563+ fn goto_view_column_qualified ( ) {
564+ assert_snapshot ! ( goto( "
565+ create view v as select 1 as a;
566+ select v.a$0 from v;
567+ " ) , @r"
568+ ββΈ
569+ 2 β create view v as select 1 as a;
570+ β β 2. destination
571+ 3 β select v.a from v;
572+ β°β΄ β 1. source
573+ " ) ;
574+ }
575+
576+ #[ test]
577+ fn goto_view_with_explicit_column_list ( ) {
578+ assert_snapshot ! ( goto( "
579+ create view v(col1) as select 1;
580+ select * from v$0;
581+ " ) , @r"
582+ ββΈ
583+ 2 β create view v(col1) as select 1;
584+ β β 2. destination
585+ 3 β select * from v;
586+ β°β΄ β 1. source
587+ " ) ;
588+ }
589+
590+ #[ test]
591+ fn goto_view_column_with_explicit_column_list ( ) {
592+ assert_snapshot ! ( goto( "
593+ create view v(col1) as select 1;
594+ select col1$0 from v;
595+ " ) , @r"
596+ ββΈ
597+ 2 β create view v(col1) as select 1;
598+ β ββββ 2. destination
599+ 3 β select col1 from v;
600+ β°β΄ β 1. source
601+ " ) ;
602+ }
603+
604+ #[ test]
605+ fn goto_view_column_with_schema ( ) {
606+ assert_snapshot ! ( goto( "
607+ create view public.v as select 1 as a;
608+ select a$0 from public.v;
609+ " ) , @r"
610+ ββΈ
611+ 2 β create view public.v as select 1 as a;
612+ β β 2. destination
613+ 3 β select a from public.v;
614+ β°β΄ β 1. source
615+ " ) ;
616+ }
617+
618+ #[ test]
619+ fn goto_view_multiple_columns ( ) {
620+ assert_snapshot ! ( goto( "
621+ create view v as select 1 as a, 2 as b;
622+ select b$0 from v;
623+ " ) , @r"
624+ ββΈ
625+ 2 β create view v as select 1 as a, 2 as b;
626+ β β 2. destination
627+ 3 β select b from v;
628+ β°β΄ β 1. source
629+ " ) ;
630+ }
631+
632+ #[ test]
633+ fn goto_view_column_from_table ( ) {
634+ assert_snapshot ! ( goto( "
635+ create table t(x int, y int);
636+ create view v as select x, y from t;
637+ select x$0 from v;
638+ " ) , @r"
639+ ββΈ
640+ 3 β create view v as select x, y from t;
641+ β β 2. destination
642+ 4 β select x from v;
643+ β°β΄ β 1. source
644+ " ) ;
645+ }
646+
647+ #[ test]
648+ fn goto_view_column_with_table_preference ( ) {
649+ assert_snapshot ! ( goto( "
650+ create table v(a int);
651+ create view vw as select 1 as a;
652+ select a$0 from v;
653+ " ) , @r"
654+ ββΈ
655+ 2 β create table v(a int);
656+ β β 2. destination
657+ 3 β create view vw as select 1 as a;
658+ 4 β select a from v;
659+ β°β΄ β 1. source
660+ " ) ;
661+ }
662+
460663 #[ test]
461664 fn goto_cast_operator ( ) {
462665 assert_snapshot ! ( goto( "
0 commit comments