@@ -1397,4 +1397,284 @@ select id$0 from users;
13971397 β°β΄ β 1. source
13981398 " ) ;
13991399 }
1400+
1401+ #[ test]
1402+ fn goto_select_table_as_column ( ) {
1403+ assert_snapshot ! ( goto( "
1404+ create table t(x bigint, y bigint);
1405+ select t$0 from t;
1406+ " ) , @r"
1407+ ββΈ
1408+ 2 β create table t(x bigint, y bigint);
1409+ β β 2. destination
1410+ 3 β select t from t;
1411+ β°β΄ β 1. source
1412+ " ) ;
1413+ }
1414+
1415+ #[ test]
1416+ fn goto_select_table_as_column_with_schema ( ) {
1417+ assert_snapshot ! ( goto( "
1418+ create table public.t(x bigint, y bigint);
1419+ select t$0 from public.t;
1420+ " ) , @r"
1421+ ββΈ
1422+ 2 β create table public.t(x bigint, y bigint);
1423+ β β 2. destination
1424+ 3 β select t from public.t;
1425+ β°β΄ β 1. source
1426+ " ) ;
1427+ }
1428+
1429+ #[ test]
1430+ fn goto_select_table_as_column_with_search_path ( ) {
1431+ assert_snapshot ! ( goto( "
1432+ set search_path to foo;
1433+ create table foo.users(id int, email text);
1434+ select users$0 from users;
1435+ " ) , @r"
1436+ ββΈ
1437+ 3 β create table foo.users(id int, email text);
1438+ β βββββ 2. destination
1439+ 4 β select users from users;
1440+ β°β΄ β 1. source
1441+ " ) ;
1442+ }
1443+
1444+ #[ test]
1445+ fn goto_select_column_with_same_name_as_table ( ) {
1446+ assert_snapshot ! ( goto( "
1447+ create table t(t int);
1448+ select t$0 from t;
1449+ " ) , @r"
1450+ ββΈ
1451+ 2 β create table t(t int);
1452+ β β 2. destination
1453+ 3 β select t from t;
1454+ β°β΄ β 1. source
1455+ " ) ;
1456+ }
1457+
1458+ #[ test]
1459+ fn goto_drop_schema ( ) {
1460+ assert_snapshot ! ( goto( "
1461+ create schema foo;
1462+ drop schema foo$0;
1463+ " ) , @r"
1464+ ββΈ
1465+ 2 β create schema foo;
1466+ β βββ 2. destination
1467+ 3 β drop schema foo;
1468+ β°β΄ β 1. source
1469+ " ) ;
1470+ }
1471+
1472+ #[ test]
1473+ fn goto_drop_schema_defined_after ( ) {
1474+ assert_snapshot ! ( goto( "
1475+ drop schema foo$0;
1476+ create schema foo;
1477+ " ) , @r"
1478+ ββΈ
1479+ 2 β drop schema foo;
1480+ β β 1. source
1481+ 3 β create schema foo;
1482+ β°β΄ βββ 2. destination
1483+ " ) ;
1484+ }
1485+
1486+ #[ test]
1487+ fn goto_schema_qualifier_in_table ( ) {
1488+ assert_snapshot ! ( goto( "
1489+ create schema foo;
1490+ create table foo$0.t(a int);
1491+ " ) , @r"
1492+ ββΈ
1493+ 2 β create schema foo;
1494+ β βββ 2. destination
1495+ 3 β create table foo.t(a int);
1496+ β°β΄ β 1. source
1497+ " ) ;
1498+ }
1499+
1500+ #[ test]
1501+ fn goto_schema_qualifier_in_drop_table ( ) {
1502+ assert_snapshot ! ( goto( "
1503+ create schema foo;
1504+ create table foo.t(a int);
1505+ drop table foo$0.t;
1506+ " ) , @r"
1507+ ββΈ
1508+ 2 β create schema foo;
1509+ β βββ 2. destination
1510+ 3 β create table foo.t(a int);
1511+ 4 β drop table foo.t;
1512+ β°β΄ β 1. source
1513+ " ) ;
1514+ }
1515+
1516+ #[ test]
1517+ fn goto_schema_qualifier_multiple_schemas ( ) {
1518+ assert_snapshot ! ( goto( "
1519+ create schema foo;
1520+ create schema bar;
1521+ create table bar$0.t(a int);
1522+ " ) , @r"
1523+ ββΈ
1524+ 3 β create schema bar;
1525+ β βββ 2. destination
1526+ 4 β create table bar.t(a int);
1527+ β°β΄ β 1. source
1528+ " ) ;
1529+ }
1530+
1531+ #[ test]
1532+ fn goto_schema_qualifier_in_function_call ( ) {
1533+ assert_snapshot ! ( goto( r#"
1534+ create schema foo;
1535+ create function foo.bar() returns int as $$ begin return 1; end; $$ language plpgsql;
1536+ select foo$0.bar();
1537+ "# ) , @r"
1538+ ββΈ
1539+ 2 β create schema foo;
1540+ β βββ 2. destination
1541+ 3 β create function foo.bar() returns int as $$ begin return 1; end; $$ language plpgsql;
1542+ 4 β select foo.bar();
1543+ β°β΄ β 1. source
1544+ " ) ;
1545+ }
1546+
1547+ #[ test]
1548+ fn goto_schema_qualifier_in_function_call_from_clause ( ) {
1549+ assert_snapshot ! ( goto( r#"
1550+ create schema myschema;
1551+ create function myschema.get_data() returns table(id int) as $$ begin return query select 1; end; $$ language plpgsql;
1552+ select * from myschema$0.get_data();
1553+ "# ) , @r"
1554+ ββΈ
1555+ 2 β create schema myschema;
1556+ β ββββββββ 2. destination
1557+ 3 β create function myschema.get_data() returns table(id int) as $$ begin return query select 1; end; $$ language plpgsql;
1558+ 4 β select * from myschema.get_data();
1559+ β°β΄ β 1. source
1560+ " ) ;
1561+ }
1562+
1563+ #[ test]
1564+ fn goto_schema_qualifier_in_select_from ( ) {
1565+ assert_snapshot ! ( goto( "
1566+ create schema foo;
1567+ create table foo.t(x int);
1568+ select x from foo$0.t;
1569+ " ) , @r"
1570+ ββΈ
1571+ 2 β create schema foo;
1572+ β βββ 2. destination
1573+ 3 β create table foo.t(x int);
1574+ 4 β select x from foo.t;
1575+ β°β΄ β 1. source
1576+ " ) ;
1577+ }
1578+
1579+ #[ test]
1580+ fn goto_qualified_column_table ( ) {
1581+ assert_snapshot ! ( goto( "
1582+ create table t(a int);
1583+ select t$0.a from t;
1584+ " ) , @r"
1585+ ββΈ
1586+ 2 β create table t(a int);
1587+ β β 2. destination
1588+ 3 β select t.a from t;
1589+ β°β΄ β 1. source
1590+ " ) ;
1591+ }
1592+
1593+ #[ test]
1594+ fn goto_qualified_column_column ( ) {
1595+ assert_snapshot ! ( goto( "
1596+ create table t(a int);
1597+ select t.a$0 from t;
1598+ " ) , @r"
1599+ ββΈ
1600+ 2 β create table t(a int);
1601+ β β 2. destination
1602+ 3 β select t.a from t;
1603+ β°β΄ β 1. source
1604+ " ) ;
1605+ }
1606+
1607+ #[ test]
1608+ fn goto_three_part_qualified_column_schema ( ) {
1609+ assert_snapshot ! ( goto( "
1610+ create schema foo;
1611+ create table foo.t(a int);
1612+ select foo$0.t.a from t;
1613+ " ) , @r"
1614+ ββΈ
1615+ 2 β create schema foo;
1616+ β βββ 2. destination
1617+ 3 β create table foo.t(a int);
1618+ 4 β select foo.t.a from t;
1619+ β°β΄ β 1. source
1620+ " ) ;
1621+ }
1622+
1623+ #[ test]
1624+ fn goto_three_part_qualified_column_table ( ) {
1625+ assert_snapshot ! ( goto( "
1626+ create schema foo;
1627+ create table foo.t(a int);
1628+ select foo.t$0.a from t;
1629+ " ) , @r"
1630+ ββΈ
1631+ 3 β create table foo.t(a int);
1632+ β β 2. destination
1633+ 4 β select foo.t.a from t;
1634+ β°β΄ β 1. source
1635+ " ) ;
1636+ }
1637+
1638+ #[ test]
1639+ fn goto_three_part_qualified_column_column ( ) {
1640+ assert_snapshot ! ( goto( "
1641+ create schema foo;
1642+ create table foo.t(a int);
1643+ select foo.t.a$0 from t;
1644+ " ) , @r"
1645+ ββΈ
1646+ 3 β create table foo.t(a int);
1647+ β β 2. destination
1648+ 4 β select foo.t.a from t;
1649+ β°β΄ β 1. source
1650+ " ) ;
1651+ }
1652+
1653+ #[ test]
1654+ fn goto_qualified_column_with_schema_in_from_table ( ) {
1655+ assert_snapshot ! ( goto( "
1656+ create table foo.t(a int, b int);
1657+ select t$0.a from foo.t;
1658+ " ) , @r"
1659+ ββΈ
1660+ 2 β create table foo.t(a int, b int);
1661+ β β 2. destination
1662+ 3 β select t.a from foo.t;
1663+ β°β΄ β 1. source
1664+ " ) ;
1665+ }
1666+
1667+ #[ test]
1668+ fn goto_qualified_column_with_schema_in_from_column ( ) {
1669+ assert_snapshot ! ( goto( "
1670+ create table foo.t(a int, b int);
1671+ select t.a$0 from foo.t;
1672+ " ) , @r"
1673+ ββΈ
1674+ 2 β create table foo.t(a int, b int);
1675+ β β 2. destination
1676+ 3 β select t.a from foo.t;
1677+ β°β΄ β 1. source
1678+ " ) ;
1679+ }
14001680}
0 commit comments