On Sat, Aug 20, 2011 at 11:15:20PM +0000, Mark wrote:
> How would I do this in SQLObject? 
> 
> UPDATE
>     Table
> SET
>     some_text = CONCAT(some_text, 'text')
> WHERE
>     id = 57
> 
> Is it just
> 
> table = Table.get(57)
> table.some_text = table.some_text + "text"

   It depends on what you really want. Functionally, your SQL and python
code do the same thing but in different ways. SQL code works on the
server side and doesn't update the client side; python code performs
concatenation on the client side and sends an UPDATE like that:

UPDATE table SET some_text = new_text WHERE id = 57

   If you really want to call CONCAT or any other function do it in
SQLObject like this:

from sqlobject.sqlbuilder import Update, func
connection.query(
    Update(Table.sqlmeta.table,
        {'some_text': func.CONCAT(Table.q.some_text, 'text')},
        Test.q.id==57))

   You have to ask SQLObject to update the client side because
you updated the server side and you don't want python and SQL sides to
by desynchronized:

table.sync()

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to