Oleg Broytmann | 1 Oct 19:07
X-Face
Picon
Favicon

Re: Inheritance and signals

On Sun, Sep 28, 2008 at 06:01:24PM -0400, David Turner wrote:
> I have written a patch for this.  Since I noticed the change in the
> inheritance system, that's where the test for it ended up going.  If
> this is OK with you, I'll commit it.

   Ok from me. It passed the test suite in the trunk.

   Are you going to backport it to 0.9 and 0.10? Actually I think the diff
has been created against 0.10 - I had a minor problem applying in to the
trunk.

Oleg.
--

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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Leandro Sales | 1 Oct 19:34
Picon
Gravatar

Re: Query using ends with

On Tue, Sep 30, 2008 at 7:19 PM, Leandro Sales <leandroal <at> gmail.com> wrote:
>
> Hello. Please consider the following: I have a sqlobject object named
> Domain that stores the list of available domains:
>
> class Domain(SQLObject):
>    name = StringCol(alternateID=True, length=255, default=None)
>
> In the database I have domains like:
>
> ID    name
> --------------------------
> 1     domain1.com
> 2     domain2.com
>
> I'd like to query the domain into the database that contains in a
> given hostname, lets say "www.domain1.com".
>
> I now that I can do something like:
>
> domain = Domain.select(Domain.q.name.endswith("www.domain1.com"))
>
> but instead, I'd check which domain name is in the hostname. Somethink like:
>
> domain = Domain.select("www.domain1.com".endswith(Domain.q.name.endswith()))
>
> .. but sqlobject doesn't allow me to do this. Any clue?
>
> Thank you,
> Leandro.
(Continue reading)

Oleg Broytmann | 1 Oct 19:59
X-Face
Picon
Favicon

Re: Query using ends with

On Wed, Oct 01, 2008 at 02:34:16PM -0300, Leandro Sales wrote:
> On Tue, Sep 30, 2008 at 7:19 PM, Leandro Sales <leandroal <at> gmail.com> wrote:
> > but instead, I'd check which domain name is in the hostname. Somethink like:
> >
> > domain = Domain.select("www.domain1.com".endswith(Domain.q.name.endswith()))

   I don't understand what query you are going to build. Can you elaborate?

Oleg.
--

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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Oleg Broytmann | 1 Oct 20:29
X-Face
Picon
Favicon

Re: Query using ends with

On Wed, Oct 01, 2008 at 03:19:14PM -0300, Leandro Sales wrote:
> SELECT * FROM domain WHERE LOCATE(name, hostname);

   Try:

from sqlobject.sqlbuilder import func
Domain.select(func.LOCATE(Domain.q.name, hostname))

Oleg.
--

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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Leandro Sales | 1 Oct 20:30
Picon
Gravatar

Re: Query using ends with

On Wed, Oct 1, 2008 at 3:19 PM, Leandro Sales <leandroal <at> gmail.com> wrote:
> I'd like a sqlobject query that does:
>
> Domain table:
> id       name
> 1        domain1.com
> 2        domain2.com
> 3        domain3.com
>
> hostname = 'www.domain1.com'
>
> SELECT * FROM domain WHERE hostname LIKE CONCAT('%', name);
>
> or in a similar way:
>
> SELECT * FROM domain WHERE LOCATE(name, hostname);
>
> The problem in the second approach (though I think it is more
> efficient and the first one), is if the variable hostname is
> "www.domain1.com.br", the query is still valid, but it shouldn't be.
>
> So, what is the best way to do what I need?
>
> Thank you,
> Leandro.
>
>
> On Wed, Oct 1, 2008 at 2:59 PM, Oleg Broytmann <phd <at> phd.pp.ru> wrote:
>> On Wed, Oct 01, 2008 at 02:34:16PM -0300, Leandro Sales wrote:
>>> On Tue, Sep 30, 2008 at 7:19 PM, Leandro Sales <leandroal <at> gmail.com> wrote:
(Continue reading)

