Skip to content

Go to Definition support #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Go to Definition support #278

wants to merge 24 commits into from

Conversation

worksofliam
Copy link
Contributor

@worksofliam worksofliam commented Sep 18, 2024

Enables Go to Definition and Peek Definition, which under the hood uses GENERATE_SQL.

We are using our legacy formatter for the time being. Formatted issues won't be solved here.

To test

  1. Write an SQL statement: select * from sndbx3.sales
  2. Right click on sndbx3.sales and use either: Go to Definition or Peek -> Definition
  3. A slimmed down statement to create the referenced object should appear

Copy link

github-actions bot commented Sep 18, 2024

👋 A new build is available for this PR based on b690143.

@worksofliam worksofliam self-assigned this Jan 31, 2025
@worksofliam
Copy link
Contributor Author

@julesyan is this another you can take a look at when you have a mo?

@worksofliam worksofliam added this to the Fix day milestone Mar 15, 2025
@julesyan
Copy link
Collaborator

Yes I can test in a couple hours

@forstie
Copy link
Collaborator

forstie commented Mar 16, 2025

When using NAMING *SQL and SET SCHEMA, peek went to the wrong table.

-- Create a table with a polygon column and insert several polygons that represent different New York City Parks
set schema coolstuff;
drop table if exists sample_parks;
CREATE TABLE sample_parks (park_name VARCHAR(50), geometry QSYS2.ST_POLYGON);
INSERT INTO sample_parks (park_name, geometry) VALUES
  ('Central Park', QSYS2.ST_POLYGON('polygon((-73.9817 40.7682, -73.9581 40.8005, -73.9495 40.7968, -73.9732 40.7644, -73.9817 40.7682))')),
  ('Washington Square Park', QSYS2.ST_POLYGON('polygon((-73.9995 40.7310, -73.9986 40.7321, -73.9957 40.7307, -73.9966 40.7297, -73.9995 40.7310))'));

-- Find the maximum and minimum x and y coordinate for various New York City parks
SELECT park_name, 
       QSYS2.ST_MAXX(geometry) AS max_x,
       QSYS2.ST_MAXY(geometry) AS max_y,
       QSYS2.ST_MINX(geometry) AS min_x,
       QSYS2.ST_MINY(geometry) AS min_y
 FROM sample_parks;

image

@worksofliam
Copy link
Contributor Author

To do for me:

  • If system naming is used, use the library list.
  • If SQL naming is used, use the current library/schema.
  • If a qualified name is used, use that

@julesyan
Copy link
Collaborator

Question, when you use peek it opens a whole new file, is there any way to do peek without a new file? Or at least close said file when the peek is closed? Because if i do peek often enough, it is tedious to close a bunch of unsaved files (I did 16 peeks and it was annoying to close)

@worksofliam
Copy link
Contributor Author

@julesyan I checked, but sadly in this particular instance it's not possible to stop the tab from coming up.

It's because the source is temporary because we are generating it from GENERATE_SQL. If the source actually existed on a file system somewhere, then the tab would not show up, but that's not the case here.

@forstie
Copy link
Collaborator

forstie commented Mar 17, 2025

@worksofliam
Peek doesn't handle delimited named schemas or delimited named tables or views.

create schema "annoying";
CREATE TABLE "annoying"."annoyingly123" for system name "annoy1" (park_name VARCHAR(50), geometry QSYS2.ST_POLYGON);
CREATE TABLE qgpl."annoyingly123" for system name "annoy1" (foo integer);

select * from "annoyingly123";
select * from "annoy1";
image

Signed-off-by: worksofliam <[email protected]>
Signed-off-by: worksofliam <[email protected]>
@worksofliam worksofliam modified the milestones: Fix day, 2.0.0, Fix day 2 Apr 16, 2025
@worksofliam worksofliam modified the milestones: Fix day 2, Fix day 1.5 Apr 28, 2025
Copy link
Collaborator

@forstie forstie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retests have gone very well, thank you

@forstie
Copy link
Collaborator

forstie commented Apr 28, 2025

Peek isn't working for this situation:

CREATE SCHEMA "CaMel";
CREATE TABLE "CaMel"."CoWt" (
"cLo" FOR COLUMN CLO__00001 INTEGER DEFAULT NULL )
RCDFMT "CoWt" ;

-- then try to peek on "CoWt"
SELECT * FROM "CaMel"."CoWt"

@forstie
Copy link
Collaborator

forstie commented Apr 28, 2025

also, it seems that peek is using the LIBL list all the time
when I use SQL naming, that doesn't make sense
I would expect the current schema to rule supreme for unqualified tables in a query and SQL naming

@forstie
Copy link
Collaborator

forstie commented Apr 28, 2025

Here's a recreate of the NAMING(*SQL) not working for PEEK.
As the example shows, NAMING(*SQL) works fine for the query.

-- use naming *SQL on your connection
create schema notinlibl;
CREATE TABLE notinlibl.baset(foo integer);
insert into notinlibl.baset values(5);

set schema notinlibl;
select * from baset;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants