Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DBIx-Class-Migration CPAN distribution.

Report information
The Basics
Id: 77777
Status: resolved
Priority: 0/
Queue: DBIx-Class-Migration

People
Owner: Nobody in particular
Requestors: fs5 [...] sanger.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.024
Fixed in: (no value)



Subject: Suggestion for documentation regarding whitespace in DDL files
I just came across some unexpected behaviour that took me some time to figure out. The issue is not caused by DBIC::Migration but it would be good to mention it in the docs as a possible gotcha. It seems that the SQL::Translator has a problem with leading whitespace in DDL files, even if the statement is actually syntactically correct. The following migration throws and error: BEGIN; ; ALTER TABLE addresses DROP PRIMARY KEY , ADD COLUMN organization VARCHAR(100) NOT NULL, ADD PRIMARY KEY (id) ; COMMIT; The error is: DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::__ANON__(): DBI Exception: DBD::mysql::db do failed: Query was empty [for Statement ""] I have: DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator version 0.002100 and SQL::Translator Version: 0.11010 But removing all leading whitespace results in a successful migration, so this works: BEGIN; ; ALTER TABLE addresses DROP PRIMARY KEY , ADD COLUMN organization VARCHAR(100) NOT NULL, ADD PRIMARY KEY (id) ; COMMIT; But the first version works in a mysql shell with the leading whitespace, so it is surprising that the migration fails. The leading whitespace in my case is the result of auto-formatting (in vim) the DDL file that was auto-generated by the dbic-migration prepare command. I can try to write this up for your docs and submit a patch if you want to include this.
Subject: Re: [rt.cpan.org #77777] Suggestion for documentation regarding whitespace in DDL files
Date: Tue, 12 Jun 2012 06:24:02 -0700 (PDT)
To: bug-DBIx-Class-Migration [...] rt.cpan.org
From: John Napiorkowski <jjn1056 [...] yahoo.com>
Hi, I've noticed that the code that chops up a DDL to execute can be a little cranky. I would love to get a test case, although in the end I might end up transfering the issue to DBIC:DH, which is the framework that does all the heavy lifting. A failing test case would definitely help and also prevent regressions (my guess is that the job of chopping up and executing the ddl is a bit more tricky than might be desired. I think also I want to take a second look at how SQLT generates some of this DDL code. The output is far from clean. Thanks for bringing this to my attention, and hope the DBIC:M has been otherwise useful to you. Johnn Show quoted text
>________________________________ > From: Frank Schwach via RT <bug-DBIx-Class-Migration@rt.cpan.org> >To: >Sent: Tuesday, June 12, 2012 9:16 AM >Subject: [rt.cpan.org #77777] Suggestion for documentation regarding whitespace in DDL files > >Tue Jun 12 09:16:02 2012: Request 77777 was acted upon. >Transaction: Ticket created by fschwach >      Queue: DBIx-Class-Migration >    Subject: Suggestion for documentation regarding whitespace in DDL files >  Broken in: 0.024 >    Severity: Wishlist >      Owner: Nobody >  Requestors: fs5@sanger.ac.uk >      Status: new >Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=77777 > > > >I just came across some unexpected behaviour that took me some time to >figure out. The issue is not caused by DBIC::Migration but it would be >good to mention it in the docs as a possible gotcha. > >It seems that the SQL::Translator has a problem with leading whitespace >in DDL files, even if the statement is actually syntactically correct. > >The following migration throws and error: > >BEGIN; >  ; >  ALTER TABLE addresses DROP PRIMARY KEY , >  ADD COLUMN organization VARCHAR(100) NOT NULL, >  ADD PRIMARY KEY (id) > >  ; > >  COMMIT; > >The error is: >DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::__ANON__(): >DBI Exception: DBD::mysql::db do failed: Query was empty [for Statement ""] > >I have: >DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator >version 0.002100 > >and >SQL::Translator >Version: 0.11010 > >But removing all leading whitespace results in a successful migration, >so this works: > >BEGIN; >; >ALTER TABLE addresses DROP PRIMARY KEY , >ADD COLUMN organization VARCHAR(100) NOT NULL, >ADD PRIMARY KEY (id) > >; > >COMMIT; > >But the first version works in a mysql shell with the leading >whitespace, so it is surprising that the migration fails. > >The leading whitespace in my case is the result of auto-formatting (in >vim) the DDL file that was auto-generated by the >dbic-migration prepare >command. > >I can try to write this up for your docs and submit a patch if you want >to include this. > > > > > >
Subject: Re: [rt.cpan.org #77777] Suggestion for documentation regarding whitespace in DDL files
Date: Tue, 12 Jun 2012 14:51:36 +0100
To: bug-DBIx-Class-Migration [...] rt.cpan.org
From: Frank Schwach <fs5 [...] sanger.ac.uk>
Thanks John! Yes, the generated DDL can be quite ugly, which is why I reformatted it in the first place ( the full file that caused the error is longer and it looked really unreadable at first). For that reason, I think it would be good to mention the problem as peope could well be tempted to re-format the DDL and then get this completely cryptic error. Yes, your modules are incredibly useful to me - I still owe you a little write-up of my experiences so far. Haven't forgotten, just didn't have the time yet... Cheers, Frank On 12/06/12 14:24, jjn1056@yahoo.com via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=77777> > > Hi, > > I've noticed that the code that chops up a DDL to execute can be a little cranky. I would love to get a test case, although in the end I might end up transfering the issue to DBIC:DH, which is the framework that does all the heavy lifting. > > A failing test case would definitely help and also prevent regressions (my guess is that the job of chopping up and executing the ddl is a bit more tricky than might be desired. > > I think also I want to take a second look at how SQLT generates some of this DDL code. The output is far from clean. > > Thanks for bringing this to my attention, and hope the DBIC:M has been otherwise useful to you. > > Johnn > >
>> ________________________________ >> From: Frank Schwach via RT<bug-DBIx-Class-Migration@rt.cpan.org> >> To: >> Sent: Tuesday, June 12, 2012 9:16 AM >> Subject: [rt.cpan.org #77777] Suggestion for documentation regarding whitespace in DDL files >> >> Tue Jun 12 09:16:02 2012: Request 77777 was acted upon. >> Transaction: Ticket created by fschwach >> Queue: DBIx-Class-Migration >> Subject: Suggestion for documentation regarding whitespace in DDL files >> Broken in: 0.024 >> Severity: Wishlist >> Owner: Nobody >> Requestors: fs5@sanger.ac.uk >> Status: new >> Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=77777> >> >> >> I just came across some unexpected behaviour that took me some time to >> figure out. The issue is not caused by DBIC::Migration but it would be >> good to mention it in the docs as a possible gotcha. >> >> It seems that the SQL::Translator has a problem with leading whitespace >> in DDL files, even if the statement is actually syntactically correct. >> >> The following migration throws and error: >> >> BEGIN; >> ; >> ALTER TABLE addresses DROP PRIMARY KEY , >> ADD COLUMN organization VARCHAR(100) NOT NULL, >> ADD PRIMARY KEY (id) >> >> ; >> >> COMMIT; >> >> The error is: >> DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::__ANON__(): >> DBI Exception: DBD::mysql::db do failed: Query was empty [for Statement ""] >> >> I have: >> DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator >> version 0.002100 >> >> and >> SQL::Translator >> Version: 0.11010 >> >> But removing all leading whitespace results in a successful migration, >> so this works: >> >> BEGIN; >> ; >> ALTER TABLE addresses DROP PRIMARY KEY , >> ADD COLUMN organization VARCHAR(100) NOT NULL, >> ADD PRIMARY KEY (id) >> >> ; >> >> COMMIT; >> >> But the first version works in a mysql shell with the leading >> whitespace, so it is surprising that the migration fails. >> >> The leading whitespace in my case is the result of auto-formatting (in >> vim) the DDL file that was auto-generated by the >> dbic-migration prepare >> command. >> >> I can try to write this up for your docs and submit a patch if you want >> to include this. >> >> >> >> >> >>
-- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
Subject: Re: [rt.cpan.org #77777] Suggestion for documentation regarding whitespace in DDL files
Date: Tue, 12 Jun 2012 14:52:48 +0100
To: bug-DBIx-Class-Migration [...] rt.cpan.org
From: Frank Schwach <fs5 [...] sanger.ac.uk>
whoa, just noticed the ticket ID #77777 - do I win the jackpot or something??? :) On 12/06/12 14:24, jjn1056@yahoo.com via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=77777> > > Hi, > > I've noticed that the code that chops up a DDL to execute can be a little cranky. I would love to get a test case, although in the end I might end up transfering the issue to DBIC:DH, which is the framework that does all the heavy lifting. > > A failing test case would definitely help and also prevent regressions (my guess is that the job of chopping up and executing the ddl is a bit more tricky than might be desired. > > I think also I want to take a second look at how SQLT generates some of this DDL code. The output is far from clean. > > Thanks for bringing this to my attention, and hope the DBIC:M has been otherwise useful to you. > > Johnn > >
>> ________________________________ >> From: Frank Schwach via RT<bug-DBIx-Class-Migration@rt.cpan.org> >> To: >> Sent: Tuesday, June 12, 2012 9:16 AM >> Subject: [rt.cpan.org #77777] Suggestion for documentation regarding whitespace in DDL files >> >> Tue Jun 12 09:16:02 2012: Request 77777 was acted upon. >> Transaction: Ticket created by fschwach >> Queue: DBIx-Class-Migration >> Subject: Suggestion for documentation regarding whitespace in DDL files >> Broken in: 0.024 >> Severity: Wishlist >> Owner: Nobody >> Requestors: fs5@sanger.ac.uk >> Status: new >> Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=77777> >> >> >> I just came across some unexpected behaviour that took me some time to >> figure out. The issue is not caused by DBIC::Migration but it would be >> good to mention it in the docs as a possible gotcha. >> >> It seems that the SQL::Translator has a problem with leading whitespace >> in DDL files, even if the statement is actually syntactically correct. >> >> The following migration throws and error: >> >> BEGIN; >> ; >> ALTER TABLE addresses DROP PRIMARY KEY , >> ADD COLUMN organization VARCHAR(100) NOT NULL, >> ADD PRIMARY KEY (id) >> >> ; >> >> COMMIT; >> >> The error is: >> DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::__ANON__(): >> DBI Exception: DBD::mysql::db do failed: Query was empty [for Statement ""] >> >> I have: >> DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator >> version 0.002100 >> >> and >> SQL::Translator >> Version: 0.11010 >> >> But removing all leading whitespace results in a successful migration, >> so this works: >> >> BEGIN; >> ; >> ALTER TABLE addresses DROP PRIMARY KEY , >> ADD COLUMN organization VARCHAR(100) NOT NULL, >> ADD PRIMARY KEY (id) >> >> ; >> >> COMMIT; >> >> But the first version works in a mysql shell with the leading >> whitespace, so it is surprising that the migration fails. >> >> The leading whitespace in my case is the result of auto-formatting (in >> vim) the DDL file that was auto-generated by the >> dbic-migration prepare >> command. >> >> I can try to write this up for your docs and submit a patch if you want >> to include this. >> >> >> >> >> >>
-- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
On Tue Jun 12 09:51:48 2012, fs5@sanger.ac.uk wrote: Show quoted text
> Thanks John! > Yes, the generated DDL can be quite ugly, which is why I reformatted > it > in the first place ( the full file that caused the error is longer and > it looked really unreadable at first). > For that reason, I think it would be good to mention the problem as > peope could well be tempted to re-format the DDL and then get this > completely cryptic error.
The real solution would be to fix SQL::Translator not to choke on leading pace no...? Or am I misunderstanding the issue...?
I am closing this ticket since it has been a little while. If the issue is still happening, please open an issue on the GitHub repo.