List Info

Thread: Newbie with the tutorial and Postgresql




Newbie with the tutorial and Postgresql
user name
2007-05-29 22:06:13
Hi all,

I've been working through the tutorial, converting over to
postgresql, and 
get the http://localhost:300
0/books/list working fine. When I move to the 
BasicCRUD portion and the url_create 
(http://localhost:3000/books/url_create/TCPIP_I
llustrated_Vol-2/5/4)

my result is:

  Caught exception in
MyApp::Controller::Books->url_create 
"DBIx::Class::ResultSet::create(): Error executing
'INSERT INTO books 
(rating, title) VALUES (?, ?)': ERROR:  null value in column
"id" violates 
not-null constraint"


lib/MyAppDB/Book.pm has

# Load required DBIC stuff
__PACKAGE__->load_components(qw/PK::Auto Core/);


which I think means that the automatci primary key should
be inserte 
(although I may need to create a sequence).

I am such a newbie that I'm not sure if I'm missing
something with DBIC or 
should create a Pg sequence with appropriate names, or am
completely 
offbase.

Any assistance would be appreciated.

Thanks in advance,

Louis
_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: Newbie with the tutorial and Postgresql
user name
2007-05-30 16:38:27
Thank you, you got me past that hurdle. I was missing a

"DEFAULT nextval('books_seq'),"

in the CREATE TABLE. I had the correct stuff in the
lib/MyAppDB/Book.pm (since it was copied right out of the
tutorial  I 
was missing something for the PK::Auto to operate on.

Thanks again!

Louis


On Wed, 30 May 2007, Marcello Romani wrote:

> Tom Lanyon ha scritto:
>> 
>> On 30/05/2007, at 3:39 PM, Marcello Romani wrote:
>> 
>>> Do you also have
>>>
>>>  __PACKAGE__->set_primary_key('id');
>>> 
>>> ?
>> 
>> You need:
>>     - an add_column() or add_columns() line for
your 'id' column
>>     - the above set_primary_key('id') line
>>     - the 'id' column in your database table must
have its default value 
>> set to the nextval from a sequence in the database
>> 
>> Hope this helps.
>> 
>> -- 
>> Tom Lanyon
>> Systems Administrator
>> NetSpot Pty Ltd
>> 
>> 
>> 
>> _______________________________________________
>> List: Catalystlists.rawmode.org
>> Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
>> Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
>> Dev site: http://dev.catalyst.per
l.org/
>> 
>> 
>
> Yes, I've probably been too concise 
>
> In fact it would be of great help to see the full
source code for the 
> dbic-class and the db-creation script, to see where the
problem lies.
>
> I think checking if the id column is SERIAL is a good
advice.
>
> -- 
> Marcello Romani
> Responsabile IT
> Ottotecnica s.r.l.
> http://www.ottotecnica.com

>
> _______________________________________________
> List: Catalystlists.rawmode.org
> Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
> Dev site: http://dev.catalyst.per
l.org/
>
>
>

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )