Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix database definition errors in MySQL #13

wants to merge 1 commit into


None yet
4 participants

neonics commented Feb 2, 2014


I was attempting to run the Flowers application and ran into some trouble initialising the database.

The first commit fixes errors like this:
ERROR 1101 (42000) at line 49: BLOB/TEXT column 'type' can't have a default value
when importing the sql/Interchange6-Schema-0.013-MySQL.sql file into MySQL 5.6.15;

The second commit fixes Flowers/bin/populate errors like this:
DBIx::Class::Storage::DBI::_dbh_execute_for_fetch(): execute_for_fetch() aborted with 'Field 'created' doesn't have a default value' at populate slice: { canonical_sku => undef, description => "Surprise the one who makes you smile, or express yourself perfectly with this stunning...


racke commented Feb 4, 2014

It works for me with MySQL 5.5 and I couldn't find a pointer to this change in MySQL 5.6.
Kenny, what are your versions of DBIx::Class and SQL::Translator?
Does run "make test" without error?


neonics commented Feb 5, 2014

Hi there,

A quick response. Please bear in mind that I have no experience with
DBIx or Dancer,
so I might indeed be missing something obvious. That said, the code
doesn't run
out of the box. I'd appreciate any help, specifically because it'll help
test your code.

On 4-2-2014 17:32, Stefan Hornburg (Racke) wrote:

It works for me with MySQL 5.5 and I couldn't find a pointer to this
change in MySQL 5.6.

Try https://www.google.com/search?q=mysql+text+default+value
or isn't that what you meant?
It's not been supported since at least 5.0, and if memory serves, never.

By the way, it does work properly with Postgres 9.3.2.

Kenny, what are your versions of DBIx::Class and SQL::Translator?

DBIx::Class 0.08270
SQL::Translator 0.11018 (most versions of subpackages are 1.59 or 1.60).

I installed everything from CPAN that same day.

Does run "make test" without error?

No; in Flowers I get:

t/001_base.t ......... 1/1
#   Failed test 'use Flowers;'
#   at t/001_base.t line 5.
#     Tried to use 'Flowers'.
#     Error:  No schemas are configured at
/usr/lib/perl5/site_perl/5.14/Dancer/Plugin/DBIC.pm line 23.
# Compilation failed in require at t/001_base.t line 5.
# BEGIN failed--compilation aborted at t/001_base.t line 5.
# Looks like you failed 1 test of 1.
t/001_base.t ......... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
t/002_index_route.t .. No schemas are configured at
/usr/lib/perl5/site_perl/5.14/Dancer/Plugin/DBIC.pm line 23.

which I attributed to the fact that I have no clue now to pass the
--environment parameter to dancer there.
I do have environments/development.yml copied from config.yml with only
the DSN modified, and the site
runs fine using bin/app.pl.

And in interchange6-schema, I didn't think to run make test, but it
fails aswell:

t/dbic_testdatabase.t .. DBIx::Class::Storage::DBI::deploy():
DBIx::Class::Storage::DBI::deploy(): DBI Exception: DBD::SQLite::db
do failed: near "(": syntax error [for Statement "CREATE TABLE
"products" (
   "sku" varchar(32) NOT NULL,
)") at /usr/lib/perl5/site_perl/5.14/DBICx/TestDatabase.pm line 29

Btw, DBICx::TestDatabase 0.05.
I didn't bother with that because I don't use SQLite anyway ;-)

I'll dive deeper into it on my side here, but, as far as I know, TEXT
and BLOB cannot have default values
in MySQL, and specifying them as such in Result table files appears to
be wrong, since they're not modified
when generating the sql/Interchange6-Schema-0.013-*.sql files, nor when
dynamically creating the
tables in the Flowers/populate script. Perhaps DBIx would catch this?
Besides, it doesnt' seem quite useful
to specify an empty string as a default value rather than just allowing
NULL, but that may just be personal
Also, not specifying a default value for a timestamp not null column and
then inserting a row without
providing a value seems wrong; I don't see any settings indicating that
such a value would need to be
dynamically calculated. But as I said, I'm a noob with these packages ;-)


It's nice to finally 'meet' you - I've been hacking interchange 5.7.1
for the last month.. It's good to start
from scratch, isn't it?

Kenney Westerhof

Reply to this email directly or view it on GitHub
#13 (comment).


racke commented Feb 5, 2014

Ok, so I suppose it doesn't depend on the server version, but on the setting of the sql_mode server variable.
Looks like you are in strict mode.


Can you please tell me your current value of sql_mode?



racke commented Feb 5, 2014

The failure of Flowers test seems unrelated to this issue, it doesn't work for me as well.

Yeah, and nice to meet you as well :-). Better to start from scratch, I agree.



racke commented Feb 5, 2014

OK, I reproduced the problem with


Good catch!


racke commented Feb 5, 2014

Kenny, can you please revise your "TEXT cannot have default value" commit to use
default_value => ''. Otherwise we have to add all these fields to every query which
is really annoying.

neonics commented Feb 5, 2014

UPDATE: aww, i didn't see the other emails. But you' re absolutely right about the sql_mode! ;-) It's the default on windows.

I did a git rebase -i head^^ and removed the commit, then did a git push -f and it appears to have gone even from the pull request. Shouldn't have any consequences so early on right?


racke commented Feb 15, 2014

I'm going to ask for advice on DBIx::Class mailing list issue.


hexfusion commented Mar 22, 2014

@neonics Appreciate your interest in Flowers/Interchange6 Kenny. I just sent you an email to your f*@neonics.com email. Hope to hear from you!


SysPete commented Jul 16, 2014

Problems with default values for text fields fixed by commit 1a91a0b.
created & modified fields handled by timestamp component.

@SysPete SysPete closed this Jul 16, 2014

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