Golemon, Buck | 1 Jul 02:19 2008
Picon

Re: SO test results

Thanks for looking at this.

I've submitted some tests for the default styles in the tracker. 
http://sourceforge.net/tracker/index.php?func=detail&aid=2007233&group_i
d=74338&atid=540674

--Buck

-----Original Message-----
From: sqlobject-discuss-bounces <at> lists.sourceforge.net
[mailto:sqlobject-discuss-bounces <at> lists.sourceforge.net] On Behalf Of
Oleg Broytmann
Sent: Monday, June 30, 2008 2:20 PM
To: sqlobject-discuss <at> lists.sourceforge.net
Subject: Re: [SQLObject] SO test results

Hello!

   Please bear in mind that I use Postgres and SQLite; I stopped using
MySQL long time ago, so I cannot fix MySQL-related problems. I have to
rely
on other people's patches.

On Mon, Jun 30, 2008 at 01:21:16PM -0700, Golemon, Buck wrote:
> Here are my test results for the SO test suite. Some sources of
errors:
> 
> * Many of the asserts use a string where the MySQLdb cursor returns
and
> integer.
(Continue reading)

Golemon, Buck | 1 Jul 04:12 2008
Picon

Join-search?

Given a graph of tables with ForeignKeys and MultipleJoins, what's the
best/easiest way to find how to join two arbitrary tables?

Thanks!
--Buck

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Oleg Broytmann | 1 Jul 08:16 2008
X-Face
Picon

Re: Join-search?

