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

Warning on missing alias #71

Merged
merged 15 commits into from
Sep 16, 2023
Merged

Warning on missing alias #71

merged 15 commits into from
Sep 16, 2023

Conversation

JasonShin
Copy link
Owner

@JasonShin JasonShin commented Sep 13, 2023

Feature:

Screen Shot 2023-09-13 at 5 27 38 pm

You would get this if you have a query that's like

const sql3 = sql`
SELECT items.id
FROM items
`

TODO

  • Update docs

@nicoabie
Copy link

I believe people will hate the tool if you throw warnings where there are no conflicts.

It would be healthier to error out if two columns clash like

select a.someName, b.someName .... that is definitely an error

@JasonShin
Copy link
Owner Author

JasonShin commented Sep 13, 2023

@nicoabie 🤷‍♂️ that's kind of already happening from the DB level already
If you

SELECT tableA.id, tableB.id
FROM tableA
JOIN tableB ON tableA.id = tableB.tableA_id

You would get clashing column names id, id.

I'm still leaning towards throwing warning and then in V1, make it throw an error but have a configuration to warn only if the user wants.

But you have a good point. I will handle the clashing name problem next

@nicoabie
Copy link

Correct, that sql should rise an error whereas the example you posted that raises a warning should be ok.

Do you see the difference?
People will get annoyed if you always rise warnings and will omit them. Then they will have columns clashing

The only way of really help them is rising an error when columns clash

@JasonShin JasonShin merged commit aab83b4 into main Sep 16, 2023
9 checks passed
@JasonShin JasonShin deleted the warning-on-missing-alias branch September 16, 2023 05:55
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.

2 participants