1

For whatever reason Sequelize is ignoring ampersands and I'm unable to figure out why. The rest of the query comes out right in the console (Node.Js) but in the where parameter it ignores ampersands and cuts off the rest of the string.

The problem seems to only be the ampersand as the other special characters that I've tried (not many but a few such as .) work fine.

I've also tried a raw query in Sequelize where I put literal SQL code with the ampersand and it results in the same thing. There is also no error (except for MySQL stating said entry doesn't exist which is accurate because Sequelize isn't including the ampersand and cuts off the rest of the string after it)

[Expected] Input: "Stack & Overflow" Output: "Stack & Overflow"

[Reality] Input: "Stack & Overflow" Output: "Stack "

2 Answers2

1

After much debugging and troubleshooting I created an isolated environment. Turns out the problem all along was that I was sending data in a GET request for whatever reason. As a result & was creating separated parameters.

Fixed by sending via POST requests.

I'd imagine URL encoding could've also been a potential fix for this problem.

0

Instead double quotes " you should use single quotes '.

This is based on PostgreSQL behavior. You can read explanation in this answer

Andrew
  • 88
  • 9