Leandro Sales | 1 Oct 20:41
Picon
Gravatar

Re: Query using ends with

On Wed, Oct 1, 2008 at 3:29 PM, Oleg Broytmann <phd <at> phd.pp.ru> wrote:
> On Wed, Oct 01, 2008 at 03:19:14PM -0300, Leandro Sales wrote:
>> SELECT * FROM domain WHERE LOCATE(name, hostname);
>
>   Try:
>
> from sqlobject.sqlbuilder import func
> Domain.select(func.LOCATE(Domain.q.name, hostname))
>
> Oleg.
> --
>     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
>           Programmers don't die, they just GOSUB without RETURN.
>

I don't want to use LOCATE due to what I comment (in some cases it
matches a wrong record for my case). I want the record of the Domain
table that the field domain.name matches with the end of the variable
'hostname'. This works:

qname = "www.domain1.com"
domain = Domain.select("""'""" + qname + """' LIKE CONCAT('%', domain.name)""")

The question is, is there a better way (more efficient) to do this
using sqlobject?

Thank you,
Leandro.

-------------------------------------------------------------------------
(Continue reading)

Oleg Broytmann | 1 Oct 21:11
X-Face
Picon
Favicon

Re: Query using ends with

On Wed, Oct 01, 2008 at 03:41:09PM -0300, Leandro Sales wrote:
> qname = "www.domain1.com"
> domain = Domain.select("""'""" + qname + """' LIKE CONCAT('%', domain.name)""")

from sqlobject.sqlbuilder import SQLConstant
domain = Domain.select(SQLConstant('www.domain1.com').endswith(Domain.q.name))

Oleg.
--

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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Leandro Sales | 1 Oct 21:16
Picon
Gravatar

Lazy query

Hi,
  I have an sqloject object (ObjectParent) that contains others
sqlobject objects (OtherObject):

class ObjectParent(SQLObject):
    name = StringCol(alternateID=True, length=255, default=None)
    objects = MultipleJoin("OtherObject", joinColumn="objectId")

class OtherObject(SQLObject):
    name = StringCol(alternateID=True, length=255, default=None)
    object = ForeignKey('ObjectParent', dbName='objectId', cascade=True)

Then if I do

 x = ObjectParent.select(some_query)

... aparrently sqlobject loads also x.objects, selecting all related
objects. Is it possible to tell to sqlobject to query the records only
when I read x.objects for the first time?

Thank you,
Leandro.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Oleg Broytmann | 1 Oct 21:32
X-Face
Picon
Favicon

Re: Lazy query

On Wed, Oct 01, 2008 at 04:16:53PM -0300, Leandro Sales wrote:
>  x = ObjectParent.select(some_query)
> 
> ... aparrently sqlobject loads also x.objects, selecting all related
> objects.

   Why do you think SO does that?

print ObjectParent.select()

=> SELECT object_parent.id, object_parent.name FROM object_parent WHERE 1 = 1

Oleg.
--

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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Leandro Sales | 1 Oct 21:40
Picon
Gravatar

Re: Lazy query

On Wed, Oct 1, 2008 at 4:32 PM, Oleg Broytmann <phd <at> phd.pp.ru> wrote:
> On Wed, Oct 01, 2008 at 04:16:53PM -0300, Leandro Sales wrote:
>>  x = ObjectParent.select(some_query)
>>
>> ... aparrently sqlobject loads also x.objects, selecting all related
>> objects.
>
>   Why do you think SO does that?
>
> print ObjectParent.select()
>
> => SELECT object_parent.id, object_parent.name FROM object_parent WHERE 1 = 1
>
> Oleg.
> --
>     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
>           Programmers don't die, they just GOSUB without RETURN.
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> sqlobject-discuss mailing list
> sqlobject-discuss <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>

In fact, I run one example using debug=1 and the SQL queries mixed
(Continue reading)


Gmane