_split_sql_chunk() can break user defined SQL for VIEWs that contain blank lines #15

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

columbusmonkey commented May 7, 2013

If I have a view that starts with a newline, then DBIC generates something like the following:

CREATE
  VIEW `view1` ( `col1` ) AS

SELECT
  cola...

...and then _split_sql_chunk() will join the AS and the SELECT into ASSELECT and break the deployment. (Tested on MySQL.)

This is the (over zealous?) trimming:

    # trim whitespaces
    s/^\s+|\s+$//mg;

Is there a reason to do this trim?

(The pull request adds a test to show the problem, but not yet a solution.)

Owner

frioux commented Jul 31, 2013

The solution to this is to store generated SQL in a structured format; JSON or YAML are both good options. SQL::Translator, which is what generates the actual SQL has an option to return the lines as a list instead of a single giant string, and putting said list into a structured file would solve this. I've meant to do this for a long time but have never gotten around to it. I still plan on doing it but I might as well leave this note here if someone else has a chance.

Owner

frioux commented Aug 2, 2013

Actually this is also a duplicate of #11. See details there.

frioux closed this Aug 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment