Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 28841
Status: resolved
Priority: 0/
Queue: SQL-Translator

People
Owner: cpan [...] desert-island.me.uk
Requestors: jimdread [...] hotmail.com
Cc:
AdminCc:

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



Subject: SQL::Translator comments out part of create table command for PostgreSQL
Date: Wed, 15 Aug 2007 05:59:02 +0000
To: bug-SQL-Translator [...] rt.cpan.org
From: "Jim Dread" <jimdread [...] hotmail.com>
Part of create table command is commented with Pg producer ---------------------------------------------------------- Hello SQLFairy developers. Today I started to use your excellent tool, but unfortunately had a few problems. One problem was that using the PostgreSQL producer, the SQL that came out had part of the create table command commented out. I was able to fix this with a dirty hack oops I mean "patch" which is below after the test data and results. I don't really know why this went wrong, maybe some flag or switch I haven't set. I don't guarantee the patch is useful to you, since I just did the simplest thing I could see to make it work for me and didn't test all possibilities. But I can't think of any reason why an extra linefeed in front of "CREATE TABLE" would hurt anything. Feel free to use it if you want to. Thanks for a great tool. Jim Follows: 0. Version information 1. XML for test database 2. Command to run to produce output 3. Output of broken producer 4. Output of patched producer 5. Patch for producer ======================================================================== 0. Version information SQL::Translator is up to date (0.08). This is perl, v5.8.8 built for i486-linux-gnu-thread-multi Linux asp 2.6.22 #2 Tue Jul 10 14:04:42 EST 2007 i686 GNU/Linux -----------------------------8<----------------------------------------- 1. SQLFairy XML for a simple database table -----------------------------8<----------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <schema name="" database="" xmlns="http://sqlfairy.sourceforge.net/sqlfairy.xml"> <extra /> <tables> <table name="control" order="1"> <extra /> <fields> <field name="id" data_type="int" size="11" is_nullable="0" is_auto_increment="1" is_primary_key="1" is_foreign_key="0" order="1"> <extra /> <comments></comments> </field> <field name="name" data_type="varchar" size="255" is_nullable="0" is_auto_increment="0" is_primary_key="0" is_foreign_key="0" order="2"> <extra /> <comments></comments> </field> </fields> <indices> </indices> <constraints> <constraint name="control-id" type="PRIMARY KEY" fields="id" reference_table="" reference_fields="" on_delete="" on_update="" match_type="" expression="" options="" deferrable="1"> <extra /> </constraint> <constraint name="control-name" type="UNIQUE" fields="name" reference_table="" reference_fields="" on_delete="" on_update="" match_type="" expression="" options="" deferrable="1"> <extra /> </constraint> </constraints> <comments></comments> </table> </tables> <views></views> <triggers></triggers> <procedures></procedures> </schema> -----------------------------8<----------------------------------------- 2. Command to run to produce output. sqlt -f XML-SQLFairy -t PostgreSQL bugschema.xml -----------------------------8<----------------------------------------- 3. Output of broken producer. Note that the first line of the create table command is commented out. That turns good SQL into syntax errors. -----------------------------8<----------------------------------------- -- -- Table: control --CREATE TABLE "control" ( "id" serial NOT NULL, "name" character varying(255) NOT NULL, Constraint "control-id" PRIMARY KEY ("id"), Constraint "control-name" UNIQUE ("name") ); -----------------------------8<----------------------------------------- 4. Output of patched producer. Looks better to me. -----------------------------8<----------------------------------------- -- -- Table: control -- CREATE TABLE "control" ( "id" serial NOT NULL, "name" character varying(255) NOT NULL, Constraint "control-id" PRIMARY KEY ("id"), Constraint "control-name" UNIQUE ("name") ); -----------------------------8<----------------------------------------- 5. Patch for SQL::Translator::Producer::PostgreSQL.pm -----------------------------8<----------------------------------------- --- PostgreSQL.pm 2007-08-15 05:50:56.000000000 +0000 +++ PostgreSQL.pm-orig 2007-08-15 05:50:41.000000000 +0000 @@ -379,7 +379,7 @@ $create_statement = join("\n", @comments); $create_statement .= qq[DROP TABLE $qt$table_name_ur$qt CASCADE;\n] if $add_drop_table; - $create_statement .= qq[\nCREATE TABLE $qt$table_name_ur$qt (\n]. + $create_statement .= qq[CREATE TABLE $qt$table_name_ur$qt (\n]. join( ",\n", map { " $_" } @field_defs, @constraint_defs ). "\n);" ; -----------------------------8<----------------------------------------- Show quoted text
_________________________________________________________________ Puzzles, trivia teasers, word scrambles and more. Play for your chance to win! http://club.live.com/home.aspx?icid=CLUB_hotmailtextlink
Thanks Jim! I'll look into this and see if you patch fixes the issue. Jess On Wed Aug 15 01:59:46 2007, jimdread@hotmail.com wrote: Show quoted text
> > Part of create table command is commented with Pg producer > ---------------------------------------------------------- > > Hello SQLFairy developers. Today I started to use your excellent tool, > but unfortunately had a few problems. One problem was that using the > PostgreSQL producer, the SQL that came out had part of the create > table command commented out. I was able to fix this with a dirty hack > oops I mean "patch" which is below after the test data and results. > > I don't really know why this went wrong, maybe some flag or switch I > haven't set. > > I don't guarantee the patch is useful to you, since I just did the > simplest thing I could see to make it work for me and didn't test all > possibilities. But I can't think of any reason why an extra linefeed > in front of "CREATE TABLE" would hurt anything. Feel free to use it if > you want to. > > Thanks for a great tool. > Jim > > Follows: > 0. Version information > 1. XML for test database > 2. Command to run to produce output > 3. Output of broken producer > 4. Output of patched producer > 5. Patch for producer > >
======================================================================== Show quoted text
> > 0. Version information > > SQL::Translator is up to date (0.08). > This is perl, v5.8.8 built for i486-linux-gnu-thread-multi > Linux asp 2.6.22 #2 Tue Jul 10 14:04:42 EST 2007 i686 GNU/Linux > > > -----------------------------8<---------------------------------------
-- Show quoted text
> > > 1. SQLFairy XML for a simple database table > > -----------------------------8<---------------------------------------
-- Show quoted text
> > <?xml version="1.0" encoding="UTF-8"?> > > <schema name="" database="" > xmlns="http://sqlfairy.sourceforge.net/sqlfairy.xml"> > <extra /> > <tables> > <table name="control" order="1"> > <extra /> > <fields> > <field name="id" data_type="int" size="11" is_nullable="0" > is_auto_increment="1" is_primary_key="1" is_foreign_key="0" order="1"> > <extra /> > <comments></comments> > </field> > <field name="name" data_type="varchar" size="255"
is_nullable="0" Show quoted text
> is_auto_increment="0" is_primary_key="0" is_foreign_key="0" order="2"> > <extra /> > <comments></comments> > </field> > </fields> > <indices> > </indices> > <constraints> > <constraint name="control-id" type="PRIMARY KEY" fields="id" > reference_table="" reference_fields="" on_delete="" on_update="" > match_type="" expression="" options="" deferrable="1"> > <extra /> > </constraint> > <constraint name="control-name" type="UNIQUE" fields="name" > reference_table="" reference_fields="" on_delete="" on_update="" > match_type="" expression="" options="" deferrable="1"> > <extra /> > </constraint> > </constraints> > <comments></comments> > </table> > </tables> > <views></views> > <triggers></triggers> > <procedures></procedures> > </schema> > > -----------------------------8<---------------------------------------
-- Show quoted text
> > 2. Command to run to produce output. > > sqlt -f XML-SQLFairy -t PostgreSQL bugschema.xml > > -----------------------------8<---------------------------------------
-- Show quoted text
> > > 3. Output of broken producer. Note that the first line of the create > table command is commented out. That turns good SQL into syntax > errors. > > -----------------------------8<---------------------------------------
-- Show quoted text
> > -- > -- Table: control > --CREATE TABLE "control" ( > "id" serial NOT NULL, > "name" character varying(255) NOT NULL, > Constraint "control-id" PRIMARY KEY ("id"), > Constraint "control-name" UNIQUE ("name") > ); > > -----------------------------8<---------------------------------------
-- Show quoted text
> > 4. Output of patched producer. Looks better to me. > > -----------------------------8<---------------------------------------
-- Show quoted text
> > -- > -- Table: control > -- > CREATE TABLE "control" ( > "id" serial NOT NULL, > "name" character varying(255) NOT NULL, > Constraint "control-id" PRIMARY KEY ("id"), > Constraint "control-name" UNIQUE ("name") > ); > > -----------------------------8<---------------------------------------
-- Show quoted text
> > 5. Patch for SQL::Translator::Producer::PostgreSQL.pm > > -----------------------------8<---------------------------------------
-- Show quoted text
> > --- PostgreSQL.pm 2007-08-15 05:50:56.000000000 +0000 > +++ PostgreSQL.pm-orig 2007-08-15 05:50:41.000000000 +0000 > @@ -379,7 +379,7 @@ > $create_statement = join("\n", @comments); > $create_statement .= qq[DROP TABLE $qt$table_name_ur$qt
CASCADE;\n] Show quoted text
> if $add_drop_table; > - $create_statement .= qq[\nCREATE TABLE $qt$table_name_ur$qt (\n]. > + $create_statement .= qq[CREATE TABLE $qt$table_name_ur$qt (\n]. > join( ",\n", map { " $_" } @field_defs, > @constraint_defs ). > "\n);" > ; > > > -----------------------------8<---------------------------------------
-- Show quoted text
> > _________________________________________________________________ > Puzzles, trivia teasers, word scrambles and more. Play for your
chance to Show quoted text
Aha, looks like someone has fixed this in CVS already, I'll do another release soonish. Jess On Mon Aug 20 08:18:11 2007, JROBINSON wrote: Show quoted text
> Thanks Jim! I'll look into this and see if you patch fixes the issue. > > Jess > > > On Wed Aug 15 01:59:46 2007, jimdread@hotmail.com wrote:
> > > > Part of create table command is commented with Pg producer > > ---------------------------------------------------------- > > > > Hello SQLFairy developers. Today I started to use your excellent
tool, Show quoted text
> > but unfortunately had a few problems. One problem was that using the > > PostgreSQL producer, the SQL that came out had part of the create > > table command commented out. I was able to fix this with a dirty
hack Show quoted text
> > oops I mean "patch" which is below after the test data and results. > > > > I don't really know why this went wrong, maybe some flag or switch I > > haven't set. > > > > I don't guarantee the patch is useful to you, since I just did the > > simplest thing I could see to make it work for me and didn't test
all Show quoted text
> > possibilities. But I can't think of any reason why an extra linefeed > > in front of "CREATE TABLE" would hurt anything. Feel free to use it
if Show quoted text
> > you want to. > > > > Thanks for a great tool. > > Jim > > > > Follows: > > 0. Version information > > 1. XML for test database > > 2. Command to run to produce output > > 3. Output of broken producer > > 4. Output of patched producer > > 5. Patch for producer > > > >
>
======================================================================== Show quoted text
> > > > 0. Version information > > > > SQL::Translator is up to date (0.08). > > This is perl, v5.8.8 built for i486-linux-gnu-thread-multi > > Linux asp 2.6.22 #2 Tue Jul 10 14:04:42 EST 2007 i686 GNU/Linux > > > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > > > 1. SQLFairy XML for a simple database table > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > <?xml version="1.0" encoding="UTF-8"?> > > > > <schema name="" database="" > > xmlns="http://sqlfairy.sourceforge.net/sqlfairy.xml"> > > <extra /> > > <tables> > > <table name="control" order="1"> > > <extra /> > > <fields> > > <field name="id" data_type="int" size="11" is_nullable="0" > > is_auto_increment="1" is_primary_key="1" is_foreign_key="0"
order="1"> Show quoted text
> > <extra /> > > <comments></comments> > > </field> > > <field name="name" data_type="varchar" size="255"
> is_nullable="0"
> > is_auto_increment="0" is_primary_key="0" is_foreign_key="0"
order="2"> Show quoted text
> > <extra /> > > <comments></comments> > > </field> > > </fields> > > <indices> > > </indices> > > <constraints> > > <constraint name="control-id" type="PRIMARY KEY"
fields="id" Show quoted text
> > reference_table="" reference_fields="" on_delete="" on_update="" > > match_type="" expression="" options="" deferrable="1"> > > <extra /> > > </constraint> > > <constraint name="control-name" type="UNIQUE" fields="name" > > reference_table="" reference_fields="" on_delete="" on_update="" > > match_type="" expression="" options="" deferrable="1"> > > <extra /> > > </constraint> > > </constraints> > > <comments></comments> > > </table> > > </tables> > > <views></views> > > <triggers></triggers> > > <procedures></procedures> > > </schema> > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > 2. Command to run to produce output. > > > > sqlt -f XML-SQLFairy -t PostgreSQL bugschema.xml > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > > > 3. Output of broken producer. Note that the first line of the create > > table command is commented out. That turns good SQL into syntax > > errors. > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > -- > > -- Table: control > > --CREATE TABLE "control" ( > > "id" serial NOT NULL, > > "name" character varying(255) NOT NULL, > > Constraint "control-id" PRIMARY KEY ("id"), > > Constraint "control-name" UNIQUE ("name") > > ); > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > 4. Output of patched producer. Looks better to me. > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > -- > > -- Table: control > > -- > > CREATE TABLE "control" ( > > "id" serial NOT NULL, > > "name" character varying(255) NOT NULL, > > Constraint "control-id" PRIMARY KEY ("id"), > > Constraint "control-name" UNIQUE ("name") > > ); > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > 5. Patch for SQL::Translator::Producer::PostgreSQL.pm > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > --- PostgreSQL.pm 2007-08-15 05:50:56.000000000 +0000 > > +++ PostgreSQL.pm-orig 2007-08-15 05:50:41.000000000 +0000 > > @@ -379,7 +379,7 @@ > > $create_statement = join("\n", @comments); > > $create_statement .= qq[DROP TABLE $qt$table_name_ur$qt
> CASCADE;\n]
> > if $add_drop_table; > > - $create_statement .= qq[\nCREATE TABLE $qt$table_name_ur$qt
(\n]. Show quoted text
> > + $create_statement .= qq[CREATE TABLE $qt$table_name_ur$qt (\n]. > > join( ",\n", map { "
$_" } @field_defs, Show quoted text
> > @constraint_defs ). > > "\n);" > > ; > > > > > > -----------------------------8<-------------------------------------
-- Show quoted text
> --
> > > > _________________________________________________________________ > > Puzzles, trivia teasers, word scrambles and more. Play for your
> chance to > >