Re: [SQLObject] Final patch for 0.4 with unit tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Matt G. <ma...@po...> - 2003-07-01 15:56:14
|
This is just a quick thought, and probably something for a later
release, but couldn't an alphanumeric id be expressed something like
this:
class Pet(SQLObject):
id =3D IdCol(type=3D'alpha', length=3D32)
code =3D StringCol()
name =3D StringCol()
toyID =3D IntCol(foreignKey=3D'Toy')
_joins =3D [...]
class Toy(SQLObject):
name =3D StringCol()
Note that Toy does not specify the id attribute and so uses the
automatically generated version, as currently implemented.
Sorry if I am repeating things that have already been discussed, I have
not been following the SQLObject mailing list properly until recently.
Cheers, Matt
On Tue, 2003-07-01 at 15:54, Fran=E7ois Girault wrote:
> Hello,
>=20
> I've made some tests around the features I added.
>=20
> While testing, I had to add another change : cause of alphanum ID, table =
creation was wrong and insert failed.
>=20
> So, that must be specified in the class with _idAlpha and _idLength attri=
bute.
>=20
> Same for relation : joinFieldAlpha and otherFieldAlpha are used to specif=
y this. I *know* that field size is missing, so intermediate table generati=
on has hard-coded field size (16 caracter yet).
>=20
> But, as Ian says that relation object design will move in 0.5, I haven't =
tried to specify size by another attribute (joinFieldLength and otherFieldL=
ength by example) because *I* don't need to generate table at runtime (the =
database is already generated when I launch my client)
>=20
> class Pet(SQLObject):
> _idAlpha =3D True
> _idLength =3D 16
> code =3D StringCol()
> name =3D StringCol()
> favoriteToyID =3D IntCol(foreignKey=3D'Toy')
> _joins =3D [RelatedJoin('Toy', joinField=3D'code', joinFieldAlpha=3DT=
rue, joinColumn=3D'pet_code', otherColumn=3D'toy_code', otherField=3D'alpha=
Code', otherFieldAlpha=3DTrue, intermediateTable=3D'pet_toy')]
>=20
> class Toy(SQLObject):
> alphaCode =3D StringCol(alternateID=3DTrue)
> name =3D StringCol()
>=20
>=20
> Note again that it works for *postgres only*
>=20
> Fran=E7ois
--=20
Matt Goodall, Pollenation Internet Ltd
w: http://www.pollenation.net
e: ma...@po...
|