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

Bug with SQL queries #774

Open
Arputikos opened this issue Oct 8, 2024 · 0 comments
Open

Bug with SQL queries #774

Arputikos opened this issue Oct 8, 2024 · 0 comments

Comments

@Arputikos
Copy link

Arputikos commented Oct 8, 2024

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 sqlSELECT 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] );

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

1 participant