sqlobject-cvs Mailing List for SQLObject (Page 157)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
(9) |
Apr
(74) |
May
(29) |
Jun
(16) |
Jul
(28) |
Aug
(10) |
Sep
(57) |
Oct
(9) |
Nov
(29) |
Dec
(12) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(7) |
Feb
(14) |
Mar
(6) |
Apr
(3) |
May
(12) |
Jun
(34) |
Jul
(9) |
Aug
(29) |
Sep
(22) |
Oct
(2) |
Nov
(15) |
Dec
(52) |
| 2005 |
Jan
(47) |
Feb
(78) |
Mar
(14) |
Apr
(35) |
May
(33) |
Jun
(16) |
Jul
(26) |
Aug
(63) |
Sep
(40) |
Oct
(96) |
Nov
(96) |
Dec
(123) |
| 2006 |
Jan
(159) |
Feb
(144) |
Mar
(64) |
Apr
(31) |
May
(88) |
Jun
(48) |
Jul
(16) |
Aug
(64) |
Sep
(87) |
Oct
(92) |
Nov
(56) |
Dec
(76) |
| 2007 |
Jan
(94) |
Feb
(103) |
Mar
(126) |
Apr
(123) |
May
(85) |
Jun
(11) |
Jul
(130) |
Aug
(47) |
Sep
(65) |
Oct
(70) |
Nov
(12) |
Dec
(11) |
| 2008 |
Jan
(30) |
Feb
(55) |
Mar
(88) |
Apr
(20) |
May
(50) |
Jun
|
Jul
(38) |
Aug
(1) |
Sep
(9) |
Oct
(5) |
Nov
(6) |
Dec
(39) |
| 2009 |
Jan
(8) |
Feb
(16) |
Mar
(3) |
Apr
(33) |
May
(44) |
Jun
(1) |
Jul
(10) |
Aug
(33) |
Sep
(74) |
Oct
(22) |
Nov
|
Dec
(15) |
| 2010 |
Jan
(28) |
Feb
(22) |
Mar
(46) |
Apr
(29) |
May
(1) |
Jun
(1) |
Jul
(27) |
Aug
(8) |
Sep
(5) |
Oct
(33) |
Nov
(24) |
Dec
(41) |
| 2011 |
Jan
(4) |
Feb
(12) |
Mar
(35) |
Apr
(29) |
May
(19) |
Jun
(16) |
Jul
(32) |
Aug
(25) |
Sep
(5) |
Oct
(11) |
Nov
(21) |
Dec
(12) |
| 2012 |
Jan
(3) |
Feb
(4) |
Mar
(20) |
Apr
(4) |
May
(25) |
Jun
(13) |
Jul
|
Aug
|
Sep
(2) |
Oct
(25) |
Nov
(9) |
Dec
(1) |
| 2013 |
Jan
(6) |
Feb
(8) |
Mar
|
Apr
(10) |
May
(31) |
Jun
(7) |
Jul
(18) |
Aug
(33) |
Sep
(4) |
Oct
(16) |
Nov
|
Dec
(27) |
| 2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(11) |
May
(39) |
Jun
(8) |
Jul
(11) |
Aug
(4) |
Sep
|
Oct
(27) |
Nov
|
Dec
(71) |
| 2015 |
Jan
(17) |
Feb
(47) |
Mar
(33) |
Apr
|
May
|
Jun
(9) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
| 2016 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
(12) |
Jun
(7) |
Jul
(9) |
Aug
(31) |
Sep
(8) |
Oct
(3) |
Nov
(15) |
Dec
(1) |
| 2017 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(8) |
May
(10) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(4) |
Dec
(5) |
| 2018 |
Jan
(2) |
Feb
(8) |
Mar
|
Apr
(4) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
(1) |
Feb
(16) |
Mar
(1) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
| 2021 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
(1) |
Dec
(4) |
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
|
| 2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
| 2025 |
Jan
|
Feb
(4) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
|
From: <sub...@co...> - 2005-10-25 21:36:55
|
Author: test
Date: 2005-10-25 21:36:42 +0000 (Tue, 25 Oct 2005)
New Revision: 1138
Modified:
SQLObject/trunk/sqlobject/manager/command.py
Log:
Fix bug when sqlobject.txt doesn't exist
Modified: SQLObject/trunk/sqlobject/manager/command.py
===================================================================
--- SQLObject/trunk/sqlobject/manager/command.py 2005-10-25 19:44:00 UTC (rev 1137)
+++ SQLObject/trunk/sqlobject/manager/command.py 2005-10-25 21:36:42 UTC (rev 1138)
@@ -427,7 +427,7 @@
if not dist.has_metadata('sqlobject.txt'):
if warn_no_sqlobject:
print 'No sqlobject.txt in %s egg info' % egg_spec
- return {}
+ return None, {}
result = {}
for line in dist.get_metadata_lines('sqlobject.txt'):
line = line.strip()
@@ -436,7 +436,7 @@
name, value = line.split('=', 1)
name = name.strip().lower()
if name in result:
- print 'Warning: %s appears more than one in sqlobject.txt' % name
+ print 'Warning: %s appears more than once in sqlobject.txt' % name
result[name.strip().lower()] = value.strip()
return dist, result
|
|
From: <sub...@co...> - 2005-10-25 19:44:10
|
Author: test
Date: 2005-10-25 19:44:00 +0000 (Tue, 25 Oct 2005)
New Revision: 1137
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/sqlobject/joins.py
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/manager/command.py
Log:
Fixed sqlobject-admin record with respect to new createTableSQL return values. Allow RelatedJoin objects to have a createRelatedTable keyword argument, to suppress the automatic creation of the join table.
Modified: SQLObject/trunk/docs/News.txt
===================================================================
--- SQLObject/trunk/docs/News.txt 2005-10-25 16:45:52 UTC (rev 1136)
+++ SQLObject/trunk/docs/News.txt 2005-10-25 19:44:00 UTC (rev 1137)
@@ -23,6 +23,12 @@
* Added ``TimeCol``.
+* ``RelatedJoin`` and ``SQLRelatedJoin`` objects have a
+ ``createRelatedTable`` keyword argument (default ``True``). If
+ ``False``, then the related table won't be automatically created;
+ instead you must manually create it (e.g., with explicit SQLObject
+ classes for the joins).
+
SQLObject 0.7.0
===============
Modified: SQLObject/trunk/sqlobject/joins.py
===================================================================
--- SQLObject/trunk/sqlobject/joins.py 2005-10-25 16:45:52 UTC (rev 1136)
+++ SQLObject/trunk/sqlobject/joins.py 2005-10-25 19:44:00 UTC (rev 1137)
@@ -154,9 +154,12 @@
def __init__(self,
otherColumn=None,
- intermediateTable=None, **kw):
+ intermediateTable=None,
+ createRelatedTable=True,
+ **kw):
self.intermediateTable = intermediateTable
self.otherColumn = otherColumn
+ self.createRelatedTable = createRelatedTable
SOMultipleJoin.__init__(self, **kw)
classregistry.registry(
self.soClass.sqlmeta.registry).addClassCallback(
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2005-10-25 16:45:52 UTC (rev 1136)
+++ SQLObject/trunk/sqlobject/main.py 2005-10-25 19:44:00 UTC (rev 1137)
@@ -1329,6 +1329,9 @@
def createJoinTables(cls, ifNotExists=False, connection=None):
conn = connection or cls._connection
for join in cls._getJoinsToCreate():
+ if not getattr(join, 'createRelatedTable', True):
+ # This join has requested not to be created
+ continue
if (ifNotExists and
conn.tableExists(join.intermediateTable)):
continue
@@ -1339,6 +1342,9 @@
conn = connection or cls._connection
sql = []
for join in cls._getJoinsToCreate():
+ if not getattr(join, 'createRelatedTable', True):
+ # This join has requested not to be created
+ continue
sql.append(conn._SO_createJoinTableSQL(join))
return '\n'.join(sql)
createJoinTablesSQL = classmethod(createJoinTablesSQL)
Modified: SQLObject/trunk/sqlobject/manager/command.py
===================================================================
--- SQLObject/trunk/sqlobject/manager/command.py 2005-10-25 16:45:52 UTC (rev 1136)
+++ SQLObject/trunk/sqlobject/manager/command.py 2005-10-25 19:44:00 UTC (rev 1137)
@@ -859,6 +859,12 @@
+ '_' + dbName + '.sql')
if sim:
continue
+ create, constraints = cls.createTableSQL()
+ if constraints:
+ constraints = '\n-- Constraints:\n%s\n' % (
+ '\n'.join(constraints))
+ else:
+ constraints = ''
files[fn] = ''.join([
'-- Exported definition from %s\n'
% time.strftime('%Y-%m-%dT%H:%M:%S'),
@@ -866,8 +872,9 @@
% (cls.__module__, cls.__name__),
'-- Database: %s\n'
% dbName,
- cls.createTableSQL().strip(),
- '\n'])
+ create.strip(),
+ '\n',
+ constraints])
last_version_dir = self.find_last_version()
if last_version_dir and not self.options.force_create:
if v > 1:
|
Author: phd Date: 2005-10-25 16:45:52 +0000 (Tue, 25 Oct 2005) New Revision: 1136 Added: SQLObject/trunk/sqlobject/tests/test_string_id.py Modified: SQLObject/trunk/docs/FAQ.txt SQLObject/trunk/docs/SQLObject.txt SQLObject/trunk/sqlobject/col.py SQLObject/trunk/sqlobject/firebird/firebirdconnection.py SQLObject/trunk/sqlobject/maxdb/maxdbconnection.py SQLObject/trunk/sqlobject/mssql/mssqlconnection.py SQLObject/trunk/sqlobject/mysql/mysqlconnection.py SQLObject/trunk/sqlobject/postgres/pgconnection.py SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py SQLObject/trunk/sqlobject/sybase/sybaseconnection.py Log: Applied the patch 1333498 by Jeff Bauer: String IDs. I refactored the patch and updated documentation. Modified: SQLObject/trunk/docs/FAQ.txt =================================================================== --- SQLObject/trunk/docs/FAQ.txt 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/docs/FAQ.txt 2005-10-25 16:45:52 UTC (rev 1136) @@ -279,14 +279,13 @@ Non-Integer IDs --------------- -Yes, you can use non-integer IDs, but only in CVS_ now. +Yes, you can use non-integer IDs. -.. _CVS: http://sqlobject.org/#anonymous-cvs +If you use non-integer IDs, you will not be able to use automatic ``CREATE +TABLE`` generation (i.e., ``createTable``); SQLObject can create tables +with int or str IDs. You also will have to give your own ID values when +creating an object, like:: -If you use non-integer IDs, you will not be able to use automatic -``CREATE TABLE`` generation (i.e., ``createTable``). You also will -have to give your own ID values when creating an object, like:: - color = Something(id="blue", r=0, b=100, g=0) IDs are, and always will in future versions, be considered immutable. @@ -308,7 +307,7 @@ This will be resolved in a future version when ID column types can be declared like other columns. -Additionally you can set _idType = str in you SQLObject class. +Additionally you can set idType=str in you SQLObject class. Binary Values Modified: SQLObject/trunk/docs/SQLObject.txt =================================================================== --- SQLObject/trunk/docs/SQLObject.txt 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/docs/SQLObject.txt 2005-10-25 16:45:52 UTC (rev 1136) @@ -1396,11 +1396,12 @@ Non-Integer Keys ---------------- -While not strictly a legacy database issue, this fits into the -category of "irregularities". If you use non-integer keys, all -primary key management is up to you. You must create the table -yourself, and when you create instances you must pass a ``id`` keyword -argument into constructor (like ``Person(id='555-55-5555', ...)``). +While not strictly a legacy database issue, this fits into the category of +"irregularities". If you use non-integer keys, all primary key management +is up to you. You must create the table yourself (SQLObject can create +tables with int or str IDs), and when you create instances you must pass a +``id`` keyword argument into constructor +(like ``Person(id='555-55-5555', ...)``). DBConnection: Database Connections ================================== Modified: SQLObject/trunk/sqlobject/col.py =================================================================== --- SQLObject/trunk/sqlobject/col.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/col.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -687,31 +687,22 @@ class SOKeyCol(SOCol): + key_type = {int: "INT", str: "TEXT"} # 3-03 @@: this should have a simplified constructor # Should provide foreign key information for other DBs. - def _mysqlType(self): - return 'INT' + def _sqlType(self): + return self.key_type[self.soClass.sqlmeta.idType] - def _sqliteType(self): - return 'INT' - - def _postgresType(self): - return 'INT' - def _sybaseType(self): - return 'NUMERIC(18,0) NULL' + key_type = {int: "NUMERIC(18,0) NULL", str: "TEXT"} + return key_type[self.soClass.sqlmeta.idType] def _mssqlType(self): - return 'INT NULL' + key_type = {int: "INT NULL", str: "TEXT"} + return key_type[self.soClass.sqlmeta.idType] - def _firebirdType(self): - return 'INT' - - def _maxdbType(self): - return 'INT' - class KeyCol(Col): baseClass = SOKeyCol Modified: SQLObject/trunk/sqlobject/firebird/firebirdconnection.py =================================================================== --- SQLObject/trunk/sqlobject/firebird/firebirdconnection.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/firebird/firebirdconnection.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -131,7 +131,8 @@ return col.firebirdCreateSQL() def createIDColumn(self, soClass): - return '%s INT NOT NULL PRIMARY KEY' % soClass.sqlmeta.idName + key_type = {int: "INT", str: "TEXT"}[soClass.sqlmeta.idType] + return '%s %s NOT NULL PRIMARY KEY' % (soClass.sqlmeta.idName, key_type) def createIndexSQL(self, soClass, index): return index.firebirdCreateIndexSQL(soClass) Modified: SQLObject/trunk/sqlobject/maxdb/maxdbconnection.py =================================================================== --- SQLObject/trunk/sqlobject/maxdb/maxdbconnection.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/maxdb/maxdbconnection.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -172,7 +172,8 @@ return col.maxdbCreateSQL() def createIDColumn(self, soClass): - return '%s INT PRIMARY KEY' % soClass.sqlmeta.idName + key_type = {int: "INT", str: "TEXT"}[soClass.sqlmeta.idType] + return '%s %s PRIMARY KEY' % (soClass.sqlmeta.idName, key_type) def createIndexSQL(self, soClass, index): return index.maxdbCreateIndexSQL(soClass) Modified: SQLObject/trunk/sqlobject/mssql/mssqlconnection.py =================================================================== --- SQLObject/trunk/sqlobject/mssql/mssqlconnection.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/mssql/mssqlconnection.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -129,7 +129,8 @@ return col.mssqlCreateSQL() def createIDColumn(self, soClass): - return '%s INT IDENTITY UNIQUE' % soClass.sqlmeta.idName + key_type = {int: "INT", str: "TEXT"}[soClass.sqlmeta.idType] + return '%s %s IDENTITY UNIQUE' % (soClass.sqlmeta.idName, key_type) def createIndexSQL(self, soClass, index): return index.mssqlCreateIndexSQL(soClass) Modified: SQLObject/trunk/sqlobject/mysql/mysqlconnection.py =================================================================== --- SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -99,6 +99,8 @@ return index.mysqlCreateIndexSQL(soClass) def createIDColumn(self, soClass): + if soClass.sqlmeta.idType == str: + return '%s TEXT PRIMARY KEY' % soClass.sqlmeta.idName return '%s INT PRIMARY KEY AUTO_INCREMENT' % soClass.sqlmeta.idName def joinSQLType(self, join): Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py =================================================================== --- SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -145,7 +145,8 @@ return index.postgresCreateIndexSQL(soClass) def createIDColumn(self, soClass): - return '%s SERIAL PRIMARY KEY' % soClass.sqlmeta.idName + key_type = {int: "SERIAL", str: "TEXT"}[soClass.sqlmeta.idType] + return '%s %s PRIMARY KEY' % (soClass.sqlmeta.idName, key_type) def dropTable(self, tableName, cascade=False): if self.server_version[:3] <= "7.2": Modified: SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py =================================================================== --- SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -120,7 +120,8 @@ return None def createIDColumn(self, soClass): - return '%s INTEGER PRIMARY KEY' % soClass.sqlmeta.idName + key_type = {int: "INTEGER", str: "TEXT"}[soClass.sqlmeta.idType] + return '%s %s PRIMARY KEY' % (soClass.sqlmeta.idName, key_type) def joinSQLType(self, join): return 'INT NOT NULL' Modified: SQLObject/trunk/sqlobject/sybase/sybaseconnection.py =================================================================== --- SQLObject/trunk/sqlobject/sybase/sybaseconnection.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/sybase/sybaseconnection.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -102,7 +102,8 @@ return col.sybaseCreateSQL() def createIDColumn(self, soClass): - return '%s NUMERIC(18,0) IDENTITY UNIQUE' % soClass.sqlmeta.idName + key_type = {int: "NUMERIC(18,0)", str: "TEXT"}[soClass.sqlmeta.idType] + return '%s %s IDENTITY UNIQUE' % (soClass.sqlmeta.idName, key_type) def createIndexSQL(self, soClass, index): return index.sybaseCreateIndexSQL(soClass) Added: SQLObject/trunk/sqlobject/tests/test_string_id.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_string_id.py 2005-10-23 13:28:07 UTC (rev 1135) +++ SQLObject/trunk/sqlobject/tests/test_string_id.py 2005-10-25 16:45:52 UTC (rev 1136) @@ -0,0 +1,17 @@ +from sqlobject import * +from sqlobject.tests.dbtest import * + +class TestStringID(SQLObject): + class sqlmeta(sqlmeta): + idType = str + idName = 'test_id_here' + name = StringCol() + +def test_string_id(): + conn = getConnection() + TestStringID.setConnection(conn) + TestStringID.dropTable(ifExists=True) + assert not conn.tableExists(TestStringID.sqlmeta.table) + TestStringID.createTable() + TestStringID(id="TestStringID", name="TestStringID name") + assert len(list(TestStringID.selectBy(id='TestStringID'))) == 1 |
|
From: <sub...@co...> - 2005-10-23 13:28:19
|
Author: phd
Date: 2005-10-23 13:28:07 +0000 (Sun, 23 Oct 2005)
New Revision: 1135
Modified:
SQLObject/trunk/sqlobject/col.py
Log:
Applied the patch N1299109 by Andy Dustman - FOREIGN KEY for MySQL.
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2005-10-22 23:27:09 UTC (rev 1134)
+++ SQLObject/trunk/sqlobject/col.py 2005-10-23 13:28:07 UTC (rev 1135)
@@ -758,6 +758,31 @@
'sTName': sTName})
return constraint
+ def mysqlCreateSQL(self):
+ sql = SOKeyCol.mysqlCreateSQL(self)
+ other = findClass(self.foreignKey, self.soClass.sqlmeta.registry)
+ tName = other.sqlmeta.table
+ idName = other.sqlmeta.idName
+ if self.cascade is not None:
+ if self.cascade == 'null':
+ action = 'ON DELETE SET NULL'
+ elif self.cascade:
+ action = 'ON DELETE CASCADE'
+ else:
+ action = 'ON DELETE RESTRICT'
+ else:
+ action = ''
+ constraint = ('CONSTRAINT %(colName)s_exists '
+ 'FOREIGN KEY (%(colName)s) '
+ 'REFERENCES %(tName)s (%(idName)s) '
+ '%(action)s' %
+ {'tName': tName,
+ 'colName': self.dbName,
+ 'idName': idName,
+ 'action': action})
+ sql = ', '.join([sql, constraint])
+ return sql
+
def sybaseCreateSQL(self):
sql = SOKeyCol.sybaseCreateSQL(self)
other = findClass(self.foreignKey)
|
|
From: <sub...@co...> - 2005-10-22 23:27:17
|
Author: ianb Date: 2005-10-22 23:27:09 +0000 (Sat, 22 Oct 2005) New Revision: 1134 Added: SQLObject/tags/0.6.1/ Log: Tagged 0.6.1 Copied: SQLObject/tags/0.6.1 (from rev 221, trunk/SQLObject) |
|
From: <sub...@co...> - 2005-10-22 23:09:51
|
Author: ianb Date: 2005-10-22 23:09:39 +0000 (Sat, 22 Oct 2005) New Revision: 1133 Modified: SQLObject/trunk/docs/DeveloperGuide.txt Log: Fixed svn url Modified: SQLObject/trunk/docs/DeveloperGuide.txt =================================================================== --- SQLObject/trunk/docs/DeveloperGuide.txt 2005-10-22 17:20:44 UTC (rev 1132) +++ SQLObject/trunk/docs/DeveloperGuide.txt 2005-10-22 23:09:39 UTC (rev 1133) @@ -25,7 +25,7 @@ Then do the same for SQLObject:: - $ svn co http://svn.colorstudy.com/trunk/SQLObject SQLObject + $ svn co http://svn.colorstudy.com/SQLObject/trunk SQLObject $ cd SQLObject $ sudo python setup.py develop |
|
From: <sub...@co...> - 2005-10-20 16:11:33
|
Author: phd
Date: 2005-10-20 16:11:21 +0000 (Thu, 20 Oct 2005)
New Revision: 1131
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py
Log:
Merged the patch from the revision 1130 from the trunk -
a patch by gary ng <li...@ga...> to guess more column types.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py 2005-10-20 16:06:43 UTC (rev 1130)
+++ SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py 2005-10-20 16:11:21 UTC (rev 1131)
@@ -245,7 +245,7 @@
def guessClass(self, t):
if t.count('int'):
return col.IntCol, {}
- elif t.count('varying'):
+ elif t.count('varying') or t.count('varchar'):
if '(' in t:
return col.StringCol, {'length': int(t[t.index('(')+1:-1])}
else: # varchar without length in Postgres means any length
@@ -253,10 +253,16 @@
elif t.startswith('character('):
return col.StringCol, {'length': int(t[t.index('(')+1:-1]),
'varchar': False}
+ elif t.count('float') or t.count('real') or t.count('double'):
+ return col.FloatCol, {}
elif t == 'text':
return col.StringCol, {}
+ elif t.startswith('timestamp'):
+ return col.DateTimeCol, {}
elif t.startswith('datetime'):
return col.DateTimeCol, {}
+ elif t.startswith('date'):
+ return col.DateCol, {}
elif t.startswith('bool'):
return col.BoolCol, {}
elif t.startswith('bytea'):
|
|
From: <sub...@co...> - 2005-10-20 16:07:07
|
Author: phd
Date: 2005-10-20 16:06:43 +0000 (Thu, 20 Oct 2005)
New Revision: 1130
Modified:
SQLObject/trunk/sqlobject/postgres/pgconnection.py
Log:
Applied a patch by gary ng <li...@ga...> to guess more column types.
Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-10-19 03:07:59 UTC (rev 1129)
+++ SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-10-20 16:06:43 UTC (rev 1130)
@@ -248,7 +248,7 @@
def guessClass(self, t):
if t.count('int'):
return col.IntCol, {}
- elif t.count('varying'):
+ elif t.count('varying') or t.count('varchar'):
if '(' in t:
return col.StringCol, {'length': int(t[t.index('(')+1:-1])}
else: # varchar without length in Postgres means any length
@@ -256,10 +256,16 @@
elif t.startswith('character('):
return col.StringCol, {'length': int(t[t.index('(')+1:-1]),
'varchar': False}
+ elif t.count('float') or t.count('real') or t.count('double'):
+ return col.FloatCol, {}
elif t == 'text':
return col.StringCol, {}
+ elif t.startswith('timestamp'):
+ return col.DateTimeCol, {}
elif t.startswith('datetime'):
return col.DateTimeCol, {}
+ elif t.startswith('date'):
+ return col.DateCol, {}
elif t.startswith('bool'):
return col.BoolCol, {}
elif t.startswith('bytea'):
|
|
From: <sub...@co...> - 2005-10-18 15:36:48
|
Author: phd
Date: 2005-10-18 15:36:42 +0000 (Tue, 18 Oct 2005)
New Revision: 1127
Modified:
home/phd/SQLObject/paramstyles/sqlobject/tests/test_datetime.py
Log:
Narrow the date workaround for PySQLite2 only.
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_datetime.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_datetime.py 2005-10-18 15:32:55 UTC (rev 1126)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_datetime.py 2005-10-18 15:36:42 UTC (rev 1127)
@@ -43,10 +43,15 @@
col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION
from mx.DateTime import now, Time
+ dateFormat = None # use default
+ if getConnection().dbName == "sqlite":
+ from sqlobject.sqlite.sqliteconnection import using_sqlite2
+ if using_sqlite2: # PySQLite2 returns full date/time for a date
+ dateFormat = "%Y-%m-%d %H:%M:%S"
+
class DateTime2(SQLObject):
col1 = DateTimeCol()
- col2 = DateCol(dateFormat="%Y-%m-%d %H:%M:%S")
- # mxDateTime does not have a separate date type
+ col2 = DateCol(dateFormat=dateFormat)
col3 = TimeCol()
def test_mxDateTime():
|
|
From: <sub...@co...> - 2005-10-18 15:33:04
|
Author: phd
Date: 2005-10-18 15:32:55 +0000 (Tue, 18 Oct 2005)
New Revision: 1126
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py
Log:
Narrow the date workaround for PySQLite2 only.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py 2005-10-18 15:31:40 UTC (rev 1125)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py 2005-10-18 15:32:55 UTC (rev 1126)
@@ -43,10 +43,15 @@
col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION
from mx.DateTime import now, Time
+ dateFormat = None # use default
+ if getConnection().dbName == "sqlite":
+ from sqlobject.sqlite.sqliteconnection import using_sqlite2
+ if using_sqlite2: # PySQLite2 returns full date/time for a date
+ dateFormat = "%Y-%m-%d %H:%M:%S"
+
class DateTime2(SQLObject):
col1 = DateTimeCol()
- col2 = DateCol(dateFormat="%Y-%m-%d %H:%M:%S")
- # mxDateTime does not have a separate date type
+ col2 = DateCol(dateFormat=dateFormat)
col3 = TimeCol()
def test_mxDateTime():
|
|
From: <sub...@co...> - 2005-10-18 15:32:21
|
Author: phd
Date: 2005-10-18 15:31:40 +0000 (Tue, 18 Oct 2005)
New Revision: 1125
Modified:
SQLObject/trunk/sqlobject/tests/test_datetime.py
Log:
Narrow the date workaround for PySQLite2 only.
Modified: SQLObject/trunk/sqlobject/tests/test_datetime.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_datetime.py 2005-10-18 15:06:59 UTC (rev 1124)
+++ SQLObject/trunk/sqlobject/tests/test_datetime.py 2005-10-18 15:31:40 UTC (rev 1125)
@@ -43,10 +43,15 @@
col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION
from mx.DateTime import now, Time
+ dateFormat = None # use default
+ if getConnection().dbName == "sqlite":
+ from sqlobject.sqlite.sqliteconnection import using_sqlite2
+ if using_sqlite2: # PySQLite2 returns full date/time for a date
+ dateFormat = "%Y-%m-%d %H:%M:%S"
+
class DateTime2(SQLObject):
col1 = DateTimeCol()
- col2 = DateCol(dateFormat="%Y-%m-%d %H:%M:%S")
- # mxDateTime does not have a separate date type
+ col2 = DateCol(dateFormat=dateFormat)
col3 = TimeCol()
def test_mxDateTime():
|
|
From: <sub...@co...> - 2005-10-18 15:07:25
|
Author: phd Date: 2005-10-18 15:06:59 +0000 (Tue, 18 Oct 2005) New Revision: 1124 Modified: home/phd/SQLObject/paramstyles/docs/Authors.txt home/phd/SQLObject/paramstyles/docs/News.txt home/phd/SQLObject/paramstyles/docs/SQLObject.txt home/phd/SQLObject/paramstyles/sqlobject/col.py home/phd/SQLObject/paramstyles/sqlobject/converters.py home/phd/SQLObject/paramstyles/sqlobject/tests/test_datetime.py Log: Merged patches from the revisions 1115:1123 from the trunk: added TimeCol. Modified: home/phd/SQLObject/paramstyles/docs/Authors.txt =================================================================== --- home/phd/SQLObject/paramstyles/docs/Authors.txt 2005-10-18 15:04:45 UTC (rev 1123) +++ home/phd/SQLObject/paramstyles/docs/Authors.txt 2005-10-18 15:06:59 UTC (rev 1124) @@ -18,4 +18,5 @@ * Yaroslav Samchuk <yarcat at ank-sia.com> * Runar Petursson <grunar at gmail.com> * J Paulo Fernandes Farias <jpaulofarias at gmail.com> +* Shahms King <shahms at shahms.com> * Oleg Broytmann <ph...@ph...> Modified: home/phd/SQLObject/paramstyles/docs/News.txt =================================================================== --- home/phd/SQLObject/paramstyles/docs/News.txt 2005-10-18 15:04:45 UTC (rev 1123) +++ home/phd/SQLObject/paramstyles/docs/News.txt 2005-10-18 15:06:59 UTC (rev 1124) @@ -21,6 +21,8 @@ Constraints (in the DBMSes that support constraints) are added after the tables have been created. +* Added ``TimeCol``. + SQLObject 0.7.0 =============== Modified: home/phd/SQLObject/paramstyles/docs/SQLObject.txt =================================================================== --- home/phd/SQLObject/paramstyles/docs/SQLObject.txt 2005-10-18 15:04:45 UTC (rev 1123) +++ home/phd/SQLObject/paramstyles/docs/SQLObject.txt 2005-10-18 15:06:59 UTC (rev 1124) @@ -1025,11 +1025,14 @@ `CurrencyCol`: Equivalent to ``DecimalCol(size=10, precision=2)``. +`DateTimeCol`: + A date and time (usually returned as an datetime or mxDateTime object). + `DateCol`: A date (usually returned as an datetime or mxDateTime object). -`DateTimeCol`: - A date and time (usually returned as an datetime or mxDateTime object). +`TimeCol`: + A time (usually returned as an datetime or mxDateTime object). `DecimalCol`: Base-10, precise number. Uses the keyword arguments `size` for @@ -1535,6 +1538,8 @@ * `ForeignKey` * `EnumCol` * `DateTimeCol` +* `DateCol` +* `TimeCol` * `DecimalCol` * `CurrencyCol` Modified: home/phd/SQLObject/paramstyles/sqlobject/col.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/col.py 2005-10-18 15:04:45 UTC (rev 1123) +++ home/phd/SQLObject/paramstyles/sqlobject/col.py 2005-10-18 15:06:59 UTC (rev 1124) @@ -60,6 +60,7 @@ if mxdatetime_available: DateTimeType = type(DateTime.now()) + TimeType = type(DateTime.Time()) if datetime_available: default_datetime_implementation = DATETIME_IMPLEMENTATION @@ -333,7 +334,7 @@ def mssqlCreateSQL(self): return ' '.join([self.dbName, self._mssqlType()] + self._extraSQL()) - + def firebirdCreateSQL(self): # Ian Sparks pointed out that fb is picky about the order # of the NOT NULL clause in a create statement. So, we handle @@ -566,15 +567,15 @@ except OverflowError: # for Python 2.2 return long(value) except: - raise validators.Invalid("expected an int in the IntCol '%s', got %s instead" % \ - (self.name, type(value)), value, state) + raise validators.Invalid("expected an int in the IntCol '%s', got %s %r instead" % \ + (self.name, type(value), value), value, state) def from_python(self, value, state): if value is None: return None if not isinstance(value, (int, long, sqlbuilder.SQLExpression)): - raise validators.Invalid("expected an int in the IntCol '%s', got %s instead" % \ - (self.name, type(value)), value, state) + raise validators.Invalid("expected an int in the IntCol '%s', got %s %r instead" % \ + (self.name, type(value), value), value, state) return value class SOIntCol(SOCol): @@ -654,15 +655,15 @@ try: return float(value) except: - raise validators.Invalid("expected a float in the FloatCol '%s', got %s instead" % \ - (self.name, type(value)), value, state) + raise validators.Invalid("expected a float in the FloatCol '%s', got %s %r instead" % \ + (self.name, type(value), value), value, state) def from_python(self, value, state): if value is None: return None if not isinstance(value, (int, long, float, sqlbuilder.SQLExpression)): - raise validators.Invalid("expected a float in the FloatCol '%s', got %s instead" % \ - (self.name, type(value)), value, state) + raise validators.Invalid("expected a float in the FloatCol '%s', got %s %r instead" % \ + (self.name, type(value), value), value, state) return value class SOFloatCol(SOCol): @@ -701,7 +702,7 @@ def _sybaseType(self): return 'NUMERIC(18,0) NULL' - + def _mssqlType(self): return 'INT NULL' @@ -870,39 +871,45 @@ def to_python(self, value, state): if value is None: return None - if isinstance(value, (datetime.date, datetime.datetime, sqlbuilder.SQLExpression)): + if isinstance(value, (datetime.datetime, datetime.date, datetime.time, sqlbuilder.SQLExpression)): return value - if mxdatetime_available and isinstance(value, DateTimeType): - # convert mxDateTime instance to datetime - if (self.format.find("%H") >= 0) or (self.format.find("%T")) >= 0: - return datetime.datetime(value.year, value.month, value.day, - value.hour, value.minute, int(value.second)) - else: - return datetime.date(value.year, value.month, value.day) + if mxdatetime_available: + if isinstance(value, DateTimeType): + # convert mxDateTime instance to datetime + if (self.format.find("%H") >= 0) or (self.format.find("%T")) >= 0: + return datetime.datetime(value.year, value.month, value.day, + value.hour, value.minute, int(value.second)) + else: + return datetime.date(value.year, value.month, value.day) + elif isinstance(value, TimeType): + # convert mxTime instance to time + if self.format.find("%d") >= 0: + return datetime.timedelta(seconds=value.seconds) + else: + return datetime.time(value.hour, value.minute, int(value.second)) try: stime = time.strptime(value, self.format) except: - raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \ - (self.format, self.name, type(value)), value, state) - secs = time.mktime(stime) - return datetime.datetime.fromtimestamp(secs) + raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \ + (self.format, self.name, type(value), value), value, state) + return datetime.datetime(*stime[:7]) def from_python(self, value, state): if value is None: return None - if isinstance(value, (datetime.date, datetime.datetime, sqlbuilder.SQLExpression)): + if isinstance(value, (datetime.datetime, datetime.date, datetime.time, sqlbuilder.SQLExpression)): return value if hasattr(value, "strftime"): return value.strftime(self.format) - raise validators.Invalid("expected a datetime in the DateTimeCol '%s', got %s instead" % \ - (self.name, type(value)), value, state) + raise validators.Invalid("expected a datetime in the DateTimeCol '%s', got %s %r instead" % \ + (self.name, type(value), value), value, state) if mxdatetime_available: class MXDateTimeValidator(validators.DateValidator): def to_python(self, value, state): if value is None: return None - if isinstance(value, (DateTimeType, sqlbuilder.SQLExpression)): + if isinstance(value, (DateTimeType, TimeType, sqlbuilder.SQLExpression)): return value if datetime_available: # convert datetime instance to mxDateTime if isinstance(value, datetime.datetime): @@ -910,22 +917,24 @@ value.hour, value.minute, value.second) elif isinstance(value, datetime.date): return DateTime.Date(value.year, value.month, value.day) + elif isinstance(value, datetime.time): + return DateTime.Time(value.hour, value.minute, value.second) try: stime = time.strptime(value, self.format) except: - raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \ - (self.format, self.name, type(value)), value, state) + raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \ + (self.format, self.name, type(value), value), value, state) return DateTime.mktime(stime) def from_python(self, value, state): if value is None: return None - if isinstance(value, (DateTimeType, sqlbuilder.SQLExpression)): + if isinstance(value, (DateTimeType, TimeType, sqlbuilder.SQLExpression)): return value if hasattr(value, "strftime"): return value.strftime(self.format) - raise validators.Invalid("expected a mxDateTime in the DateTimeCol '%s', got %s instead" % \ - (self.name, type(value)), value, state) + raise validators.Invalid("expected a mxDateTime in the DateTimeCol '%s', got %s %r instead" % \ + (self.name, type(value), value), value, state) class SODateTimeCol(SOCol): datetimeFormat = '%Y-%m-%d %H:%M:%S' @@ -984,9 +993,11 @@ if datetime_available: class DateValidator(DateTimeValidator): def to_python(self, value, state): + if isinstance(value, datetime.date): + return value value = super(DateValidator, self).to_python(value, state) if isinstance(value, datetime.datetime): - value = datetime.date(value.year, value.month, value.day) + value = value.date() return value from_python = to_python @@ -1018,7 +1029,7 @@ def _sybaseType(self): return self._postgresType() - + def _mssqlType(self): """ SQL Server doesn't have a DATE data type, to emulate we use a vc(10) @@ -1038,6 +1049,57 @@ baseClass = SODateCol +if datetime_available: + class TimeValidator(DateTimeValidator): + def to_python(self, value, state): + if isinstance(value, datetime.time): + return value + value = super(TimeValidator, self).to_python(value, state) + if isinstance(value, datetime.datetime): + value = value.time() + return value + +class SOTimeCol(SOCol): + timeFormat = '%H:%M:%S' + + def __init__(self, **kw): + timeFormat = popKey(kw, 'timeFormat') + if timeFormat: + self.timeFormat = timeFormat + SOCol.__init__(self, **kw) + + def createValidators(self): + _validators = super(SOTimeCol, self).createValidators() + if default_datetime_implementation == DATETIME_IMPLEMENTATION: + validatorClass = TimeValidator + elif default_datetime_implementation == MXDATETIME_IMPLEMENTATION: + validatorClass = MXDateTimeValidator + if default_datetime_implementation: + _validators.insert(0, validatorClass(name=self.name, format=self.timeFormat)) + return _validators + + def _mysqlType(self): + return 'TIME' + + def _postgresType(self): + return 'TIME' + + def _sybaseType(self): + return 'TIME' + + def _sqliteType(self): + return 'TIME' + + def _firebirdType(self): + return 'TIME' + + def _maxdbType(self): + return 'TIME' + +class TimeCol(Col): + baseClass = SOTimeCol + + class SODecimalCol(SOCol): def __init__(self, **kw): @@ -1091,8 +1153,8 @@ if isinstance(value, array_type): # MySQL return value.tostring() return str(value) # buffer => string - raise validators.Invalid("expected a string in the BLOBCol '%s', got %s instead" % \ - (self.name, type(value)), value, state) + raise validators.Invalid("expected a string in the BLOBCol '%s', got %s %r instead" % \ + (self.name, type(value), value), value, state) def from_python(self, value, state): if value is None: @@ -1144,8 +1206,8 @@ value = value.encode("ascii") if isinstance(value, str): return pickle.loads(value) - raise validators.Invalid("expected a pickle string in the PickleCol '%s', got %s instead" % \ - (self.name, type(value)), value, state) + raise validators.Invalid("expected a pickle string in the PickleCol '%s', got %s %r instead" % \ + (self.name, type(value), value), value, state) def from_python(self, value, state): if value is None: Modified: home/phd/SQLObject/paramstyles/sqlobject/converters.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/converters.py 2005-10-18 15:04:45 UTC (rev 1123) +++ home/phd/SQLObject/paramstyles/sqlobject/converters.py 2005-10-18 15:06:59 UTC (rev 1124) @@ -3,15 +3,17 @@ try: import mx.DateTime.ISO origISOStr = mx.DateTime.ISO.strGMT - from mx.DateTime import DateTimeType + from mx.DateTime import DateTimeType, DateTimeDeltaType except ImportError: try: import DateTime.ISO origISOStr = DateTime.ISO.strGMT - from DateTime import DateTimeType + from DateTime import DateTimeType, DateTimeDeltaType except ImportError: origISOStr = None DateTimeType = None + DateTimeDeltaType = None + import time try: import datetime @@ -163,6 +165,11 @@ registerConverter(DateTimeType, DateTimeConverter) + def TimeConverter(value, db): + return "'%s'" % value.strftime("%T") + + registerConverter(DateTimeDeltaType, TimeConverter) + def NoneConverter(value, db): return "NULL" Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_datetime.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/tests/test_datetime.py 2005-10-18 15:04:45 UTC (rev 1123) +++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_datetime.py 2005-10-18 15:06:59 UTC (rev 1124) @@ -1,11 +1,6 @@ from sqlobject import * from sqlobject.tests.dbtest import * from sqlobject import col -if default_datetime_implementation == DATETIME_IMPLEMENTATION: - from datetime import datetime - now = datetime.now -elif default_datetime_implementation == MXDATETIME_IMPLEMENTATION: - from mx.DateTime import now ######################################## ## Date/time columns @@ -13,40 +8,69 @@ if datetime_available: col.default_datetime_implementation = DATETIME_IMPLEMENTATION - from datetime import date, datetime + from datetime import datetime, date, time class DateTime1(SQLObject): - col1 = DateCol() - col2 = DateTimeCol() + col1 = DateTimeCol() + col2 = DateCol() + col3 = TimeCol() def test_dateTime(): setupClass(DateTime1) - _now = now() - dt1 = DateTime1(col1=_now, col2=_now) - assert isinstance(dt1.col1, date) - assert isinstance(dt1.col2, datetime) + _now = datetime.now() + _today = date.today() + dt1 = DateTime1(col1=_now, col2=_today, col3=_now.time()) - today_str = _now.strftime("%Y-%m-%d") - now_str = _now.strftime("%Y-%m-%d %T") - assert str(dt1.col1) == today_str - assert str(dt1.col2) == now_str + assert isinstance(dt1.col1, datetime) + assert dt1.col1.year == _now.year + assert dt1.col1.month == _now.month + assert dt1.col1.day == _now.day + assert dt1.col1.hour == _now.hour + assert dt1.col1.minute == _now.minute + assert dt1.col1.second == int(_now.second) + assert isinstance(dt1.col2, date) + assert dt1.col2.year == _today.year + assert dt1.col2.month == _today.month + assert dt1.col2.day == _today.day + + assert isinstance(dt1.col3, time) + assert dt1.col3.hour == _now.hour + assert dt1.col3.minute == _now.minute + assert dt1.col3.second == int(_now.second) + if mxdatetime_available: col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION + from mx.DateTime import now, Time class DateTime2(SQLObject): - col1 = DateCol() - col2 = DateTimeCol() + col1 = DateTimeCol() + col2 = DateCol(dateFormat="%Y-%m-%d %H:%M:%S") + # mxDateTime does not have a separate date type + col3 = TimeCol() def test_mxDateTime(): setupClass(DateTime2) _now = now() - dt2 = DateTime2(col1=_now, col2=_now) + dt2 = DateTime2(col1=_now, col2=_now, col3=Time(_now.hour, _now.minute, int(_now.second))) + assert isinstance(dt2.col1, col.DateTimeType) + assert dt2.col1.year == _now.year + assert dt2.col1.month == _now.month + assert dt2.col1.day == _now.day + assert dt2.col1.hour == _now.hour + assert dt2.col1.minute == _now.minute + assert dt2.col1.second == int(_now.second) + assert isinstance(dt2.col2, col.DateTimeType) + assert dt2.col2.year == _now.year + assert dt2.col2.month == _now.month + assert dt2.col2.day == _now.day + assert dt2.col1.hour == _now.hour + assert dt2.col1.minute == _now.minute + assert dt2.col1.second == int(_now.second) - today_str = _now.strftime("%Y-%m-%d 00:00:00.00") - now_str = _now.strftime("%Y-%m-%d %T.00") - assert str(dt2.col1) == today_str - assert str(dt2.col2) == now_str - + assert isinstance(dt2.col3, (col.DateTimeType, col.TimeType)) + assert dt2.col3.hour == _now.hour + assert dt2.col3.minute == _now.minute + assert dt2.col3.second == int(_now.second) |
|
From: <sub...@co...> - 2005-10-18 15:04:49
|
Author: phd Date: 2005-10-18 15:04:45 +0000 (Tue, 18 Oct 2005) New Revision: 1123 Modified: SQLObject/trunk/docs/Authors.txt SQLObject/trunk/docs/News.txt SQLObject/trunk/docs/SQLObject.txt Log: Updated docs. Modified: SQLObject/trunk/docs/Authors.txt =================================================================== --- SQLObject/trunk/docs/Authors.txt 2005-10-18 15:03:40 UTC (rev 1122) +++ SQLObject/trunk/docs/Authors.txt 2005-10-18 15:04:45 UTC (rev 1123) @@ -18,4 +18,5 @@ * Yaroslav Samchuk <yarcat at ank-sia.com> * Runar Petursson <grunar at gmail.com> * J Paulo Fernandes Farias <jpaulofarias at gmail.com> +* Shahms King <shahms at shahms.com> * Oleg Broytmann <ph...@ph...> Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2005-10-18 15:03:40 UTC (rev 1122) +++ SQLObject/trunk/docs/News.txt 2005-10-18 15:04:45 UTC (rev 1123) @@ -21,6 +21,8 @@ Constraints (in the DBMSes that support constraints) are added after the tables have been created. +* Added ``TimeCol``. + SQLObject 0.7.0 =============== Modified: SQLObject/trunk/docs/SQLObject.txt =================================================================== --- SQLObject/trunk/docs/SQLObject.txt 2005-10-18 15:03:40 UTC (rev 1122) +++ SQLObject/trunk/docs/SQLObject.txt 2005-10-18 15:04:45 UTC (rev 1123) @@ -1025,11 +1025,14 @@ `CurrencyCol`: Equivalent to ``DecimalCol(size=10, precision=2)``. +`DateTimeCol`: + A date and time (usually returned as an datetime or mxDateTime object). + `DateCol`: A date (usually returned as an datetime or mxDateTime object). -`DateTimeCol`: - A date and time (usually returned as an datetime or mxDateTime object). +`TimeCol`: + A time (usually returned as an datetime or mxDateTime object). `DecimalCol`: Base-10, precise number. Uses the keyword arguments `size` for @@ -1535,6 +1538,8 @@ * `ForeignKey` * `EnumCol` * `DateTimeCol` +* `DateCol` +* `TimeCol` * `DecimalCol` * `CurrencyCol` |
|
From: <sub...@co...> - 2005-10-18 15:03:47
|
Author: phd Date: 2005-10-18 15:03:40 +0000 (Tue, 18 Oct 2005) New Revision: 1122 Modified: SQLObject/branches/0.7-bugfix/docs/Authors.txt SQLObject/branches/0.7-bugfix/docs/News.txt SQLObject/branches/0.7-bugfix/docs/SQLObject.txt Log: Updated docs. Modified: SQLObject/branches/0.7-bugfix/docs/Authors.txt =================================================================== --- SQLObject/branches/0.7-bugfix/docs/Authors.txt 2005-10-18 14:53:04 UTC (rev 1121) +++ SQLObject/branches/0.7-bugfix/docs/Authors.txt 2005-10-18 15:03:40 UTC (rev 1122) @@ -16,4 +16,5 @@ * Daniel Savard, Xsoli Inc <sqlobject at xsoli.com> * alexander smishlajev <alex at ank-sia.com> * Yaroslav Samchuk <yarcat at ank-sia.com> +* Shahms King <shahms at shahms.com> * Oleg Broytmann <phd at phd.pp.ru> Modified: SQLObject/branches/0.7-bugfix/docs/News.txt =================================================================== --- SQLObject/branches/0.7-bugfix/docs/News.txt 2005-10-18 14:53:04 UTC (rev 1121) +++ SQLObject/branches/0.7-bugfix/docs/News.txt 2005-10-18 15:03:40 UTC (rev 1122) @@ -7,6 +7,11 @@ .. _start: +SQLObject 0.7.1 +=============== + +* Added ``TimeCol``. + SQLObject 0.7.0 =============== Modified: SQLObject/branches/0.7-bugfix/docs/SQLObject.txt =================================================================== --- SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2005-10-18 14:53:04 UTC (rev 1121) +++ SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2005-10-18 15:03:40 UTC (rev 1122) @@ -1020,11 +1020,14 @@ `CurrencyCol`: Equivalent to ``DecimalCol(size=10, precision=2)``. +`DateTimeCol`: + A date and time (usually returned as an datetime or mxDateTime object). + `DateCol`: A date (usually returned as an datetime or mxDateTime object). -`DateTimeCol`: - A date and time (usually returned as an datetime or mxDateTime object). +`TimeCol`: + A date (usually returned as an datetime or mxDateTime object). `DecimalCol`: Base-10, precise number. Uses the keyword arguments `size` for @@ -1513,6 +1516,8 @@ * `ForeignKey` * `EnumCol` * `DateTimeCol` +* `DateCol` +* `TimeCol` * `DecimalCol` * `CurrencyCol` |
|
From: <sub...@co...> - 2005-10-18 14:53:11
|
Author: phd
Date: 2005-10-18 14:53:04 +0000 (Tue, 18 Oct 2005)
New Revision: 1121
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/col.py
SQLObject/branches/0.7-bugfix/sqlobject/converters.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py
Log:
Merged a patch from the revision 1120 from the trunk: added TimeCol and tests; a number of enhancements in date/time validators.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/col.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/col.py 2005-10-18 14:52:21 UTC (rev 1120)
+++ SQLObject/branches/0.7-bugfix/sqlobject/col.py 2005-10-18 14:53:04 UTC (rev 1121)
@@ -60,6 +60,7 @@
if mxdatetime_available:
DateTimeType = type(DateTime.now())
+ TimeType = type(DateTime.Time())
if datetime_available:
default_datetime_implementation = DATETIME_IMPLEMENTATION
@@ -829,27 +830,33 @@
def to_python(self, value, state):
if value is None:
return None
- if isinstance(value, (datetime.date, datetime.datetime, sqlbuilder.SQLExpression)):
+ if isinstance(value, (datetime.datetime, datetime.date, datetime.time, sqlbuilder.SQLExpression)):
return value
- if mxdatetime_available and isinstance(value, DateTimeType):
- # convert mxDateTime instance to datetime
- if (self.format.find("%H") >= 0) or (self.format.find("%T")) >= 0:
- return datetime.datetime(value.year, value.month, value.day,
- value.hour, value.minute, int(value.second))
- else:
- return datetime.date(value.year, value.month, value.day)
+ if mxdatetime_available:
+ if isinstance(value, DateTimeType):
+ # convert mxDateTime instance to datetime
+ if (self.format.find("%H") >= 0) or (self.format.find("%T")) >= 0:
+ return datetime.datetime(value.year, value.month, value.day,
+ value.hour, value.minute, int(value.second))
+ else:
+ return datetime.date(value.year, value.month, value.day)
+ elif isinstance(value, TimeType):
+ # convert mxTime instance to time
+ if self.format.find("%d") >= 0:
+ return datetime.timedelta(seconds=value.seconds)
+ else:
+ return datetime.time(value.hour, value.minute, int(value.second))
try:
stime = time.strptime(value, self.format)
except:
raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
(self.format, self.name, type(value), value), value, state)
- secs = time.mktime(stime)
- return datetime.datetime.fromtimestamp(secs)
+ return datetime.datetime(*stime[:7])
def from_python(self, value, state):
if value is None:
return None
- if isinstance(value, (datetime.date, datetime.datetime, sqlbuilder.SQLExpression)):
+ if isinstance(value, (datetime.datetime, datetime.date, datetime.time, sqlbuilder.SQLExpression)):
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
@@ -861,7 +868,7 @@
def to_python(self, value, state):
if value is None:
return None
- if isinstance(value, (DateTimeType, sqlbuilder.SQLExpression)):
+ if isinstance(value, (DateTimeType, TimeType, sqlbuilder.SQLExpression)):
return value
if datetime_available: # convert datetime instance to mxDateTime
if isinstance(value, datetime.datetime):
@@ -869,6 +876,8 @@
value.hour, value.minute, value.second)
elif isinstance(value, datetime.date):
return DateTime.Date(value.year, value.month, value.day)
+ elif isinstance(value, datetime.time):
+ return DateTime.Time(value.hour, value.minute, value.second)
try:
stime = time.strptime(value, self.format)
except:
@@ -879,7 +888,7 @@
def from_python(self, value, state):
if value is None:
return None
- if isinstance(value, (DateTimeType, sqlbuilder.SQLExpression)):
+ if isinstance(value, (DateTimeType, TimeType, sqlbuilder.SQLExpression)):
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
@@ -940,9 +949,11 @@
if datetime_available:
class DateValidator(DateTimeValidator):
def to_python(self, value, state):
+ if isinstance(value, datetime.date):
+ return value
value = super(DateValidator, self).to_python(value, state)
if isinstance(value, datetime.datetime):
- value = datetime.date(value.year, value.month, value.day)
+ value = value.date()
return value
from_python = to_python
@@ -988,6 +999,57 @@
baseClass = SODateCol
+if datetime_available:
+ class TimeValidator(DateTimeValidator):
+ def to_python(self, value, state):
+ if isinstance(value, datetime.time):
+ return value
+ value = super(TimeValidator, self).to_python(value, state)
+ if isinstance(value, datetime.datetime):
+ value = value.time()
+ return value
+
+class SOTimeCol(SOCol):
+ timeFormat = '%H:%M:%S'
+
+ def __init__(self, **kw):
+ timeFormat = popKey(kw, 'timeFormat')
+ if timeFormat:
+ self.timeFormat = timeFormat
+ SOCol.__init__(self, **kw)
+
+ def createValidators(self):
+ _validators = super(SOTimeCol, self).createValidators()
+ if default_datetime_implementation == DATETIME_IMPLEMENTATION:
+ validatorClass = TimeValidator
+ elif default_datetime_implementation == MXDATETIME_IMPLEMENTATION:
+ validatorClass = MXDateTimeValidator
+ if default_datetime_implementation:
+ _validators.insert(0, validatorClass(name=self.name, format=self.timeFormat))
+ return _validators
+
+ def _mysqlType(self):
+ return 'TIME'
+
+ def _postgresType(self):
+ return 'TIME'
+
+ def _sybaseType(self):
+ return 'TIME'
+
+ def _sqliteType(self):
+ return 'TIME'
+
+ def _firebirdType(self):
+ return 'TIME'
+
+ def _maxdbType(self):
+ return 'TIME'
+
+class TimeCol(Col):
+ baseClass = SOTimeCol
+
+
class SODecimalCol(SOCol):
def __init__(self, **kw):
Modified: SQLObject/branches/0.7-bugfix/sqlobject/converters.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/converters.py 2005-10-18 14:52:21 UTC (rev 1120)
+++ SQLObject/branches/0.7-bugfix/sqlobject/converters.py 2005-10-18 14:53:04 UTC (rev 1121)
@@ -3,15 +3,17 @@
try:
import mx.DateTime.ISO
origISOStr = mx.DateTime.ISO.strGMT
- from mx.DateTime import DateTimeType
+ from mx.DateTime import DateTimeType, DateTimeDeltaType
except ImportError:
try:
import DateTime.ISO
origISOStr = DateTime.ISO.strGMT
- from DateTime import DateTimeType
+ from DateTime import DateTimeType, DateTimeDeltaType
except ImportError:
origISOStr = None
DateTimeType = None
+ DateTimeDeltaType = None
+
import time
try:
import datetime
@@ -163,6 +165,11 @@
registerConverter(DateTimeType, DateTimeConverter)
+ def TimeConverter(value, db):
+ return "'%s'" % value.strftime("%T")
+
+ registerConverter(DateTimeDeltaType, TimeConverter)
+
def NoneConverter(value, db):
return "NULL"
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py 2005-10-18 14:52:21 UTC (rev 1120)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py 2005-10-18 14:53:04 UTC (rev 1121)
@@ -8,18 +8,18 @@
if datetime_available:
col.default_datetime_implementation = DATETIME_IMPLEMENTATION
- from datetime import date, datetime
- now = datetime.now
+ from datetime import datetime, date, time
class DateTime1(SQLObject):
col1 = DateTimeCol()
col2 = DateCol()
+ col3 = TimeCol()
def test_dateTime():
setupClass(DateTime1)
- _now = now()
+ _now = datetime.now()
_today = date.today()
- dt1 = DateTime1(col1=_now, col2=_today)
+ dt1 = DateTime1(col1=_now, col2=_today, col3=_now.time())
assert isinstance(dt1.col1, datetime)
assert dt1.col1.year == _now.year
@@ -34,19 +34,25 @@
assert dt1.col2.month == _today.month
assert dt1.col2.day == _today.day
+ assert isinstance(dt1.col3, time)
+ assert dt1.col3.hour == _now.hour
+ assert dt1.col3.minute == _now.minute
+ assert dt1.col3.second == int(_now.second)
+
if mxdatetime_available:
col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION
- from mx.DateTime import now
+ from mx.DateTime import now, Time
class DateTime2(SQLObject):
col1 = DateTimeCol()
col2 = DateCol(dateFormat="%Y-%m-%d %H:%M:%S")
# mxDateTime does not have a separate date type
+ col3 = TimeCol()
def test_mxDateTime():
setupClass(DateTime2)
_now = now()
- dt2 = DateTime2(col1=_now, col2=_now)
+ dt2 = DateTime2(col1=_now, col2=_now, col3=Time(_now.hour, _now.minute, int(_now.second)))
assert isinstance(dt2.col1, col.DateTimeType)
assert dt2.col1.year == _now.year
@@ -63,3 +69,8 @@
assert dt2.col1.hour == _now.hour
assert dt2.col1.minute == _now.minute
assert dt2.col1.second == int(_now.second)
+
+ assert isinstance(dt2.col3, (col.DateTimeType, col.TimeType))
+ assert dt2.col3.hour == _now.hour
+ assert dt2.col3.minute == _now.minute
+ assert dt2.col3.second == int(_now.second)
|
|
From: <sub...@co...> - 2005-10-18 14:52:47
|
Author: phd
Date: 2005-10-18 14:52:21 +0000 (Tue, 18 Oct 2005)
New Revision: 1120
Modified:
SQLObject/trunk/sqlobject/col.py
SQLObject/trunk/sqlobject/converters.py
SQLObject/trunk/sqlobject/tests/test_datetime.py
Log:
Added TimeCol and tests. A number of enhancements in date/time validators.
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2005-10-18 13:52:49 UTC (rev 1119)
+++ SQLObject/trunk/sqlobject/col.py 2005-10-18 14:52:21 UTC (rev 1120)
@@ -60,6 +60,7 @@
if mxdatetime_available:
DateTimeType = type(DateTime.now())
+ TimeType = type(DateTime.Time())
if datetime_available:
default_datetime_implementation = DATETIME_IMPLEMENTATION
@@ -333,7 +334,7 @@
def mssqlCreateSQL(self):
return ' '.join([self.dbName, self._mssqlType()] + self._extraSQL())
-
+
def firebirdCreateSQL(self):
# Ian Sparks pointed out that fb is picky about the order
# of the NOT NULL clause in a create statement. So, we handle
@@ -701,7 +702,7 @@
def _sybaseType(self):
return 'NUMERIC(18,0) NULL'
-
+
def _mssqlType(self):
return 'INT NULL'
@@ -870,27 +871,33 @@
def to_python(self, value, state):
if value is None:
return None
- if isinstance(value, (datetime.date, datetime.datetime, sqlbuilder.SQLExpression)):
+ if isinstance(value, (datetime.datetime, datetime.date, datetime.time, sqlbuilder.SQLExpression)):
return value
- if mxdatetime_available and isinstance(value, DateTimeType):
- # convert mxDateTime instance to datetime
- if (self.format.find("%H") >= 0) or (self.format.find("%T")) >= 0:
- return datetime.datetime(value.year, value.month, value.day,
- value.hour, value.minute, int(value.second))
- else:
- return datetime.date(value.year, value.month, value.day)
+ if mxdatetime_available:
+ if isinstance(value, DateTimeType):
+ # convert mxDateTime instance to datetime
+ if (self.format.find("%H") >= 0) or (self.format.find("%T")) >= 0:
+ return datetime.datetime(value.year, value.month, value.day,
+ value.hour, value.minute, int(value.second))
+ else:
+ return datetime.date(value.year, value.month, value.day)
+ elif isinstance(value, TimeType):
+ # convert mxTime instance to time
+ if self.format.find("%d") >= 0:
+ return datetime.timedelta(seconds=value.seconds)
+ else:
+ return datetime.time(value.hour, value.minute, int(value.second))
try:
stime = time.strptime(value, self.format)
except:
raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
(self.format, self.name, type(value), value), value, state)
- secs = time.mktime(stime)
- return datetime.datetime.fromtimestamp(secs)
+ return datetime.datetime(*stime[:7])
def from_python(self, value, state):
if value is None:
return None
- if isinstance(value, (datetime.date, datetime.datetime, sqlbuilder.SQLExpression)):
+ if isinstance(value, (datetime.datetime, datetime.date, datetime.time, sqlbuilder.SQLExpression)):
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
@@ -902,7 +909,7 @@
def to_python(self, value, state):
if value is None:
return None
- if isinstance(value, (DateTimeType, sqlbuilder.SQLExpression)):
+ if isinstance(value, (DateTimeType, TimeType, sqlbuilder.SQLExpression)):
return value
if datetime_available: # convert datetime instance to mxDateTime
if isinstance(value, datetime.datetime):
@@ -910,6 +917,8 @@
value.hour, value.minute, value.second)
elif isinstance(value, datetime.date):
return DateTime.Date(value.year, value.month, value.day)
+ elif isinstance(value, datetime.time):
+ return DateTime.Time(value.hour, value.minute, value.second)
try:
stime = time.strptime(value, self.format)
except:
@@ -920,7 +929,7 @@
def from_python(self, value, state):
if value is None:
return None
- if isinstance(value, (DateTimeType, sqlbuilder.SQLExpression)):
+ if isinstance(value, (DateTimeType, TimeType, sqlbuilder.SQLExpression)):
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
@@ -984,9 +993,11 @@
if datetime_available:
class DateValidator(DateTimeValidator):
def to_python(self, value, state):
+ if isinstance(value, datetime.date):
+ return value
value = super(DateValidator, self).to_python(value, state)
if isinstance(value, datetime.datetime):
- value = datetime.date(value.year, value.month, value.day)
+ value = value.date()
return value
from_python = to_python
@@ -1018,7 +1029,7 @@
def _sybaseType(self):
return self._postgresType()
-
+
def _mssqlType(self):
"""
SQL Server doesn't have a DATE data type, to emulate we use a vc(10)
@@ -1038,6 +1049,57 @@
baseClass = SODateCol
+if datetime_available:
+ class TimeValidator(DateTimeValidator):
+ def to_python(self, value, state):
+ if isinstance(value, datetime.time):
+ return value
+ value = super(TimeValidator, self).to_python(value, state)
+ if isinstance(value, datetime.datetime):
+ value = value.time()
+ return value
+
+class SOTimeCol(SOCol):
+ timeFormat = '%H:%M:%S'
+
+ def __init__(self, **kw):
+ timeFormat = popKey(kw, 'timeFormat')
+ if timeFormat:
+ self.timeFormat = timeFormat
+ SOCol.__init__(self, **kw)
+
+ def createValidators(self):
+ _validators = super(SOTimeCol, self).createValidators()
+ if default_datetime_implementation == DATETIME_IMPLEMENTATION:
+ validatorClass = TimeValidator
+ elif default_datetime_implementation == MXDATETIME_IMPLEMENTATION:
+ validatorClass = MXDateTimeValidator
+ if default_datetime_implementation:
+ _validators.insert(0, validatorClass(name=self.name, format=self.timeFormat))
+ return _validators
+
+ def _mysqlType(self):
+ return 'TIME'
+
+ def _postgresType(self):
+ return 'TIME'
+
+ def _sybaseType(self):
+ return 'TIME'
+
+ def _sqliteType(self):
+ return 'TIME'
+
+ def _firebirdType(self):
+ return 'TIME'
+
+ def _maxdbType(self):
+ return 'TIME'
+
+class TimeCol(Col):
+ baseClass = SOTimeCol
+
+
class SODecimalCol(SOCol):
def __init__(self, **kw):
Modified: SQLObject/trunk/sqlobject/converters.py
===================================================================
--- SQLObject/trunk/sqlobject/converters.py 2005-10-18 13:52:49 UTC (rev 1119)
+++ SQLObject/trunk/sqlobject/converters.py 2005-10-18 14:52:21 UTC (rev 1120)
@@ -3,15 +3,17 @@
try:
import mx.DateTime.ISO
origISOStr = mx.DateTime.ISO.strGMT
- from mx.DateTime import DateTimeType
+ from mx.DateTime import DateTimeType, DateTimeDeltaType
except ImportError:
try:
import DateTime.ISO
origISOStr = DateTime.ISO.strGMT
- from DateTime import DateTimeType
+ from DateTime import DateTimeType, DateTimeDeltaType
except ImportError:
origISOStr = None
DateTimeType = None
+ DateTimeDeltaType = None
+
import time
try:
import datetime
@@ -163,6 +165,11 @@
registerConverter(DateTimeType, DateTimeConverter)
+ def TimeConverter(value, db):
+ return "'%s'" % value.strftime("%T")
+
+ registerConverter(DateTimeDeltaType, TimeConverter)
+
def NoneConverter(value, db):
return "NULL"
Modified: SQLObject/trunk/sqlobject/tests/test_datetime.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_datetime.py 2005-10-18 13:52:49 UTC (rev 1119)
+++ SQLObject/trunk/sqlobject/tests/test_datetime.py 2005-10-18 14:52:21 UTC (rev 1120)
@@ -8,18 +8,18 @@
if datetime_available:
col.default_datetime_implementation = DATETIME_IMPLEMENTATION
- from datetime import date, datetime
- now = datetime.now
+ from datetime import datetime, date, time
class DateTime1(SQLObject):
col1 = DateTimeCol()
col2 = DateCol()
+ col3 = TimeCol()
def test_dateTime():
setupClass(DateTime1)
- _now = now()
+ _now = datetime.now()
_today = date.today()
- dt1 = DateTime1(col1=_now, col2=_today)
+ dt1 = DateTime1(col1=_now, col2=_today, col3=_now.time())
assert isinstance(dt1.col1, datetime)
assert dt1.col1.year == _now.year
@@ -34,19 +34,25 @@
assert dt1.col2.month == _today.month
assert dt1.col2.day == _today.day
+ assert isinstance(dt1.col3, time)
+ assert dt1.col3.hour == _now.hour
+ assert dt1.col3.minute == _now.minute
+ assert dt1.col3.second == int(_now.second)
+
if mxdatetime_available:
col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION
- from mx.DateTime import now
+ from mx.DateTime import now, Time
class DateTime2(SQLObject):
col1 = DateTimeCol()
col2 = DateCol(dateFormat="%Y-%m-%d %H:%M:%S")
# mxDateTime does not have a separate date type
+ col3 = TimeCol()
def test_mxDateTime():
setupClass(DateTime2)
_now = now()
- dt2 = DateTime2(col1=_now, col2=_now)
+ dt2 = DateTime2(col1=_now, col2=_now, col3=Time(_now.hour, _now.minute, int(_now.second)))
assert isinstance(dt2.col1, col.DateTimeType)
assert dt2.col1.year == _now.year
@@ -63,3 +69,8 @@
assert dt2.col1.hour == _now.hour
assert dt2.col1.minute == _now.minute
assert dt2.col1.second == int(_now.second)
+
+ assert isinstance(dt2.col3, (col.DateTimeType, col.TimeType))
+ assert dt2.col3.hour == _now.hour
+ assert dt2.col3.minute == _now.minute
+ assert dt2.col3.second == int(_now.second)
|
|
From: <sub...@co...> - 2005-10-18 13:52:55
|
Author: phd
Date: 2005-10-18 13:52:49 +0000 (Tue, 18 Oct 2005)
New Revision: 1119
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py
Log:
Merged a patch from the revision 1118 from the trunk - a number of minor enhancements and fixes.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py 2005-10-18 13:52:14 UTC (rev 1118)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_datetime.py 2005-10-18 13:52:49 UTC (rev 1119)
@@ -1,11 +1,6 @@
from sqlobject import *
from sqlobject.tests.dbtest import *
from sqlobject import col
-if default_datetime_implementation == DATETIME_IMPLEMENTATION:
- from datetime import datetime
- now = datetime.now
-elif default_datetime_implementation == MXDATETIME_IMPLEMENTATION:
- from mx.DateTime import now
########################################
## Date/time columns
@@ -14,39 +9,57 @@
if datetime_available:
col.default_datetime_implementation = DATETIME_IMPLEMENTATION
from datetime import date, datetime
+ now = datetime.now
class DateTime1(SQLObject):
- col1 = DateCol()
- col2 = DateTimeCol()
+ col1 = DateTimeCol()
+ col2 = DateCol()
def test_dateTime():
setupClass(DateTime1)
_now = now()
- dt1 = DateTime1(col1=_now, col2=_now)
- assert isinstance(dt1.col1, date)
- assert isinstance(dt1.col2, datetime)
+ _today = date.today()
+ dt1 = DateTime1(col1=_now, col2=_today)
- today_str = _now.strftime("%Y-%m-%d")
- now_str = _now.strftime("%Y-%m-%d %T")
- assert str(dt1.col1) == today_str
- assert str(dt1.col2) == now_str
+ assert isinstance(dt1.col1, datetime)
+ assert dt1.col1.year == _now.year
+ assert dt1.col1.month == _now.month
+ assert dt1.col1.day == _now.day
+ assert dt1.col1.hour == _now.hour
+ assert dt1.col1.minute == _now.minute
+ assert dt1.col1.second == int(_now.second)
+ assert isinstance(dt1.col2, date)
+ assert dt1.col2.year == _today.year
+ assert dt1.col2.month == _today.month
+ assert dt1.col2.day == _today.day
+
if mxdatetime_available:
col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION
+ from mx.DateTime import now
class DateTime2(SQLObject):
- col1 = DateCol()
- col2 = DateTimeCol()
+ col1 = DateTimeCol()
+ col2 = DateCol(dateFormat="%Y-%m-%d %H:%M:%S")
+ # mxDateTime does not have a separate date type
def test_mxDateTime():
setupClass(DateTime2)
_now = now()
dt2 = DateTime2(col1=_now, col2=_now)
+
assert isinstance(dt2.col1, col.DateTimeType)
+ assert dt2.col1.year == _now.year
+ assert dt2.col1.month == _now.month
+ assert dt2.col1.day == _now.day
+ assert dt2.col1.hour == _now.hour
+ assert dt2.col1.minute == _now.minute
+ assert dt2.col1.second == int(_now.second)
+
assert isinstance(dt2.col2, col.DateTimeType)
-
- today_str = _now.strftime("%Y-%m-%d 00:00:00.00")
- now_str = _now.strftime("%Y-%m-%d %T.00")
- assert str(dt2.col1) == today_str
- assert str(dt2.col2) == now_str
-
+ assert dt2.col2.year == _now.year
+ assert dt2.col2.month == _now.month
+ assert dt2.col2.day == _now.day
+ assert dt2.col1.hour == _now.hour
+ assert dt2.col1.minute == _now.minute
+ assert dt2.col1.second == int(_now.second)
|
|
From: <sub...@co...> - 2005-10-18 13:52:35
|
Author: phd
Date: 2005-10-18 13:52:14 +0000 (Tue, 18 Oct 2005)
New Revision: 1118
Modified:
SQLObject/trunk/sqlobject/tests/test_datetime.py
Log:
A number of minor enhancements and fixes.
Modified: SQLObject/trunk/sqlobject/tests/test_datetime.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_datetime.py 2005-10-18 13:28:02 UTC (rev 1117)
+++ SQLObject/trunk/sqlobject/tests/test_datetime.py 2005-10-18 13:52:14 UTC (rev 1118)
@@ -1,11 +1,6 @@
from sqlobject import *
from sqlobject.tests.dbtest import *
from sqlobject import col
-if default_datetime_implementation == DATETIME_IMPLEMENTATION:
- from datetime import datetime
- now = datetime.now
-elif default_datetime_implementation == MXDATETIME_IMPLEMENTATION:
- from mx.DateTime import now
########################################
## Date/time columns
@@ -14,39 +9,57 @@
if datetime_available:
col.default_datetime_implementation = DATETIME_IMPLEMENTATION
from datetime import date, datetime
+ now = datetime.now
class DateTime1(SQLObject):
- col1 = DateCol()
- col2 = DateTimeCol()
+ col1 = DateTimeCol()
+ col2 = DateCol()
def test_dateTime():
setupClass(DateTime1)
_now = now()
- dt1 = DateTime1(col1=_now, col2=_now)
- assert isinstance(dt1.col1, date)
- assert isinstance(dt1.col2, datetime)
+ _today = date.today()
+ dt1 = DateTime1(col1=_now, col2=_today)
- today_str = _now.strftime("%Y-%m-%d")
- now_str = _now.strftime("%Y-%m-%d %T")
- assert str(dt1.col1) == today_str
- assert str(dt1.col2) == now_str
+ assert isinstance(dt1.col1, datetime)
+ assert dt1.col1.year == _now.year
+ assert dt1.col1.month == _now.month
+ assert dt1.col1.day == _now.day
+ assert dt1.col1.hour == _now.hour
+ assert dt1.col1.minute == _now.minute
+ assert dt1.col1.second == int(_now.second)
+ assert isinstance(dt1.col2, date)
+ assert dt1.col2.year == _today.year
+ assert dt1.col2.month == _today.month
+ assert dt1.col2.day == _today.day
+
if mxdatetime_available:
col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION
+ from mx.DateTime import now
class DateTime2(SQLObject):
- col1 = DateCol()
- col2 = DateTimeCol()
+ col1 = DateTimeCol()
+ col2 = DateCol(dateFormat="%Y-%m-%d %H:%M:%S")
+ # mxDateTime does not have a separate date type
def test_mxDateTime():
setupClass(DateTime2)
_now = now()
dt2 = DateTime2(col1=_now, col2=_now)
+
assert isinstance(dt2.col1, col.DateTimeType)
+ assert dt2.col1.year == _now.year
+ assert dt2.col1.month == _now.month
+ assert dt2.col1.day == _now.day
+ assert dt2.col1.hour == _now.hour
+ assert dt2.col1.minute == _now.minute
+ assert dt2.col1.second == int(_now.second)
+
assert isinstance(dt2.col2, col.DateTimeType)
-
- today_str = _now.strftime("%Y-%m-%d 00:00:00.00")
- now_str = _now.strftime("%Y-%m-%d %T.00")
- assert str(dt2.col1) == today_str
- assert str(dt2.col2) == now_str
-
+ assert dt2.col2.year == _now.year
+ assert dt2.col2.month == _now.month
+ assert dt2.col2.day == _now.day
+ assert dt2.col1.hour == _now.hour
+ assert dt2.col1.minute == _now.minute
+ assert dt2.col1.second == int(_now.second)
|
|
From: <sub...@co...> - 2005-10-18 13:28:15
|
Author: phd
Date: 2005-10-18 13:28:02 +0000 (Tue, 18 Oct 2005)
New Revision: 1117
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/col.py
Log:
Merged patch from revision 1116 from the trunk - report the repr(value) along with its type.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/col.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/col.py 2005-10-18 13:26:55 UTC (rev 1116)
+++ SQLObject/branches/0.7-bugfix/sqlobject/col.py 2005-10-18 13:28:02 UTC (rev 1117)
@@ -549,15 +549,15 @@
except OverflowError: # for Python 2.2
return long(value)
except:
- raise validators.Invalid("expected an int in the IntCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected an int in the IntCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
return None
if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
- raise validators.Invalid("expected an int in the IntCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected an int in the IntCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
return value
class SOIntCol(SOCol):
@@ -634,15 +634,15 @@
try:
return float(value)
except:
- raise validators.Invalid("expected a float in the FloatCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a float in the FloatCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
return None
if not isinstance(value, (int, long, float, sqlbuilder.SQLExpression)):
- raise validators.Invalid("expected a float in the FloatCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a float in the FloatCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
return value
class SOFloatCol(SOCol):
@@ -841,8 +841,8 @@
try:
stime = time.strptime(value, self.format)
except:
- raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \
- (self.format, self.name, type(value)), value, state)
+ raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
+ (self.format, self.name, type(value), value), value, state)
secs = time.mktime(stime)
return datetime.datetime.fromtimestamp(secs)
@@ -853,8 +853,8 @@
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
- raise validators.Invalid("expected a datetime in the DateTimeCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a datetime in the DateTimeCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
if mxdatetime_available:
class MXDateTimeValidator(validators.DateValidator):
@@ -872,8 +872,8 @@
try:
stime = time.strptime(value, self.format)
except:
- raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \
- (self.format, self.name, type(value)), value, state)
+ raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
+ (self.format, self.name, type(value), value), value, state)
return DateTime.mktime(stime)
def from_python(self, value, state):
@@ -883,8 +883,8 @@
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
- raise validators.Invalid("expected a mxDateTime in the DateTimeCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a mxDateTime in the DateTimeCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
class SODateTimeCol(SOCol):
datetimeFormat = '%Y-%m-%d %H:%M:%S'
@@ -1041,8 +1041,8 @@
if isinstance(value, array_type): # MySQL
return value.tostring()
return str(value) # buffer => string
- raise validators.Invalid("expected a string in the BLOBCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a string in the BLOBCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
@@ -1091,8 +1091,8 @@
value = value.encode("ascii")
if isinstance(value, str):
return pickle.loads(value)
- raise validators.Invalid("expected a pickle string in the PickleCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a pickle string in the PickleCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
|
|
From: <sub...@co...> - 2005-10-18 13:27:08
|
Author: phd
Date: 2005-10-18 13:26:55 +0000 (Tue, 18 Oct 2005)
New Revision: 1116
Modified:
SQLObject/trunk/sqlobject/col.py
Log:
Report the repr(value) along with its type.
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2005-10-12 23:15:51 UTC (rev 1115)
+++ SQLObject/trunk/sqlobject/col.py 2005-10-18 13:26:55 UTC (rev 1116)
@@ -566,15 +566,15 @@
except OverflowError: # for Python 2.2
return long(value)
except:
- raise validators.Invalid("expected an int in the IntCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected an int in the IntCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
return None
if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
- raise validators.Invalid("expected an int in the IntCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected an int in the IntCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
return value
class SOIntCol(SOCol):
@@ -654,15 +654,15 @@
try:
return float(value)
except:
- raise validators.Invalid("expected a float in the FloatCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a float in the FloatCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
return None
if not isinstance(value, (int, long, float, sqlbuilder.SQLExpression)):
- raise validators.Invalid("expected a float in the FloatCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a float in the FloatCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
return value
class SOFloatCol(SOCol):
@@ -882,8 +882,8 @@
try:
stime = time.strptime(value, self.format)
except:
- raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \
- (self.format, self.name, type(value)), value, state)
+ raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
+ (self.format, self.name, type(value), value), value, state)
secs = time.mktime(stime)
return datetime.datetime.fromtimestamp(secs)
@@ -894,8 +894,8 @@
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
- raise validators.Invalid("expected a datetime in the DateTimeCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a datetime in the DateTimeCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
if mxdatetime_available:
class MXDateTimeValidator(validators.DateValidator):
@@ -913,8 +913,8 @@
try:
stime = time.strptime(value, self.format)
except:
- raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \
- (self.format, self.name, type(value)), value, state)
+ raise validators.Invalid("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
+ (self.format, self.name, type(value), value), value, state)
return DateTime.mktime(stime)
def from_python(self, value, state):
@@ -924,8 +924,8 @@
return value
if hasattr(value, "strftime"):
return value.strftime(self.format)
- raise validators.Invalid("expected a mxDateTime in the DateTimeCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a mxDateTime in the DateTimeCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
class SODateTimeCol(SOCol):
datetimeFormat = '%Y-%m-%d %H:%M:%S'
@@ -1091,8 +1091,8 @@
if isinstance(value, array_type): # MySQL
return value.tostring()
return str(value) # buffer => string
- raise validators.Invalid("expected a string in the BLOBCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a string in the BLOBCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
@@ -1144,8 +1144,8 @@
value = value.encode("ascii")
if isinstance(value, str):
return pickle.loads(value)
- raise validators.Invalid("expected a pickle string in the PickleCol '%s', got %s instead" % \
- (self.name, type(value)), value, state)
+ raise validators.Invalid("expected a pickle string in the PickleCol '%s', got %s %r instead" % \
+ (self.name, type(value), value), value, state)
def from_python(self, value, state):
if value is None:
|
|
From: <sub...@co...> - 2005-10-12 22:53:48
|
Author: test Date: 2005-10-12 22:53:42 +0000 (Wed, 12 Oct 2005) New Revision: 1113 Modified: SQLObject/trunk/docs/DeveloperGuide.txt Log: Typo noted by Jeff Bauer Modified: SQLObject/trunk/docs/DeveloperGuide.txt =================================================================== --- SQLObject/trunk/docs/DeveloperGuide.txt 2005-10-12 17:48:44 UTC (rev 1112) +++ SQLObject/trunk/docs/DeveloperGuide.txt 2005-10-12 22:53:42 UTC (rev 1113) @@ -149,7 +149,7 @@ its `getting started`_ document for more. .. __: http://codespeak.net/py/current/doc/test.html -.. _getting started: http://codespeak.net/py/current/doc/getting_started.html +.. _getting started: http://codespeak.net/py/current/doc/getting-started.html To actually run the test, you have to give it a database to connect to. You do this with the ``TESTDB`` environmental variable (right now |
|
From: <sub...@co...> - 2005-10-12 16:21:15
|
Author: ianb
Date: 2005-10-12 16:20:59 +0000 (Wed, 12 Oct 2005)
New Revision: 1109
Modified:
SQLObject/trunk/sqlobject/sresults.py
Log:
Filter should respect queries written as strings (which RelatedJoin also happens to use, and is necessary when using SQLRelatedJoin with .filter()). Also, ignore arguments of None, as this represents an empty query that should match anything (using the same semantics as .select())
Modified: SQLObject/trunk/sqlobject/sresults.py
===================================================================
--- SQLObject/trunk/sqlobject/sresults.py 2005-10-12 14:46:53 UTC (rev 1108)
+++ SQLObject/trunk/sqlobject/sresults.py 2005-10-12 16:20:59 UTC (rev 1109)
@@ -91,7 +91,13 @@
self.clauseTables, **self.ops)
def filter(self, filter_clause):
- return self.newClause(sqlbuilder.AND(self.clause, filter_clause))
+ if filter_clause is None:
+ # None doesn't filter anything, it's just a no-op:
+ return self
+ clause = self.clause
+ if isinstance(clause, (str, unicode)):
+ clause = sqlbuilder.SQLConstant('(%s)' % self.clause)
+ return self.newClause(sqlbuilder.AND(clause, filter_clause))
def __getitem__(self, value):
if type(value) is type(slice(1)):
|
|
From: <sub...@co...> - 2005-10-12 14:47:06
|
Author: phd
Date: 2005-10-12 14:46:53 +0000 (Wed, 12 Oct 2005)
New Revision: 1108
Modified:
home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
Log:
Fixed a numnber of bugs in _convertQuery() and _executeRetry().
Converted _insertSQL() to use SQLQuery and Param (actually, insert()).
Modified: home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2005-10-12 12:58:57 UTC (rev 1107)
+++ home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2005-10-12 14:46:53 UTC (rev 1108)
@@ -292,23 +292,20 @@
def _convertQuery(self, query):
paramstyle = self.module.paramstyle
- converter = getattr(DBSingleStyle, "to_" % paramstyle)
- query_string, params = converter(query.query_list)
- if paramstyle in ("named", "pyformat"):
- keywords = params
- params = []
- else:
- keywords = {}
- return query_string, params, keywords
+ converter = getattr(DBSingleStyle, "to_" + paramstyle)
+ return converter(query.query_list)
def _executeRetry(self, conn, cursor, query):
- if self.debug:
- self.printDebug(conn, query, 'QueryR')
if isinstance(query, str):
+ if self.debug:
+ self.printDebug(conn, query, 'QueryR')
return cursor.execute(query)
elif isinstance(query, sqlbuilder.SQLQuery):
- query_string, params, keywords = self._convertQuery(query)
- return cursor.execute(query_string, *params, **keywords)
+ query_string, params = self._convertQuery(query)
+ if self.debug:
+ self.printDebug(conn, query_string, 'QueryString')
+ self.printDebug(conn, params, 'QueryParams')
+ return cursor.execute(query_string, params)
else:
raise TypeError, "_executeRetry expects query string, not %s" % type(query)
@@ -364,9 +361,8 @@
return self._runWithConnection(self._queryOne, s)
def _insertSQL(self, table, names, values):
- return ("INSERT INTO %s (%s) VALUES (%s)" %
- (table, ', '.join(names),
- ', '.join([self.sqlrepr(v) for v in values])))
+ name_value_dict = dict(zip(names, values))
+ return sqlbuilder.SQLQuery(DBSingleStyle.insert(table, name_value_dict))
def transaction(self):
return Transaction(self)
|
|
From: <sub...@co...> - 2005-10-12 12:59:09
|
Author: phd Date: 2005-10-12 12:58:57 +0000 (Wed, 12 Oct 2005) New Revision: 1107 Modified: home/phd/SQLObject/paramstyles/sqlobject/include/DBSingleStyle.py home/phd/SQLObject/paramstyles/sqlobject/include/update-paramstyles Log: Added __all__. Modified: home/phd/SQLObject/paramstyles/sqlobject/include/DBSingleStyle.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/include/DBSingleStyle.py 2005-10-12 04:16:42 UTC (rev 1106) +++ home/phd/SQLObject/paramstyles/sqlobject/include/DBSingleStyle.py 2005-10-12 12:58:57 UTC (rev 1107) @@ -6,6 +6,10 @@ # # See also Python Publishing Accessories (http://ppa.sourceforge.net/). +__all__ = ["Raw", "Param", "to_qmark", "to_numeric", "to_named", + "to_format", "to_pyformat", "insert"] + + class Raw: def __init__(self, value): self.value = value Modified: home/phd/SQLObject/paramstyles/sqlobject/include/update-paramstyles =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/include/update-paramstyles 2005-10-12 04:16:42 UTC (rev 1106) +++ home/phd/SQLObject/paramstyles/sqlobject/include/update-paramstyles 2005-10-12 12:58:57 UTC (rev 1107) @@ -12,8 +12,12 @@ # Author: Denis Otkidach (http://sourceforge.net/users/ods/). # License: Python (PSF). # -# See also Python Publishing Accessories (http://ppa.sourceforge.net/).' >DBSingleStyle.py.tmp2 +# See also Python Publishing Accessories (http://ppa.sourceforge.net/). +__all__ = ["Raw", "Param", "to_qmark", "to_numeric", "to_named", + "to_format", "to_pyformat", "insert"] +' >DBSingleStyle.py.tmp2 + awk 'NR==1 {} NR!=1 {print}' DBSingleStyle.py.tmp1 >>DBSingleStyle.py.tmp2 cmp -s DBSingleStyle.py.tmp2 DBSingleStyle.py && \ rm DBSingleStyle.py.tmp2 || \ |
|
From: <sub...@co...> - 2005-10-12 04:16:50
|
Author: victorng
Date: 2005-10-12 04:16:42 +0000 (Wed, 12 Oct 2005)
New Revision: 1106
Modified:
SQLObject/branches/victorng/sqlobject/tests/test_blob.py
Log:
- reverted the comment in test_create test case to demonstrate bug with blobs in sqlite
Modified: SQLObject/branches/victorng/sqlobject/tests/test_blob.py
===================================================================
--- SQLObject/branches/victorng/sqlobject/tests/test_blob.py 2005-10-12 04:05:08 UTC (rev 1105)
+++ SQLObject/branches/victorng/sqlobject/tests/test_blob.py 2005-10-12 04:16:42 UTC (rev 1106)
@@ -21,5 +21,4 @@
ImageData._connection.cache.clear()
prof2 = ImageData.get(iid)
- # TODO: go over this again --VictorNg
- #assert prof2.image == data
+ assert prof2.image == data
|