Discussion:
[jifty-devel] jifty beginner problem
xu zhou
2008-10-14 09:18:00 UTC
Permalink
HI
I just followed the Jifty::Manual::Tutorial and when I went to

jifty schema --setup

I got such messages:


WARN - Prototype mismatch: sub Jifty::View::Declare::Helpers::wrapper
($$) vs none at
/usr/local/share/perl/5.8.8/Jifty/View/Declare/Helpers.pm line 368.
WARN - Subroutine wrapper redefined at
/usr/local/share/perl/5.8.8/Jifty/View/Declare/Helpers.pm line 332.
WARN - Application schema has no version in the database.
WARN - Automatically creating your database.
INFO - Generating SQL for application Mywebblog...
INFO - Using Mywebblog::Model::Post, as it appears to be new.
WARN - DBD::mysql::st execute failed: BLOB/TEXT column 'title' can't
have a default value at
/usr/local/share/perl/5.8.8/Jifty/DBI/Handle.pm line 554.
WARN - Mywebblog::Handle=HASH(0x9f5abbc) couldn't execute the query
'CREATE TABLE posts (
id INTEGER NOT NULL AUTO_INCREMENT,
title text NULL DEFAULT 'Untitled post' ,
body text NULL ,
PRIMARY KEY (id)
)
' at /usr/local/share/perl/5.8.8/Jifty/DBI/Handle.pm line 578.
error creating table Mywebblog::Model::Post: Couldn't execute the
query 'CREATE TABLE posts (
id INTEGER NOT NULL AUTO_INCREMENT,
title text NULL DEFAULT 'Untitled post' ,
body text NULL ,
PRIMARY KEY (id)
)
'BLOB/TEXT column 'title' can't have a default value at
/usr/local/share/perl/5.8.8/Jifty/Record.pm line 699.

No tables were created in the database mywebblog
Dose anybody know what is the problem?
Sterling Hanenkamp
2008-10-14 12:34:32 UTC
Permalink
Post by xu zhou
WARN - DBD::mysql::st execute failed: BLOB/TEXT column 'title' can't
have a default value at
/usr/local/share/perl/5.8.8/Jifty/DBI/Handle.pm line 554.
If you use MySQL for database storage, don't use a default for text columns.
So, if your model definition looks like this:

column title => type is 'text', default is 'Untitled post';

You should change it to:

column title => type is 'text';

or to use a VARCHAR type instead like:

column title => type is 'varchar(100)', default is 'Untitled post';

If you still want the default and still want to use the "text" type, you can
add a before_create() hook to your model like this:

sub before_create {
my ($self, $args) = @_;

$args->{title} ||= 'Untitled post';

return 1;
}

I think Jifty::DBI ought to be smart enough to know about and do the right
thing in this case, but it currently does not, so you'll have to go ahead
and take care of it this way for the time being.

Cheers,
Sterling
Post by xu zhou
WARN - Mywebblog::Handle=HASH(0x9f5abbc) couldn't execute the query
'CREATE TABLE posts (
id INTEGER NOT NULL AUTO_INCREMENT,
title text NULL DEFAULT 'Untitled post' ,
body text NULL ,
PRIMARY KEY (id)
)
' at /usr/local/share/perl/5.8.8/Jifty/DBI/Handle.pm line 578.
error creating table Mywebblog::Model::Post: Couldn't execute the
query 'CREATE TABLE posts (
id INTEGER NOT NULL AUTO_INCREMENT,
title text NULL DEFAULT 'Untitled post' ,
body text NULL ,
PRIMARY KEY (id)
)
'BLOB/TEXT column 'title' can't have a default value at
/usr/local/share/perl/5.8.8/Jifty/Record.pm line 699.
No tables were created in the database mywebblog
Dose anybody know what is the problem?
_______________________________________________
jifty-devel mailing list
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
Loading...