Re: [SQLObject] Strange ForeignKey behavior...
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Oleg B. <ph...@ph...> - 2015-12-23 22:09:47
|
On Wed, Dec 23, 2015 at 08:35:10PM +0100, Oleg Broytman <ph...@ph...> wrote:
> Hi!
> On Wed, Dec 23, 2015 at 12:09:27PM -0500, Nathan Edwards <nj...@ge...> wrote:
> >
> > >> I'll see if I can figure out a minimalist patch to
> > >> propose...
> > >
> > > Eagerly waiting! But if you don't succeed notify me -- I'll at least
> > > add a TODO item.
> >
> > Not sure if this will be up to your coding standards, but here is an
> > attempt - it uses the validator infrastructure to attempt conversion
> > using the idType function of the foreign table.
> >
> > Patch for col.py and a new test module attached.
>
> Thank you! I need to work on it: the test doesn't work with Postgres;
> I'd like to rename 'to_python' to 'from_python' and remove 'from_python'
> assignment (I think there is no need to validate foreign keys when
> they're fetched from the database); and I want to fix style.
I fixed all that but in required a few major changes.
1. Postgres. Until now SQLObject used to create ForeignKeys of type
idType of the current table, i.e. usually INT. I fixed that (by adding a
lookup of idType of the referenced table), but that a big
backward-incompatible change and I don't want to apply it to bugfix
releases. So I think the patches will go to 2.2.0b2 and 3.0.0a2.
2. 'to_python' => 'from_python': works.
3. Test applied, but I have to create a helper function to setup
mutually referenced classes; before that test framework didn't work with
cyclic references (but see test_cyclic_reference.py).
4. Style mostly fixed. I'll do more fixes when merge the code into
branch 3.0.
> > Cheers!
> >
> > - n
> >
> > --
> > Dr. Nathan Edwards nj...@ge...
> > Department of Biochemistry and Molecular & Cellular Biology
> > Georgetown University Medical Center
> > Room 1217, Harris Building,
> > 3300 Whitehaven St, NW, Washington DC 20007
> > Phone: 202-687-7042, Fax: 202-687-0057
Oleg.
--
Oleg Broytman http://phdru.name/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|