On Mon, Jun 30, 2008 at 07:12:42PM -0700, Golemon, Buck wrote:
> Given a graph of tables with ForeignKeys and MultipleJoins, what's the
> best/easiest way to find how to join two arbitrary tables?

   Either to do it manually, or using magic attribute .throughTo (which
I don't fully understand myself).
   See http://sqlobject.org/News.html#sqlobject-0-10-0 ,
tests/test_select_through.py, tests/test_sqlbuilder_joins_instances.py.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Oleg Broytmann | 1 Jul 18:29 2008
X-Face
Picon

Re: Decimals in sqlite

On Thu, Feb 14, 2008 at 07:31:10PM +0300, Oleg Broytmann wrote:
>    DecimalCol will not be changed. I will add documentation explaining the
> type affinity problem in SQLite.
>    There will be a new DecimalStringCol that stores Decimals as text.

   It is now in the trunk.

> If
> you want quantization please write a validator class, and I will include it
> into SQLObject. Initially it will be off, but a user can easily use it
> - every column has a "validator" keyword argument.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Christopher Singley | 1 Jul 19:52 2008
Picon

Re: Decimals in sqlite

On Tuesday 01 July 2008 11:29:56 Oleg Broytmann wrote:
> On Thu, Feb 14, 2008 at 07:31:10PM +0300, Oleg Broytmann wrote:
> >    DecimalCol will not be changed. I will add documentation explaining
> > the type affinity problem in SQLite.
> >    There will be a new DecimalStringCol that stores Decimals as text.
>
>    It is now in the trunk.
>
> > If
> > you want quantization please write a validator class, and I will include
> > it into SQLObject. Initially it will be off, but a user can easily use it
> > - every column has a "validator" keyword argument.
>
> Oleg.

Oleg,

Thank you.  I'd be happy to write a validator, if I can figure out how it 
should work.

For the special case of CurrencyCol, which has  precision known in advance, 
this is easy:

=====
class CurrencyValidator(sqlobject.col.DecimalValidator):
    HUNDREDTHS = Decimal('9.99')

    def to_python(self, value, state):
        value = super(CurrencyValidator, self).to_python(value, state)
        if isinstance(value, Decimal):
(Continue reading)

Oleg Broytmann | 1 Jul 20:53 2008
X-Face
Picon

Re: Decimals in sqlite

On Tue, Jul 01, 2008 at 12:52:31PM -0500, Christopher Singley wrote:
> class Example(sqlobject.SQLObject):
>     value = sqlobject.DecimalCol(size=10, precision=precision,
>         validator=PreciseDecimalValidator(precision=precision))
> 
> But this is very inelegant.  Is there a way to use introspection instead?

   I do not consider this as inelegant. But we can decide to add an
additional parameter:

class Example(sqlobject.SQLObject):
    value = sqlobject.DecimalCol(size=10, precision=precision,
        quantize=precision)

   DecimalCol will pass the 'quantize' parameter down to the validator.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
Oleg Broytmann | 1 Jul 20:56 2008
X-Face
Picon

Re: Decimals in sqlite

On Tue, Jul 01, 2008 at 10:53:16PM +0400, Oleg Broytmann wrote:
>    we can decide to add an
> additional parameter:
> 
> class Example(sqlobject.SQLObject):
>     value = sqlobject.DecimalCol(size=10, precision=precision,
>         quantize=precision)

   Or, if 'quantize' is always equal to precision, that could be

class Example(sqlobject.SQLObject):
    value = sqlobject.DecimalCol(size=10, precision=precision,
        quantize=True)

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
Christopher Singley | 1 Jul 22:17 2008
Picon

Re: Decimals in sqlite

On Tuesday 01 July 2008 13:56:26 Oleg Broytmann wrote:
>    Or, if 'quantize' is always equal to precision

Since I believe the intent is to enforce consistency between the Python model 
and the persistent storage, that should be the case.

> class Example(sqlobject.SQLObject):
>     value = sqlobject.DecimalCol(size=10, precision=precision,
>         quantize=True)

How about something like this?

class DecimalStringValidator(DecimalValidator):
    def __init__(self, *args, **kw):
        size = kw.pop('size', NoDefault)
        precision = kw.pop('precision', NoDefault)
        assert precision >= 0, \
                "You must give a precision argument as a positive integer"
        self.precision = Decimal(10) ** (-1 * int(precision))
        super(DecimalStringValidator, self).__init__(*args, **kw)

    def to_python(self, value, state):
        value = super(DecimalStringValidator, self).to_python(value, state)
        if isinstance(value, Decimal):
            value = value.quantize(self.precision)
        return value

    def from_python(self, value, state):
        value = super(DecimalStringValidator, self).from_python(value, state)
        if isinstance(value, Decimal):
(Continue reading)

Oleg Broytmann | 1 Jul 22:55 2008
X-Face
Picon

Re: Decimals in sqlite

On Tue, Jul 01, 2008 at 03:17:14PM -0500, Christopher Singley wrote:
> How about something like this?

   It looks good. I will test it and add to the trunk. Thank you!

> class DecimalStringValidator(DecimalValidator):
>     def __init__(self, *args, **kw):
>         size = kw.pop('size', NoDefault)
>         precision = kw.pop('precision', NoDefault)
>         assert precision >= 0, \
>                 "You must give a precision argument as a positive integer"
>         self.precision = Decimal(10) ** (-1 * int(precision))
>         super(DecimalStringValidator, self).__init__(*args, **kw)
> 
>     def to_python(self, value, state):
>         value = super(DecimalStringValidator, self).to_python(value, state)
>         if isinstance(value, Decimal):
>             value = value.quantize(self.precision)
>         return value
> 
>     def from_python(self, value, state):
>         value = super(DecimalStringValidator, self).from_python(value, state)
>         if isinstance(value, Decimal):
>             value = value.quantize(self.precision)
>         return value
> 
> class SODecimalStringCol(SOStringCol):
>     def __init__(self, **kw):
>         self.size = kw.pop('size', NoDefault)
>         assert self.size >= 0, \
(Continue reading)

Daniel Fetchinson | 3 Jul 20:01 2008

sqlobject schema migration

Does anyone know of a tool that makes sqlobject db schema migration easy?

Cheers,
Daniel
--

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08

Gmane