Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 4 and Version 5 of SqlObjectGotchas


Ignore:
Timestamp:
03/06/08 21:05:42 (11 years ago)
Author:
Chris Arndt
Comment:

migrated

Legend:

Unmodified
Added
Removed
Modified
  • SqlObjectGotchas

    v4 v5  
    1 SqlObject does not catch and re-throw the exceptions of the underlying DB-API module. Instead you will get the exceptions of the DB-API module directly in your face, like an !IntegrityError if you hit a constraint violation. 
    2  
    3 I haven't seen a sensible way to intercept those exceptions, yet, something like 
    4  
    51{{{ 
    6 #!python 
    7 try: 
    8    ... 
    9 except hub.hub.getConnection().module.IntegrityError, e: 
    10    ... 
     2#!rst 
     3.. note:: This page has been migrated to http://docs.turbogears.org/1.0/SqlObjectGotchas 
    114}}} 
    125 
    13 just seems to be too kludgy ... 
    146 
    15 Question: Maybe this is a bug in SQLObject? 
    167 
    17 = Using PickleCol and MySQL = 
    18  
    19 {{{ 
    20     some_field = PickleCol() 
    21 }}} 
    22  
    23 Will create a TINYBLOB column in MySQL, which can only hold 256 bytes. Depending on the data you're throwing at it, this may be OK, but if you start getting "Pickle data truncated" errors, add a length to the PickleCol, like so: 
    24  
    25 {{{ 
    26     some_field = PickleCol( length=2**24 ) 
    27 }}} 
    28  
    29 This will give you more room to pickle stuff.  
    30  
    31 Check the MySQL docs to see what length values will map to MEDIUMBLOB and LARGEBLOB, if you need to be precise. 
    32  
    33 = Using a Column named 'dirty' = 
    34  
    35 I've spent the last few hours tackling a confusing problem in 
    36 SQLObject, and thought I might post the experience to help other 
    37 TurboGear people. 
    38  
    39 I have a table, which has a column named 'dirty' of type Boolean. 
    40  
    41 Something was mysteriously setting this bit to false. I hunted though 
    42 all my code, and could not find any code which was generating the 
    43 update statement: 
    44 {{{ 
    45     UPDATE xxx SET dirty = ('f') WHERE id = (XXX) 
    46 }}} 
    47 As it turns out, one cannot use a field named 'dirty' in SQLObject 
    48 classes, as it is an internal attribute used by SQLObject. Everytime 
    49 SQLObject sets this attribute, (which was now a property) it triggered 
    50 a SQL update operation. 
    51  
    52 I renamed the field, and the problem went away.