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

View columns made by EXTRACT cannot be used in Query Tool. #7446

Closed
DaniWe opened this issue May 3, 2024 · 3 comments
Closed

View columns made by EXTRACT cannot be used in Query Tool. #7446

DaniWe opened this issue May 3, 2024 · 3 comments
Assignees

Comments

@DaniWe
Copy link

DaniWe commented May 3, 2024

Have a view with Year, Month and/or Day as numeric view columns defined as:
EXTRACT(year FROM f.recorddate::timestamp without time zone) AS "Year",
EXTRACT(month FROM f.recorddate::timestamp without time zone) AS "Month",
EXTRACT(day FROM f.recorddate::timestamp without time zone) AS "Day",

Execute a simple query:
SELECT * FROM service.yxney_fuelrecord WHERE Year>2022

Result:

ERROR: column "year" does not exist
LINE 7: SELECT * FROM service.yxney_fuelrecord WHERE Year>2022
^
HINT: Perhaps you meant to reference the column "yxney_fuelrecord.Year".

SQL state: 42703
Character: 407

No other alternatives work either, like:
SELECT * FROM service.yxney_fuelrecord WHERE yxney_fuelrecord .Year>2022
SELECT * FROM service.yxney_fuelrecord WHERE service.yxney_fuelrecord.Month=6
SELECT * FROM service.yxney_fuelrecord ORDER BY Day;

The Query Tool colors Year, Month and Day as if they are reserved keywords and refuse to acknowledge them as columns no matter what. Cannot be used anywhere in a query, even if prefixed.

Year-Month-Day-fails

pgAdmin 7.8 on Windows 11.

@DaniWe DaniWe changed the title Year, Month and Day cannot be used as column names in Query Tool. View columns made by EXTRACT cannot be used in Query Tool. May 3, 2024
@adityatoshniwal
Copy link
Contributor

Hi @DaniWe,
What is the behaviour when you run it from psql tool?

@DaniWe
Copy link
Author

DaniWe commented May 13, 2024 via email

@adityatoshniwal
Copy link
Contributor

Hi @DaniWe,
If its the same behaviour with PSQL then Query tool is working fine. You'll probably need to fix the SQL you're using.
You can take help from pgsql-admin@postgresql.org
I'm closing this issue.
Thanks.

@adityatoshniwal adityatoshniwal closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
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