Quoting Ian Bicking <ia...@co...>:
> On Mon, 2003-03-31 at 10:43, Bud P.Bruegger wrote:
> > Is there a reason for using SEQUENCE instead of SERIAL?
>
> AFAIK (but I'm not a Postgres expert), SERIAL is
> equivalent to creating
> a sequence in the same way SQLObject expects. Maybe
> it'll even work.
> It's easier for SQLObject to use the sequence directly
> rather than let
> the ID be generated implicitly by the default, but
> obviously you don't
> have to use the default.
Yes, in Postgres the preferred way is to use SERIAL, and all
of our tables are generated that way. Sorry I haven't
mentioned this before Ian, and it makes some changes to your
PostgresConnection class.
When you use SERIAL in Postgres, it creates a sequence named
slightly differently than SQLObject expects now, so there
either needs to be a way to pass the sequence name, or just
change it to the SERIAL format: tablname_idname_seq (ie,
product_id_seq), slightly different from the current
"product_seq". So the postgresconnection could pull table
name and idfield name, and both request and generate the
appropriate sequence name. I'll create a patch sometime
today for this.
As far as SQLObject using this, no change is necessary
(beyond referring to the appropriate sequence mentioned
above). Calling NEXTVAL and inserting (instead of letting
the default made by SERIAL be used) works completely fine,
and works if you have both SQLObject and other DB tools
creating records.
- Luke
|