Re: :auto-increment support for primary keys MySQL only
Holger Schauer <[email protected]> Mon, 28 Feb 2011 08:50:33 +0100
| Newsgroups | gmane.lisp.clsql.general |
|---|---|
| Message-ID | <[email protected]> |
On 6384 September 1993, Holger Schauer wrote:
[:autoincrement for Postgres]
> So the select should probably move to a backend specific method. I'll
> see if I can come up with a patch in the next days.
After digging into the code (on head) and thinking things over, I just
stumbled upon the autoincrement branch by Nathan, which pretty much
goes in the same direction as what I had started.
Nathan, if you don't mind, I'll start from there but will move into a
slightly different direction. The Postgres code you implemented relies
on a Postgres implementation detail, namely that usage of the "serial"
db-type will generate a sequence <tablename>_<columnname>_seq.
But currently there is no code mapping :autoincrement to db-type
"serial", AFAICS. So, if users would just specify :autoincrement on an
integer db-type column, the code is probably not going to work because
no appropriate sequence is available.
Hence, I would suggest going the way of adding a new (mostly internal)
slot autoincrement-sequence to view-class-slot-definition-mixin which
should store the sequence. database-generate-column-definition would
then, upon finding an autoincrement keyword in the constraints,
generate the appropriate sequence (if no other is specified).
This could also be re-used for mysql later on, based on the sequence
stuff in mysql-sql.
Comments?
Holger
--
--- http://hillview.1on.de/ ---
"Seit wir den Source lesen fuehlt sich Dein C viel kraeftiger an. Es kommt
eben doch darauf an, dass man das richtige Betriebssystem verwendet."
-- Kristian Koehntopp in de.comp.os.unix.linux.misc