Subject: | A bug in DBIx/DataModel/Schema/Generator.pm |
Date: | Fri, 20 Mar 2015 06:22:28 -0400 |
To: | bug-Plack-App-AutoCRUD [...] rt.cpan.org |
From: | Richard Chen <richard [...] doubleprime.com> |
Hi,
I am trying out autocrud on a simple database in which
I only have a couple of unrelated tables and I got errors like
===
500 Server Error
can't generate schema: no data. Call parse_DBI() or parse_DBIx_Class()
before at ../../lib/App/AutoCRUD/DataSource.pm line 114.
===
I have traced this to the undef value for $self->{assoc} as shown below:
[root@myserver html]# diff -u /u01/ops/perl-5.20.1/lib/site_perl/5.20.1/DBIx/DataModel/Schema/Generator.pm.sav /u01/ops/perl-5.20.1/lib/site_perl/5.20.1/DBIx/DataModel/Schema/Generator.pm
---
/u01/ops/perl-5.20.1/lib/site_perl/5.20.1/DBIx/DataModel/Schema/Generator.pm.sav
2015-03-11 20:24:53.000000000 -0400
+++
/u01/ops/perl-5.20.1/lib/site_perl/5.20.1/DBIx/DataModel/Schema/Generator.pm
2015-03-20 04:07:48.823876390 -0400
@@ -288,7 +288,8 @@
my ($self) = @_;
# check that we have some data
- $self->{assoc} && $self->{tables}
+# $self->{assoc} && $self->{tables}
+ $self->{tables}
or croak "can't generate schema: no data. "
. "Call parse_DBI() or parse_DBIx_Class() before";
I am not familiar with the autocrud code base yet but it appears that
$self->{assoc} is for associations or relationships among the tables
and if there are no relationship among the tables, then this value can be undef.
This should not be considered as an error because autocrud should cover
the simple cases as well as complicated ones.
The above changes seems to have made my simple test database work.
Please confirm if this is the case and if it needs to be fixed.
It would also be nice to have some info about troubleshoot autocrud.
I just used perl debugger on the command line but there may be
better ways.
Another issue is that if json output fails if you install the latest
JSON and JSON::XS because calls like
my $json_maker = JSON->new(%{$self->{json_args}});
does not work any more in the newer versions.
I have not used autcrud much yet but it seems to be really useful.
Thanks for your hard work.
Thanks
Richard Chen