[CDBI] Dealing with non-required primary keys
rustyp at freeshell.org
Sun Sep 4 12:24:35 BST 2005
While it's impossible to have keys that have no values inside the RDBMS,
you can certainly have ones that don't have to be input with an insert
command. There is such a thing in every RDBMS that I've tried.
On Sun, 2005-09-04 at 05:17 -0500, Peter Speltz wrote:
> I think your subject reveals your trouble: "non-required primary
> keys". There is no such thing. It seems what you are worried about
> is locking into a single RDBMS by having to declare "sequence" or not
> and that the code written to not do this is not good enough.
Looking at the individual subclasses of Class::DBI, it looks like the
subclasses themselves all declare sequences. Is there code somewhere
that I'm not aware of to not require sequences at all?
> believe Class::DBI::Loader will set up autoinc PKs correctly based
> on the RDBMS specified in the dbi connection string but it is using
> the code in specific drivers.
Class::DBI::Loader is just automagic to get the proper superclasses to
work. It doesn't do anything with autoincs. The setting up of the
autoinc PKs is handled by subclasses of Class::DBI, such as
Class::DBI::Pg, Class::DBI::MySQL, etc.
> It seems your solution would be to patch the specific drivers for each
> RDBMS you want to use so they work.
I guess that's one way. There's a lot of brokenness in them, though.
It also means only using the databases that have Class::DBI drivers and
hoping that they continue to work forever.
A database-agnostic way would be to have a way to specify that
Class::DBI doesn't have to worry about certain primary keys because the
database will take care of it. But if that's impossible right now, then
it's impossible. In which case, may I suggest a change to Class::DBI to
make it possible? How about allowing this behaviour (ignoring the
primary keys during insert) when the "use sequence" command has no
arguments? I'd be happy to implement it and send in a patch.
> ClassDBI mailing list
> ClassDBI at lists.digitalcraftsmen.net
More information about the ClassDBI