large sql query causes error when line breaks removed

I have a very large and complex MySQL query that gets run from a Node.JS process, but I am getting a strange error.

The query is about 150 lines of SQL code, so I'm not going to include it, but I know it's good. It is written in the JS source code as a variable with \ at the end of the each line to continue the string. If I copy the SQL from the source and remove the \s it runs perfectly. However, when I run it through the app, I get the dreaded:

MySQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

'' anywhere in the huge single line that is my query - thanks MySQL.

When I get the app to output the SQL to the screen and I copy and paste that, I get the same error in MySQL. I decided to run the 2 queries (source when \ removed and the output) through diff, and the only difference is the line breaks - the source has line breaks, and the output doesn't. I should also note, that simpler queries in this app do work, so there's something in this query causing this.

What possible change could be happening to the MySQL query when the line breaks are removed? Is there some limit of lines or spaces that I am unaware of? My understanding is that MySQL ignores all line breaks and whitespace. Is this not true? Could someone point me in the right direction to trouble shoot this?

There were some comments that I removed, there were some blank lines that I removed, I converted the tabs to spaces.. I'm out of ideas.

Thanks,

whiteatom

Missed a comment in the query. I was using the -- MySQL comment syntax which comments to the end of the line. When the line breaks are removed - the query was terminated at that comment.

Thanks for looking; hope this helps someone else.