Bug with SQL queries
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 595
- Forks
- 101
- Avg merge
- 2h 24m
- Merged PRs (30d)
- 1
Description
This is my stackoverflow question:
https://stackoverflow.com/questions/79067775/sql-select-statement-returning-different-values-when-columns-in-different-order
but investigating this I found that it apparently is a bug because when changed vercel postgresql package to pg, the same query works.
Full problem:
I have a very weird SQL problem. I am creating next.js project and using vercel postgres sql. So when I call
const result = await sql
SELECT isenabled FROM Chatbots WHERE id = ${chatbotId};
;
It returns { isenabled: true } as expected. When I do
SELECT isenabled, cssbubblestyles FROM Chatbots WHERE id = ${chatbotId};
it returns...
{ isenabled: true, cssbubblestyles: '' }
And that's incorrect, because in vercel I clearly see it has value. Also in pgAdmin 4.
When I do:
SELECT isenabled, cssbubblestyles, internalname FROM Chatbots WHERE id = ${chatbotId};
It returns correctly:
{ isenabled: true, cssbubblestyles: '#chatbot-launcher { background-color: #aaabbb; }',
internalname: 'Chatbot' }
Why on earth calling it with just isenabled and cssbubblestyles returns only the first value and null?
What's the best part - when I change the order to cssbubblestyles, isenabled, it returns correct values... Also, when I write just CSSBubbleStyles, or isenAbled, instead of lower case, it also works.
Any ideas?
Working code with pg library:
const result = await pool.query<ChatbotBubbleData>(
SELECT isenabled, cssbubblestyles FROM Chatbots WHERE id = $1,
[chatbotId]
);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Stack Overflow question and compare the Vercel Postgres package behavior with the working pg example. Reproduce the three SELECT variants against the same Chatbots row, then identify whether the discrepancy is in query handling or result mapping; done means a confirmed cause and a focused repository location for the fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100