Skip to content
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

Table-qualified prof tags #33

Open
michaelgmiller opened this issue Jun 7, 2018 · 4 comments
Open

Table-qualified prof tags #33

michaelgmiller opened this issue Jun 7, 2018 · 4 comments

Comments

@michaelgmiller
Copy link

michaelgmiller commented Jun 7, 2018

I have a table schema like:

CREATE TABLE table2 (
  "id" BIGSERIAL PRIMARY KEY,
  "uuid" VARCHAR(36) UNIQUE NOT NULL,
  "column2" VARCHAR(24) NOT NULL
);

CREATE TABLE table1 (
  "id" BIGSERIAL PRIMARY KEY,
  "uuid" VARCHAR(36) UNIQUE NOT NULL,
  "ref" VARCHAR(36) REFERENCES table2(uuid)
);

I'd like to do a query like SELECT * from table1 JOIN table2 ON table1.ref = table2.uuid, and have table2 referenced as a child struct. The problem is that both tables have id and uuid columns. Can I qualify the prof tags so that table2 has a prof tag of prof:"table2.uuid" for example? I know I can use "AS" clauses for each column, but this becomes a maintenance nightmare for any sizable number of queries.

@jonbodner
Copy link
Owner

Hrm, I had started some work so that you could have nested pprof tags; a pprof tag on a named struct field within a struct would work as a prefix for fields within the inner struct with their own pprof tags. There's still some additional work to do to make this functional.

If you have two different fields in the same struct with different pprof tags with different values, I don't see why Proteus wouldn't work right now. All that matters is that there is a column in the result set whose name matches a pprof tag. If that's not working, let me know (a small example is best), and I can see what's going on.

@michaelgmiller
Copy link
Author

michaelgmiller commented Jun 7, 2018

The issue is that with SELECT *, the columns have clashing names in the result set. So in the above query, the result will have table1.uuid and table2.uuid. I'd like to reference the table qualifiers in a prof tag. Should this work? If not, is there any way around this, without renaming every single column by hand?

@michaelgmiller
Copy link
Author

Doing some research, seems that it's not possible to bulk rename columns in the query https://www.postgresql.org/message-id/4CA2A1F3.9000708%40darrenduncan.net - so in the case of joining two tables together with the same columns (for example id or uuid), you have to explicitly enumerate each column with an AS clause, which is kinda painful.

@jonbodner
Copy link
Owner

Let me set up a postgres db and think about what can be done. Unless there are different names, proteus can't assign the values, but maybe there's a different name I can latch on to, or maybe there's a way to specify order information in the columns (which is not my favorite way to access values from a result set)

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

No branches or pull requests

2 participants