Re: Class::DBI::mysql create_table BUG ?

[prev] [thread] [next] [Date index for 2005/01/19]

From: Kingsley Kerce
Subject: Re: Class::DBI::mysql create_table BUG ?
Date: 21:09 on 19 Jan 2005
Your package name ends in Group, so create_table() is probably
defaulting to that.  Try adding this line

__PACKAGE__->table('group_2');

before you invoke create_table().  Also, if you do that, you may not
need to supply an argument to set_up_table().

Kings

Daniel Wijnands writes:
 > Correct that's why my table name = group_2 that is not a reserved word. 
 > By Class::DBI::mysql->create_table uses the table name : group : 
 > 
 > CREATE TABLE IF NOT  
 > > > EXISTS
 > > > group (
 > 
 > But package says : 
 > 
 > 
 >  __PACKAGE__->set_up_table('group_2');
 > 
 > 
 > 
 > 
 > On Wed, 2005-01-19 at 15:12 -0500, Sean Davis wrote:
 > > I think "group" is a reserved word in MySQL, IIRC.  You can't use that  
 > > as a table name.
 > > 
 > > Sean
 > > 
 > > On Jan 19, 2005, at 3:00 PM, Daniel Wijnands wrote:
 > > 
 > > > Hi,
 > > >
 > > > I'm trying to create my tables automatic if they don't exist, see
 > > > following package :
 > > >
 > > > 2 package Database::Group;
 > > >       3 use base 'Database::DBI';
 > > >       4 use strict;
 > > >       5
 > > >       6 __PACKAGE__->create_table(q{
 > > >       7   grpId INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 > > >       8   grpName CHAR(30) NULL,
 > > >       9   grpDescription TEXT NULL,
 > > >      10   PRIMARY KEY(grpId)
 > > >      11      });
 > > >      12
 > > >      13 __PACKAGE__->set_up_table('group_2');
 > > >      14
 > > > __PACKAGE__->has_many(modulemoderules=>['Database:: 
 > > > ModuleModeRule'=>'grpId']);
 > > >      15
 > > >      16
 > > >
 > > >
 > > > Running this code gives the following error :
 > > >
 > > > aniel@dell:/usr/data/www/cms.ios/HTML/Core$ perl -e 'use
 > > > Database::Group';
 > > > DBD::mysql::st execute failed: 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 'group (
 > > >   grpId INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 > > >   grpName CHAR(30)' at line 1 [for Statement "CREATE TABLE IF NOT  
 > > > EXISTS
 > > > group (
 > > >   grpId INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 > > >   grpName CHAR(30) NULL,
 > > >   grpDescription TEXT NULL,
 > > >   PRIMARY KEY(grpId)
 > > >      )"] at  
 > > > /usr/local/lib/perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm
 > > > line 51.
 > > > Compilation failed in require at -e line 1.
 > > > BEGIN failed--compilation aborted at -e line 1.
 > > > daniel@dell:/usr/data/www/cms.ios/HTML/Core$
 > > >
 > > >
 > > > create table uses the following syntax :
 > > >
 > > >  __PACKAGE__->set_sql(
 > > >     146 | create_table => 'CREATE TABLE IF NOT EXISTS __TABLE__ (%s)');
 > > >
 > > > But the tablename = group_2 and nog group, so the conversion from
 > > > __TABLE__ is in error
 > > >
 > > >
 > > > Is this a bug of de code or a bug of mine :)
 > > >
 > > > Kind regards daniel
 > > 

Class::DBI::mysql create_table BUG ?
Daniel Wijnands 20:00 on 19 Jan 2005

Re: Class::DBI::mysql create_table BUG ?
Sean Davis 20:12 on 19 Jan 2005

Re: Class::DBI::mysql create_table BUG ?
Daniel Wijnands 21:02 on 19 Jan 2005

Re: Class::DBI::mysql create_table BUG ?
Kingsley Kerce 21:09 on 19 Jan 2005

Re: Class::DBI::mysql create_table BUG ?
Daniel Wijnands 21:45 on 19 Jan 2005

Generated at 17:42 on 27 Jan 2005 by mariachi v0.52