Re: [SQLObject] PATCH: adds support for an interval timedelta column
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Matthew W. <ma...@tp...> - 2009-05-14 14:32:52
|
On Thu 14 May 2009 10:18:47 AM EDT, Matthew Wilson wrote: > On Wed 13 May 2009 04:35:59 PM EDT, Oleg Broytmann wrote: >> On Wed, May 13, 2009 at 08:05:26PM +0000, Matthew Wilson wrote: >>> > IWBN to have a test also. >>> >>> I completely agree; can you point me to where in the code I should write >>> the test? Also, are there any tests I can use as a guide? >> >> Any test script would be ok - I'll convert it to the test suit myself. >> But of course a test in SQLObject style would be even better. >> SQLObject uses py.test as its testing environment. You can find a lot of >> tests in sqlobject/tests/ directory. Here's another test, added to the bottom of test_converters.py: $ svn diff test_converters.py Index: test_converters.py =================================================================== --- test_converters.py (revision 3881) +++ test_converters.py (working copy) @@ -1,4 +1,5 @@ import sys +from datetime import timedelta from sqlobject.sqlbuilder import sqlrepr from sqlobject.sqlbuilder import SQLExpression, SQLObjectField, \ Select, Insert, Update, Delete, Replace, \ @@ -195,3 +196,8 @@ pass else: assert sqlrepr(Set([1])) == "(1)" + +def test_timedeltas(): + + assert sqlrepr(timedelta(seconds=30*60)) == \ + "INTERVAL '0 days 1800 seconds'" By the way, how do I write a converter that converts a python object one way for one database (sqlite) and another way for another database (postgres)? Are there any examples of this already? |