sqlobject-cvs Mailing List for SQLObject (Page 177)
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...> - 2004-09-03 16:00:23
|
Author: ianb
Date: 2004-09-03 07:50:04 -0400 (Fri, 03 Sep 2004)
New Revision: 211
Modified:
trunk/SQLObject/sqlobject/joins.py
Log:
Pay attention to joinMethodName keyword argument to joins
Modified: trunk/SQLObject/sqlobject/joins.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/joins.py 2004-08-30 17:19:22 UTC (rev 210)
+++ trunk/SQLObject/sqlobject/joins.py 2004-09-03 11:50:04 UTC (rev 211)
@@ -17,7 +17,10 @@
kw['otherClass'] =3D otherClass
kw['joinDef'] =3D self
self.kw =3D kw
- self._joinMethodName =3D None
+ if self.kw.has_key('joinMethodName'):
+ self._joinMethodName =3D self.kw.pop('joinMethodName')
+ else:
+ self._joinMethodName =3D None
=20
def _set_joinMethodName(self, value):
assert self._joinMethodName =3D=3D value or self._joinMethodName=
is None, "You have already given an explicit joinMethodName (%s), and yo=
u are now setting it to %s" % (self._joinMethodName, value)
|
|
From: <sub...@co...> - 2004-08-30 21:29:19
|
Author: ianb
Date: 2004-08-30 13:19:22 -0400 (Mon, 30 Aug 2004)
New Revision: 210
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Changed contraint name generation; since you may have two columns
that are both keys to the same table, you shouldn't use=20
foreign_table_name_exists as the constraint name, as it won't be unique.
Instead we use col_name_exists.
Modified: trunk/SQLObject/sqlobject/col.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/col.py 2004-08-30 17:15:21 UTC (rev 209)
+++ trunk/SQLObject/sqlobject/col.py 2004-08-30 17:19:22 UTC (rev 210)
@@ -450,7 +450,7 @@
tName =3D other._table
idName =3D other._idName
if self.cascade is not None:
- if self.cascade.lower() =3D=3D 'null':
+ if self.cascade =3D=3D 'null':
action =3D 'ON DELETE SET NULL'
elif self.cascade:
action =3D 'ON DELETE CASCADE'
@@ -458,7 +458,7 @@
action =3D 'ON DELETE RESTRICT'
else:
action =3D ''
- constraint =3D ('CONSTRAINT %(tName)s_exists '
+ constraint =3D ('CONSTRAINT %(colName)s_exists '
'FOREIGN KEY (%(colName)s) '
'REFERENCES %(tName)s (%(idName)s) '
'%(action)s' %
|
|
From: <sub...@co...> - 2004-08-30 21:25:18
|
Author: ianb
Date: 2004-08-30 13:15:21 -0400 (Mon, 30 Aug 2004)
New Revision: 209
Modified:
trunk/SQLObject/docs/News.txt
trunk/SQLObject/sqlobject/col.py
Log:
Added CASCADE SET NULL option
Modified: trunk/SQLObject/docs/News.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/docs/News.txt 2004-08-30 17:07:02 UTC (rev 208)
+++ trunk/SQLObject/docs/News.txt 2004-08-30 17:15:21 UTC (rev 209)
@@ -43,10 +43,10 @@
* ``*Col`` constructors now support cascade: ``cascade=3DNone``
(default) means no constraint; ``cascade=3DTrue`` means that if the
foreign key is deleted, the object will be deleted;
- ``cascade=3DFalse`` means that the delete will fail. ``SET NULL`` is
- not implemented, and the constraints are only implemented in the
- DBMS, not in SQLObject (i.e., they will not work in databases like
- MySQL and SQLite).
+ ``cascade=3DFalse`` means that the delete will fail;
+ ``cascade=3D"null"`` means that the column will be set to NULL. The
+ constraints are only implemented in the DBMS, not in SQLObject
+ (i.e., they will not work in databases like MySQL and SQLite).
=20
* New ``_create(id, **kw)`` method that can be overridden to intercept
and modify attempts to insert rows in the database.
Modified: trunk/SQLObject/sqlobject/col.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/col.py 2004-08-30 17:07:02 UTC (rev 208)
+++ trunk/SQLObject/sqlobject/col.py 2004-08-30 17:15:21 UTC (rev 209)
@@ -450,7 +450,9 @@
tName =3D other._table
idName =3D other._idName
if self.cascade is not None:
- if self.cascade:
+ if self.cascade.lower() =3D=3D 'null':
+ action =3D 'ON DELETE SET NULL'
+ elif self.cascade:
action =3D 'ON DELETE CASCADE'
else:
action =3D 'ON DELETE RESTRICT'
|
|
From: <sub...@co...> - 2004-08-30 21:16:57
|
Author: ianb
Date: 2004-08-30 13:07:02 -0400 (Mon, 30 Aug 2004)
New Revision: 208
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Use FOREIGN KEY constraints even if cascade isn't explicitly given
Modified: trunk/SQLObject/sqlobject/col.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/col.py 2004-08-30 17:01:33 UTC (rev 207)
+++ trunk/SQLObject/sqlobject/col.py 2004-08-30 17:07:02 UTC (rev 208)
@@ -446,20 +446,25 @@
def postgresCreateSQL(self):
from main import findClass
sql =3D SOKeyCol.postgresCreateSQL(self)
+ other =3D findClass(self.foreignKey)
+ tName =3D other._table
+ idName =3D other._idName
if self.cascade is not None:
- other =3D findClass(self.foreignKey)
- tName =3D other._table
- idName =3D other._idName
- action =3D self.cascade and 'CASCADE' or 'RESTRICT'
- constraint =3D ('CONSTRAINT %(tName)s_exists '
- 'FOREIGN KEY(%(colName)s) '
- 'REFERENCES %(tName)s(%(idName)s) '
- 'ON DELETE %(action)s' %
- {'tName':tName,
- 'colName':self.dbName,
- 'idName':idName,
- 'action':action})
- sql =3D ', '.join([sql, constraint])
+ if self.cascade:
+ action =3D 'ON DELETE CASCADE'
+ else:
+ action =3D 'ON DELETE RESTRICT'
+ else:
+ action =3D ''
+ constraint =3D ('CONSTRAINT %(tName)s_exists '
+ 'FOREIGN KEY (%(colName)s) '
+ 'REFERENCES %(tName)s (%(idName)s) '
+ '%(action)s' %
+ {'tName': tName,
+ 'colName': self.dbName,
+ 'idName': idName,
+ 'action': action})
+ sql =3D ', '.join([sql, constraint])
return sql
=20
def sybaseCreateSQL(self):
|
|
From: <sub...@co...> - 2004-08-30 21:11:38
|
Author: ianb
Date: 2004-08-30 13:01:33 -0400 (Mon, 30 Aug 2004)
New Revision: 207
Modified:
trunk/SQLObject/docs/News.txt
trunk/SQLObject/sqlobject/dbconnection.py
trunk/SQLObject/sqlobject/main.py
Log:
New classmethod createTableSQL() =20
Modified: trunk/SQLObject/docs/News.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/docs/News.txt 2004-08-25 20:30:11 UTC (rev 206)
+++ trunk/SQLObject/docs/News.txt 2004-08-30 17:01:33 UTC (rev 207)
@@ -56,6 +56,10 @@
This is a temporary interface; a more general specifier for primary
keys will be added later.
=20
+* New classmethod ``createTableSQL()`` method for SQLObject classes,
+ which returns the SQL that can be used to create the table. Analog
+ to ``createTable()``.
+
Bugs
----
=20
Modified: trunk/SQLObject/sqlobject/dbconnection.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/dbconnection.py 2004-08-25 20:30:11 UTC (re=
v 206)
+++ trunk/SQLObject/sqlobject/dbconnection.py 2004-08-30 17:01:33 UTC (re=
v 207)
@@ -313,20 +313,26 @@
return q
=20
def _SO_createJoinTable(self, join):
- self.query('CREATE TABLE %s (\n%s %s,\n%s %s\n)' %
- (join.intermediateTable,
- join.joinColumn,
- self.joinSQLType(join),
- join.otherColumn,
- self.joinSQLType(join)))
+ self.query(self._SO_createJoinTableSQL(join))
=20
+ def _SO_createJoinTableSQL(self, join):
+ return ('CREATE TABLE %s (\n%s %s,\n%s %s\n)' %
+ (join.intermediateTable,
+ join.joinColumn,
+ self.joinSQLType(join),
+ join.otherColumn,
+ self.joinSQLType(join)))
+
def _SO_dropJoinTable(self, join):
self.query("DROP TABLE %s" % join.intermediateTable)
=20
def createTable(self, soClass):
- self.query('CREATE TABLE %s (\n%s\n)' % \
- (soClass._table, self.createColumns(soClass)))
+ self.query(self.createTableSQL(soClass))
=20
+ def createTableSQL(self, soClass):
+ return ('CREATE TABLE %s (\n%s\n)' %=20
+ (soClass._table, self.createColumns(soClass)))
+
def createColumns(self, soClass):
columnDefs =3D [self.createIDColumn(soClass)] \
+ [self.createColumn(soClass, col)
Modified: trunk/SQLObject/sqlobject/main.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/main.py 2004-08-25 20:30:11 UTC (rev 206)
+++ trunk/SQLObject/sqlobject/main.py 2004-08-30 17:01:33 UTC (rev 207)
@@ -975,25 +975,41 @@
cls.createJoinTables(ifNotExists=3DifNotExists)
createTable =3D classmethod(createTable)
=20
+ def createTableSQL(cls, createJoinTables=3DTrue):
+ sql =3D cls._connection.createTableSQL(cls)
+ if createJoinTables:
+ sql +=3D '\n' + cls.createJoinTablesSQL()
+ return sql
+ createTableSQL =3D classmethod(createTableSQL)
+
def createJoinTables(cls, ifNotExists=3DFalse):
+ for join in cls._getJoinsToCreate():
+ if ifNotExists and \
+ cls._connection.tableExists(join.intermediateTable):
+ continue
+ cls._connection._SO_createJoinTable(join)
+ createJoinTables =3D classmethod(createJoinTables)
+
+ def createJoinTablesSQL(cls):
+ sql =3D []
+ for join in cls._getJoinsToCreate():
+ sql.append(cls._connection._SO_createJoinTableSQL(join))
+ return '\n'.join(sql)
+ createJoinTablesSQL =3D classmethod(createJoinTablesSQL)
+
+ def _getJoinsToCreate(cls):
+ joins =3D []
for join in cls._SO_joinList:
if not join:
continue
if not join.hasIntermediateTable():
continue
- # This join will show up twice, in each of the
- # classes, but we only create the table once. We
- # arbitrarily create it while we're creating the
- # alphabetically earlier class.
if join.soClass.__name__ > join.otherClass.__name__:
continue
- if ifNotExists and \
- cls._connection.tableExists(join.intermediateTable):
- continue
- cls._connection._SO_createJoinTable(join)
+ joins.append(join)
+ return joins
+ _getJoinsToCreate =3D classmethod(_getJoinsToCreate)
=20
- createJoinTables =3D classmethod(createJoinTables)
-
def dropJoinTables(cls, ifExists=3DFalse):
for join in cls._SO_joinList:
if not join:
|
|
From: <sub...@co...> - 2004-08-25 17:48:33
|
Author: ianb
Date: 2004-08-25 09:38:57 -0400 (Wed, 25 Aug 2004)
New Revision: 202
Modified:
trunk/SQLObject/docs/FAQ.txt
Log:
New FAQ about reloading modules
Modified: trunk/SQLObject/docs/FAQ.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/docs/FAQ.txt 2004-08-25 02:06:07 UTC (rev 201)
+++ trunk/SQLObject/docs/FAQ.txt 2004-08-25 13:38:57 UTC (rev 202)
@@ -197,3 +197,32 @@
.. raw:: html
:file: ../examples/snippets/image-binary-sqlite.html
=20
+
+Reloading Modules
+-----------------
+
+If you've tried to reload a module that defines SQLObject subclasses,
+you've probably encountered various odd errors. The short answer: you
+can't reload these modules.
+
+The long answer: reloading modules in Python doesn't work very well.
+Reloading actually means *re-running* the module. Every ``class``
+statement creates a class -- but your old classes don't disappear.
+When you reload a module, new classes are created, and they take over
+the names in the module.
+
+SQLObject, however, doesn't search the names in a module to find a
+class. When you say ``ForeignKey('SomeClass')``, SQLObject looks for
+any SQLObject subclass anywhere with the name ``SomeClass``. This is
+to avoid problems with circular imports and circular dependencies, as
+tables have forward- and back-references, and other circular
+dependencies. SQLObject resolves these dependencies lazily.
+
+But when you reload a module, suddenly there will be two SQLObject
+classes in the process with the same name. SQLObject doesn't know
+that one of them is obsolete. And even if it did, it doesn't know
+every other place in the system that has a reference to that obsolete
+class.
+
+For this reason and several others, reloading modules is highly
+error-prone and difficult to support.
|
|
From: <sub...@co...> - 2004-08-19 00:37:51
|
Author: ianb
Date: 2004-08-18 16:29:02 -0400 (Wed, 18 Aug 2004)
New Revision: 193
Modified:
trunk/SQLObject/sqlobject/mysql/mysqlconnection.py
Log:
MySQL insert ID fix (from mailing list)
Modified: trunk/SQLObject/sqlobject/mysql/mysqlconnection.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/mysql/mysqlconnection.py 2004-08-18 03:12:0=
9 UTC (rev 192)
+++ trunk/SQLObject/sqlobject/mysql/mysqlconnection.py 2004-08-18 20:29:0=
2 UTC (rev 193)
@@ -52,7 +52,7 @@
self.printDebug(conn, q, 'QueryIns')
self._executeRetry(conn, c, q)
if id is None:
- id =3D c.insert_id()
+ id =3D c.lastrowid
if self.debugOutput:
self.printDebug(conn, id, 'QueryIns', 'result')
return id
|
|
From: <sub...@co...> - 2004-08-18 23:55:58
|
Author: ianb
Date: 2004-08-17 16:41:39 -0400 (Tue, 17 Aug 2004)
New Revision: 176
Modified:
trunk/SQLObject/docs/News.txt
trunk/SQLObject/sqlobject/converters.py
Log:
Convert long ints properly=20
Modified: trunk/SQLObject/docs/News.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/docs/News.txt 2004-08-17 20:35:43 UTC (rev 175)
+++ trunk/SQLObject/docs/News.txt 2004-08-17 20:41:39 UTC (rev 176)
@@ -48,6 +48,9 @@
DBMS, not in SQLObject (i.e., they will not work in databases like
MySQL and SQLite).
=20
+* New ``_create(id, **kw)`` method that can be overridden to intercept
+ and modify attempts to insert rows in the database.
+
Bugs
----
=20
@@ -61,6 +64,7 @@
=20
* Python 2.2 booleans fixed (SF: 903488)
=20
+* Longs (e.g., ``1L``) get converted properly (SF: 939965)
=20
SQLObject 0.5.2
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Modified: trunk/SQLObject/sqlobject/converters.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/converters.py 2004-08-17 20:35:43 UTC (rev =
175)
+++ trunk/SQLObject/sqlobject/converters.py 2004-08-17 20:41:39 UTC (rev =
176)
@@ -105,8 +105,12 @@
return repr(int(value))
=20
registerConverter(type(1), IntConverter)
-registerConverter(type(0L), IntConverter)
=20
+def LongConverter(value, db):
+ return str(value)
+
+registerConverter(type(0L), LongConverter)
+
if NumericType:
registerConverter(NumericType, IntConverter)
=20
|
|
From: <sub...@co...> - 2004-08-18 07:57:30
|
Author: ianb
Date: 2004-08-17 16:43:23 -0400 (Tue, 17 Aug 2004)
New Revision: 178
Modified:
trunk/SQLObject/sqlobject/main.py
Log:
Typo (SF: 944684)
Modified: trunk/SQLObject/sqlobject/main.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/main.py 2004-08-17 20:42:09 UTC (rev 177)
+++ trunk/SQLObject/sqlobject/main.py 2004-08-17 20:43:23 UTC (rev 178)
@@ -1045,7 +1045,7 @@
self._connection.cache.expire(self.id, self.__class__)
=20
def delete(cls, id):
- obj =3D cls(id)
+ obj =3D cls.get(id)
obj.destroySelf()
=20
delete =3D classmethod(delete)
|
|
From: <sub...@co...> - 2004-08-18 07:20:53
|
Author: ianb
Date: 2004-08-17 23:12:09 -0400 (Tue, 17 Aug 2004)
New Revision: 192
Modified:
trunk/SQLObject/tests/test.py
Log:
Fixed test case that didn't clean up after itself
Modified: trunk/SQLObject/tests/test.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/tests/test.py 2004-08-18 03:06:00 UTC (rev 191)
+++ trunk/SQLObject/tests/test.py 2004-08-18 03:12:09 UTC (rev 192)
@@ -997,10 +997,14 @@
SQLObjectTest.setUp(self)
self.conn =3D Lazy._connection
self.conn.didUpdate =3D False
- oldUpdate =3D self.conn._SO_update
- newUpdate =3D lambda so, values, s=3Dself, c=3Dself.conn, o=3Dol=
dUpdate: self._alternateUpdate(so, values, c, o)
+ self._oldUpdate =3D self.conn._SO_update
+ newUpdate =3D lambda so, values, s=3Dself, c=3Dself.conn, o=3Dse=
lf._oldUpdate: self._alternateUpdate(so, values, c, o)
self.conn._SO_update =3D newUpdate
=20
+ def tearDown(self):
+ self.conn._SO_update =3D self._oldUpdate
+ del self._oldUpdate
+
def _alternateUpdate(self, so, values, conn, oldUpdate):
conn.didUpdate =3D True
return oldUpdate(so, values)
|
|
From: <sub...@co...> - 2004-08-18 07:14:45
|
Author: ianb
Date: 2004-08-17 23:06:00 -0400 (Tue, 17 Aug 2004)
New Revision: 191
Modified:
trunk/SQLObject/sqlobject/dbconnection.py
trunk/SQLObject/tests/test.py
Log:
Fixed some transaction bugs
Modified: trunk/SQLObject/sqlobject/dbconnection.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/dbconnection.py 2004-08-18 02:53:07 UTC (re=
v 190)
+++ trunk/SQLObject/sqlobject/dbconnection.py 2004-08-18 03:06:00 UTC (re=
v 191)
@@ -148,7 +148,7 @@
else:
s +=3D ' pool=3D[%s]' % ', '.join([str(self._connectionN=
umbers[id(v)]) for v in self._pool])
self.printDebug(conn, s, 'Pool')
- if self.supportTransactions:
+ if self.supportTransactions and not explicit:
if self.autoCommit =3D=3D 'exception':
if self.debug:
self.printDebug(conn, 'auto/exception', 'ROLLBACK')
@@ -435,6 +435,9 @@
dbconn.printDebug(rawconn, self.query, 'Select')
self.dbconn._executeRetry(self.rawconn, self.cursor, self.query)
=20
+ def __iter__(self):
+ return self
+
def next(self):
result =3D self.cursor.fetchone()
if result is None:
@@ -497,8 +500,8 @@
# still iterating through the results.
# @@: But would it be okay for psycopg, with threadsafety
# level 2?
- return list(Iteration(self, self._connection,
- select, keepConnection=3DTrue))
+ return iter(list(Iteration(self, self._connection,
+ select, keepConnection=3DTrue)))
=20
def commit(self):
if self._obsolete:
Modified: trunk/SQLObject/tests/test.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/tests/test.py 2004-08-18 02:53:07 UTC (rev 190)
+++ trunk/SQLObject/tests/test.py 2004-08-18 03:06:00 UTC (rev 191)
@@ -442,6 +442,7 @@
TestSOTrans._connection.autoCommit =3D 'exception'
TestSOTrans(name=3D'joe', connection=3Dtrans)
trans.rollback()
+ trans.begin()
self.assertEqual([n.name for n in TestSOTrans.select(connect=
ion=3Dtrans)],
['bob', 'tim'])
b =3D TestSOTrans.byName('bob', connection=3Dtrans)
@@ -450,6 +451,7 @@
self.assertEqual(b.name, 'robert')
b.name =3D 'bob'
trans.rollback()
+ trans.begin()
self.assertEqual(b.name, 'robert')
finally:
TestSOTrans._connection.autoCommit =3D True
@@ -886,6 +888,7 @@
class SOStringID(SQLObject):
=20
_table =3D 'so_string_id'
+ _idType =3D str
val =3D StringCol(alternateID=3DTrue)
=20
mysqlCreate =3D """
|
|
From: <sub...@co...> - 2004-08-18 07:01:50
|
Author: ianb
Date: 2004-08-17 22:53:07 -0400 (Tue, 17 Aug 2004)
New Revision: 190
Modified:
trunk/SQLObject/sqlobject/postgres/pgconnection.py
trunk/SQLObject/tests/test.py
Log:
Fixed PG _fromDatabase primary key detection
Modified: trunk/SQLObject/sqlobject/postgres/pgconnection.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/postgres/pgconnection.py 2004-08-18 02:52:3=
6 UTC (rev 189)
+++ trunk/SQLObject/sqlobject/postgres/pgconnection.py 2004-08-18 02:53:0=
7 UTC (rev 190)
@@ -12,8 +12,7 @@
schemes =3D [dbName, 'postgresql', 'psycopg']
=20
def __init__(self, dsn=3DNone, host=3DNone, db=3DNone,
- user=3DNone, passwd=3DNone, autoCommit=3D1,
- usePygresql=3DFalse,
+ user=3DNone, passwd=3DNone, usePygresql=3DFalse,
**kw):
global psycopg, pgdb
if usePygresql:
@@ -25,7 +24,6 @@
import psycopg
self.pgmodule =3D psycopg
=20
- self.autoCommit =3D autoCommit
if dsn is None:
dsn =3D []
if db:
@@ -116,7 +114,7 @@
keyQuery =3D """
SELECT pg_catalog.pg_get_constraintdef(oid) as condef
FROM pg_catalog.pg_constraint r
- WHERE r.conrelid =3D '%s'::regclass AND r.contype =3D 'f'"""
+ WHERE r.conrelid =3D %s::regclass AND r.contype =3D 'f'"""
=20
colQuery =3D """
SELECT a.attname,
@@ -124,22 +122,48 @@
(SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d
WHERE d.adrelid=3Da.attrelid AND d.adnum =3D a.attnum)
FROM pg_catalog.pg_attribute a
- WHERE a.attrelid =3D'%s'::regclass
+ WHERE a.attrelid =3D%s::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum"""
=20
- keyData =3D self.queryAll(keyQuery % tableName)
- keyRE =3D re.compile("\((.+)\) REFERENCES (.+)\(")
+ primaryKeyQuery =3D """
+ SELECT pg_index.indisprimary,
+ pg_catalog.pg_get_indexdef(pg_index.indexrelid)
+ FROM pg_catalog.pg_class c, pg_catalog.pg_class c2,
+ pg_catalog.pg_index AS pg_index
+ WHERE c.relname =3D %s
+ AND c.oid =3D pg_index.indrelid
+ AND pg_index.indexrelid =3D c2.oid
+ AND pg_index.indisprimary
+ """
+
+ keyData =3D self.queryAll(keyQuery % self.sqlrepr(tableName))
+ keyRE =3D re.compile(r"\((.+)\) REFERENCES (.+)\(")
keymap =3D {}
+ =20
for (condef,) in keyData:
match =3D keyRE.search(condef)
if match:
field, reftable =3D match.groups()
keymap[field] =3D reftable.capitalize()
- colData =3D self.queryAll(colQuery % tableName)
+
+ primaryData =3D self.queryAll(primaryKeyQuery % self.sqlrepr(tab=
leName))
+ primaryRE =3D re.compile(r'CREATE .*? USING .* \((.+?)\)')
+ primaryKey =3D None
+ for isPrimary, indexDef in primaryData:
+ match =3D primaryRE.search(indexDef)
+ assert match, "Unparseable contraint definition: %r" % index=
Def
+ assert primaryKey is None, "Already found primary key (%r), =
then found: %r" % (primaryKey, indexDef)
+ primaryKey =3D match.group(1)
+ assert primaryKey, "No primary key found in table %r" % tableNam=
e
+ if primaryKey.startswith('"'):
+ assert primaryKey.endswith('"')
+ primaryKey =3D primaryKey[1:-1]
+
+ colData =3D self.queryAll(colQuery % self.sqlrepr(tableName))
results =3D []
for field, t, notnull, defaultstr in colData:
- if field =3D=3D 'id':
+ if field =3D=3D primaryKey:
continue
colClass, kw =3D self.guessClass(t)
kw['name'] =3D soClass._style.dbColumnToPythonAttr(field)
Modified: trunk/SQLObject/tests/test.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/tests/test.py 2004-08-18 02:52:36 UTC (rev 189)
+++ trunk/SQLObject/tests/test.py 2004-08-18 02:53:07 UTC (rev 190)
@@ -639,7 +639,7 @@
=20
postgresCreate =3D """
CREATE TABLE auto_test (
- auto_id SERIAL,
+ auto_id SERIAL PRIMARY KEY,
first_name VARCHAR(100),
last_name VARCHAR(200) NOT NULL,
age INT DEFAULT 0,
|
|
From: <sub...@co...> - 2004-08-18 07:01:19
|
Author: ianb Date: 2004-08-17 22:52:36 -0400 (Tue, 17 Aug 2004) New Revision: 189 Modified: trunk/SQLObject/docs/News.txt Log: Notes Modified: trunk/SQLObject/docs/News.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/docs/News.txt 2004-08-18 02:28:48 UTC (rev 188) +++ trunk/SQLObject/docs/News.txt 2004-08-18 02:52:36 UTC (rev 189) @@ -64,6 +64,8 @@ * You can now use ``sqlite:/:memory:`` to store the database in memory. =20 +* Some bugs resolved when caching is turned off (SF 956847) + SQLObject 0.5.3 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 |
|
From: <sub...@co...> - 2004-08-18 06:57:44
|
Author: ianb
Date: 2004-08-17 16:42:09 -0400 (Tue, 17 Aug 2004)
New Revision: 177
Modified:
branches/SQLObject/0.5/SQLObject/Converters.py
Log:
Backport of long int fix
Modified: branches/SQLObject/0.5/SQLObject/Converters.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/SQLObject/0.5/SQLObject/Converters.py 2004-08-17 20:41:39 UT=
C (rev 176)
+++ branches/SQLObject/0.5/SQLObject/Converters.py 2004-08-17 20:42:09 UT=
C (rev 177)
@@ -105,8 +105,12 @@
return repr(int(value))
=20
registerConverter(type(1), IntConverter)
-registerConverter(type(0L), IntConverter)
=20
+def LongConverter(value, db):
+ return str(value)
+
+registerConverter(type(0L), LongConverter)
+
if NumericType:
registerConverter(NumericType, IntConverter)
=20
|
|
From: <sub...@co...> - 2004-08-18 06:37:32
|
Author: ianb
Date: 2004-08-17 22:28:48 -0400 (Tue, 17 Aug 2004)
New Revision: 188
Modified:
trunk/SQLObject/tests/test.py
Log:
Test to look at SF 956839: destroySelf() doesn't work if cache=3DFalse
Modified: trunk/SQLObject/tests/test.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/tests/test.py 2004-08-18 02:20:49 UTC (rev 187)
+++ trunk/SQLObject/tests/test.py 2004-08-18 02:28:48 UTC (rev 188)
@@ -22,6 +22,7 @@
from mx import DateTime
global curr_db
curr_db =3D None
+from sqlobject import cache
=20
########################################
## Basic operation
@@ -394,7 +395,29 @@
obj.destroySelf()
self.assertEqual(list(TestSO1.select('all')), [])
=20
+########################################
+## Delete without caching
+########################################
=20
+class NoCache(SQLObject):
+ name =3D StringCol()
+
+class TestNoCache(SQLObjectTest):
+
+ classes=3D[NoCache]
+
+ def setUp(self):
+ SQLObjectTest.setUp(self)
+ NoCache._connection.cache =3D cache.CacheSet(cache=3DFalse)
+
+ def tearDown(self):
+ NoCache._connection.cache =3D cache.CacheSet(cache=3DTrue)
+ SQLObjectTest.tearDown(self)
+
+ def testDestroySelf(self):
+ value =3D NoCache(name=3D'test')
+ value.destroySelf()
+
########################################
## Transaction test
########################################
|
|
From: <sub...@co...> - 2004-08-18 06:29:38
|
Author: ianb
Date: 2004-08-17 22:20:49 -0400 (Tue, 17 Aug 2004)
New Revision: 187
Modified:
trunk/SQLObject/sqlobject/cache.py
Log:
Don't try to expire objects if cacheValues=3DValues (SF 956847)
Modified: trunk/SQLObject/sqlobject/cache.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/cache.py 2004-08-18 00:05:24 UTC (rev 186)
+++ trunk/SQLObject/sqlobject/cache.py 2004-08-18 02:20:49 UTC (rev 187)
@@ -137,6 +137,8 @@
self.expiredCache.clear()
=20
def expire(self, id):
+ if not self.doCache:
+ return
self.lock.acquire()
try:
if self.cache.has_key(id):
|
|
From: <sub...@co...> - 2004-08-18 04:14:09
|
Author: ianb
Date: 2004-08-17 20:05:24 -0400 (Tue, 17 Aug 2004)
New Revision: 186
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Allow sqlType to override StringCol's default type
Modified: trunk/SQLObject/sqlobject/col.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/col.py 2004-08-17 22:58:02 UTC (rev 185)
+++ trunk/SQLObject/sqlobject/col.py 2004-08-18 00:05:24 UTC (rev 186)
@@ -304,6 +304,8 @@
return constraints
=20
def _sqlType(self):
+ if self.customSQLType is not None:
+ return self.customSQLType
if not self.length:
return 'TEXT'
elif self.varchar:
|
|
From: <sub...@co...> - 2004-08-18 03:06:46
|
Author: ianb
Date: 2004-08-17 18:58:02 -0400 (Tue, 17 Aug 2004)
New Revision: 185
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Make SQLite use TINYINT for boolean columns (not default of str)
Modified: trunk/SQLObject/sqlobject/col.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/col.py 2004-08-17 22:57:17 UTC (rev 184)
+++ trunk/SQLObject/sqlobject/col.py 2004-08-17 22:58:02 UTC (rev 185)
@@ -383,6 +383,9 @@
def _maxdbType(self):
return "BOOLEAN"
=20
+ def _sqliteType(self):
+ return "TINYINT"
+
class BoolCol(Col):
baseClass =3D SOBoolCol
=20
|
|
From: <sub...@co...> - 2004-08-18 03:06:01
|
Author: ianb
Date: 2004-08-17 18:57:17 -0400 (Tue, 17 Aug 2004)
New Revision: 184
Modified:
trunk/SQLObject/sqlobject/col.py
trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py
Log:
Got rid of some bad tabs; fixed other minor whitespace issues.
Modified: trunk/SQLObject/sqlobject/col.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/col.py 2004-08-17 22:41:14 UTC (rev 183)
+++ trunk/SQLObject/sqlobject/col.py 2004-08-17 22:57:17 UTC (rev 184)
@@ -206,7 +206,7 @@
return self._sqlType()
=20
def _maxdbType(self):
- return self._sqlType()
+ return self._sqlType()
=20
def mysqlCreateSQL(self):
return ' '.join([self.dbName, self._mysqlType()] + self._extraSQ=
L())
@@ -228,7 +228,7 @@
return ' '.join([self.dbName, self._firebirdType()] + self._=
extraSQL())
else:
return ' '.join([self.dbName] + [self._firebirdType()[0]] + =
self._extraSQL() + [self._firebirdType()[1]])
-=09
+
def maxdbCreateSQL(self):
return ' '.join([self.dbName, self._maxdbType()] + self._extraSQL=
())
=20
@@ -324,10 +324,10 @@
return self._sqlType()
=20
def _maxdbType(self):
- if not self.length:
- return 'LONG ASCII'
- else:
- return self._sqlType()
+ if not self.length:
+ return 'LONG ASCII'
+ else:
+ return self._sqlType()
=20
class StringCol(Col):
baseClass =3D SOStringCol
@@ -380,8 +380,8 @@
def _firebirdType(self):
return 'INT'
=20
- def _maxdbType(self):
- return "BOOLEAN"
+ def _maxdbType(self):
+ return "BOOLEAN"
=20
class BoolCol(Col):
baseClass =3D SOBoolCol
@@ -469,17 +469,17 @@
sql =3D ' '.join([sql, reference])
return sql
=20
- def maxdbCreateSQL(self):
- from main import findClass
- other =3D findClass(self.foreignKey)
- fidName =3D self.dbName
- #I assume that foreign key name is identical to the id of the referen=
ce table =09
- sql =3D ' '.join([fidName, self._maxdbType()])
- tName =3D other._table
- idName =3D other._idName
- sql=3Dsql + ',' + '\n'=20
- sql=3Dsql + 'FOREIGN KEY (%s) REFERENCES %s(%s)'%(fidName,tName,idNam=
e)
- return sql
+ def maxdbCreateSQL(self):
+ from main import findClass
+ other =3D findClass(self.foreignKey)
+ fidName =3D self.dbName
+ #I assume that foreign key name is identical to the id of the re=
ference table
+ sql =3D ' '.join([fidName, self._maxdbType()])
+ tName =3D other._table
+ idName =3D other._idName
+ sql=3Dsql + ',' + '\n'=20
+ sql=3Dsql + 'FOREIGN KEY (%s) REFERENCES %s(%s)'%(fidName,tName,=
idName)
+ return sql
=20
class ForeignKey(KeyCol):
=20
@@ -521,8 +521,8 @@
#NB. Return a tuple, not a string here
return "VARCHAR(%i)" % (length), checkConstraint
=20
- def _maxdbType(self):
- raise "Enum type is not supported"
+ def _maxdbType(self):
+ raise "Enum type is not supported"
=20
class EnumCol(Col):
baseClass =3D SOEnumCol
@@ -548,7 +548,7 @@
return 'TIMESTAMP'
=20
def _maxdbType(self):
- return 'TIMESTAMP'
+ return 'TIMESTAMP'
=20
class DateTimeCol(Col):
baseClass =3D SODateTimeCol
Modified: trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py 2004-08-17 22:41:1=
4 UTC (rev 183)
+++ trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py 2004-08-17 22:57:1=
7 UTC (rev 184)
@@ -19,261 +19,278 @@
=20
=20
class maxdbException(Exception):
- def __init__(self, value):
- self.value =3D value
- def __str__(self):
- return repr(self.value)
-=09
+
+ def __init__(self, value):
+ self.value =3D value
+
+ def __str__(self):
+ return repr(self.value)
+ =20
class LowerBoundOfSliceIsNotSupported(maxdbException):
- def __init__(self, value):
- maxdbException.__init__(self,'')
-=09
+ def __init__(self, value):
+ maxdbException.__init__(self, '')
=20
class IncorrectIDStyleError(maxdbException) :
- def __init__(self,value):
- maxdbException.__init__(self,'This primary key name is not in the exp=
ected style,please rename the column to %s or switch to another style'%(v=
alue))
+ def __init__(self,value):
+ maxdbException.__init__(
+ self,
+ 'This primary key name is not in the expected style, '
+ 'please rename the column to %r or switch to another style'
+ % value)
=20
class StyleMismatchError(maxdbException):
- def __init__(self, value):
- maxdbException.__init__(self,'The name %s is only permitted for primar=
y key,change the column name or switch to another style'%value)
+ def __init__(self, value):
+ maxdbException.__init__(
+ self,
+ 'The name %r is only permitted for primary key, change the '
+ 'column name or switch to another style' % value)
=20
-
class PrimaryKeyNotFounded(maxdbException):
- def __init__(self, value):
- maxdbException.__init__(self,"No primary key was defined on table %s"%=
(value))
+ def __init__(self, value):
+ maxdbException.__init__(
+ self,
+ "No primary key was defined on table %r" % value)
=20
- =09
SAPDBMAX_ID_LENGTH=3D32 =20
- =09
+
class MaxdbConnection(DBAPI):
-
=20
- supportTransactions =3D True
- dbName =3D 'maxdb'
- schemes =3D [dbName]
+ supportTransactions =3D True
+ dbName =3D 'maxdb'
+ schemes =3D [dbName]
=20
- def __init__ (self, user, password, database, host =3D '',autoCommit=3D=
1,sqlmode=3D'internal',isolation=3DNone,timeout=3DNone, **kw):
- global dbapi
- if dbapi is None:
- from sapdb import dbapi
- self.autoCommit =3D autoCommit
- self.user =3D user
- self.password =3D password
- self.database =3D database
- self.host =3D host
- self.sqlmode =3D sqlmode
- self.isolation =3D isolation
- self.timeout =3D timeout
- =20
- DBAPI.__init__(self, **kw)
- =20
- def connectionFromURI(cls, uri):
- auth, password, host, path, args =3D cls._parseURI(uri)
- path =3D path.replace('/', os.path.sep)
- return cls(host, db=3Dpath, user=3Dauth, passwd=3Dpassword, **args)
- connectionFromURI =3D classmethod(connectionFromURI)
-=09
- =09
- def _getConfigParams(self,sqlmode,auto):
- autocommit=3D'off'
- if auto:autocommit=3D'on'
- opt=3D{}
- opt["autocommit"]=3Dautocommit
- opt["sqlmode"]=3Dsqlmode
- if self.isolation:
- opt["isolation"]=3Dself.isolation
- if self.timeout :
- opt["timeout"]=3Dself.timeout
- =09
- return opt
- =09
- def _setAutoCommit(self, conn, auto):
- conn.close()
- conn.__init__(self.user, self.password, self.database, self.host,**sel=
f._getConfigParams(self.sqlmode,auto))
- =09
- =20
-=09
- =20
- def createSequenceName(self,table):
- """ sequence name are builded with the concatenation of the table name=
with '_SEQ' word
- we truncate the name of the sequence_name because
- sapdb identifier cannot exceed 32 characters
- so that the name of the sequence does not exceed 32 characters
- """
- return '%s_SEQ'%(table[:SAPDBMAX_ID_LENGTH -4])
-=09
- def makeConnection(self):
- conn =3D dbapi.Connection(self.user, self.password, self.database, se=
lf.host,**self._getConfigParams(self.sqlmode,self.autoCommit) )
- return conn
-=09
- def _queryInsertID(self, conn, soInstance, id, names, values):
- table =3D soInstance._table
- idName =3D soInstance._idName
- c =3D conn.cursor()
- if id is None:
- c.execute('SELECT %s.NEXTVAL FROM DUAL' % (self.createSequenceName(ta=
ble)))
- id =3D c.fetchone()[0]
- names =3D [idName] + names
- values =3D [id] + values
- q =3D self._insertSQL(table, names, values)
- if self.debug:
- self.printDebug(conn, q, 'QueryIns')
- c.execute(q)
- if self.debugOutput:
- self.printDebug(conn, id, 'QueryIns', 'result')
- return id
-=09
- def sqlAddLimit(self,query,limit):
- sql =3D query
- sql =3D sql.replace("SELECT","SELECT ROWNO, ")
- if sql.find('WHERE') !=3D -1:
- sql =3D sql + ' AND ' + limit
- else:=09
- sql =3D sql + 'WHERE ' + limit
+ def __init__ (self, user, password, database,
+ host=3D'', autoCommit=3D1, sqlmode=3D'internal',
+ isolation=3DNone, timeout=3DNone, **kw):
+ global dbapi
+ if dbapi is None:
+ from sapdb import dbapi
+ self.autoCommit =3D autoCommit
+ self.user =3D user
+ self.password =3D password
+ self.database =3D database
+ self.host =3D host
+ self.sqlmode =3D sqlmode
+ self.isolation =3D isolation
+ self.timeout =3D timeout
=20
- return sql
- =09
- def _queryAddLimitOffset(self, query, start, end):
- if start: raise LowerBoundOfSliceIsNotSupported
- limit =3D ' ROWNO <=3D %d ' % (end)
- return self.sqlAddLimit(query,limit)
+ DBAPI.__init__(self, **kw)
=20
- =20
- def createTable(self, soClass):
- #we create the table in a transaction because the addition of the
- #table and the sequence must be atomic=20
+ def connectionFromURI(cls, uri):
+ auth, password, host, path, args =3D cls._parseURI(uri)
+ path =3D path.replace('/', os.path.sep)
+ return cls(host, db=3Dpath, user=3Dauth, passwd=3Dpassword, **ar=
gs)
+ connectionFromURI =3D classmethod(connectionFromURI)
=20
- #i tried to use the transaction class but i get a recursion limi=
t error =20
- # t=3Dself.transaction()
- # t.query('CREATE TABLE %s (\n%s\n)' % \
- # (soClass._table, self.createColumns(soClass)))
- # =09
- # t.query("CREATE SEQUENCE %s" % self.createSequenceName(soClass._ta=
ble))
- # t.commit()
- =09
- #so use transaction when the problem will be solved
- self.query('CREATE TABLE %s (\n%s\n)' % \
- (soClass._table, self.createColumns(soClass)))
- self.query("CREATE SEQUENCE %s" % self.createSequenceName(soClass._tab=
le))
+ def _getConfigParams(self,sqlmode,auto):
+ autocommit=3D'off'
+ if auto:
+ autocommit=3D'on'
+ opt =3D {}
+ opt["autocommit"] =3D autocommit
+ opt["sqlmode"] =3D sqlmode
+ if self.isolation:
+ opt["isolation"]=3Dself.isolation
+ if self.timeout :
+ opt["timeout"]=3Dself.timeout
+ return opt
+
+ def _setAutoCommit(self, conn, auto):
+ conn.close()
+ conn.__init__(self.user, self.password, self.database,
+ self.host,
+ **self._getConfigParams(self.sqlmode,auto))
=20
-=09
- def createColumn(self, soClass, col):
- return col.maxdbCreateSQL()
-=09
- def createIDColumn(self, soClass):
- return '%s INT PRIMARY KEY' % soClass._idName
-=09
- def dropTable(self, tableName,cascade=3DFalse):
- #we drop the table in a transaction because the removal of the
- #table and the sequence must be atomic=20
- #i tried to use the transaction class but i get a recursion limit erro=
r=09
- # try:
- # t=3Dself.transaction()
- # t.query("DROP TABLE %s" % tableName)
- # t.query("DROP SEQUENCE %s" % self.createSequenceName(tableName))
- # t.commit()
- # except:t.rollback()
- #so use transaction when the problem will be solved
- self.query("DROP TABLE %s" % tableName)
- self.query("DROP SEQUENCE %s" % self.createSequenceName(tableName))
-=09
- def joinSQLType(self, join):
- return 'INT NOT NULL'
-=09
- def tableExists(self, tableName):
- for (table,) in self.queryAll("SELECT OBJECT_NAME FROM ALL_OBJECTS WHE=
RE OBJECT_TYPE=3D'TABLE'"):
- if table.lower() =3D=3D tableName.lower():
- return True
- return False
- =20
-=09
- def addColumn(self, tableName, column):
- self.query('ALTER TABLE %s ADD %s' %
- (tableName,
- column.maxdbCreateSQL()))
-=09
- def delColumn(self, tableName, column):
- self.query('ALTER TABLE %s DROP COLUMN %s' %
- (tableName,
- column.dbName))
-=09
+ def createSequenceName(self,table):
+ """
+ sequence name are builded with the concatenation of the table
+ name with '_SEQ' word we truncate the name of the
+ sequence_name because sapdb identifier cannot exceed 32
+ characters so that the name of the sequence does not exceed 32
+ characters
+ """
+ return '%s_SEQ'%(table[:SAPDBMAX_ID_LENGTH -4])
=20
+ def makeConnection(self):
+ conn =3D dbapi.Connection(
+ self.user, self.password, self.database, self.host,
+ **self._getConfigParams(self.sqlmode,self.autoCommit))
+ return conn
=20
+ def _queryInsertID(self, conn, soInstance, id, names, values):
+ table =3D soInstance._table
+ idName =3D soInstance._idName
+ c =3D conn.cursor()
+ if id is None:
+ c.execute('SELECT %s.NEXTVAL FROM DUAL' % (self.createSequen=
ceName(table)))
+ id =3D c.fetchone()[0]
+ names =3D [idName] + names
+ values =3D [id] + values
+ q =3D self._insertSQL(table, names, values)
+ if self.debug:
+ self.printDebug(conn, q, 'QueryIns')
+ c.execute(q)
+ if self.debugOutput:
+ self.printDebug(conn, id, 'QueryIns', 'result')
+ return id
=20
- GET_COLUMNS =3D (" SELECT COLUMN_NAME,NULLABLE,DATA_DEFAULT,DATA_TYPE=
, DATA_LENGTH,DATA_SCALE FROM USER_TAB_COLUMNS WHERE TABLE_NAME=3DUPPER('=
%s')")
- GET_PK_AND_FK =3D (""" SELECT constraint_cols .column_name,constraints.=
constraint_type , refname,reftablename FROM
- user_cons_columns constraint_cols=20
- INNER JOIN user_constraints constraints ON constraint_cols.cons=
traint_name=3Dconstraints.constraint_name=20
- LEFT OUTER JOIN show_foreign_key fk on constraint_cols.column_nam=
e=3Dfk.columnname
- WHERE constraints.table_name =3DUPPER('%s')"""
- )
-=09
- def columnsFromSchema(self, tableName, soClass):
- colData =3D self.queryAll(self.GET_COLUMNS
- % tableName)
- =09
- results =3D []
- keymap =3D {}
- pkmap=3D{}
- fkData =3D self.queryAll(self.GET_PK_AND_FK% tableName)
- for col, cons_type, refcol, reftable in fkData:
- col_name=3D col.lower()
- pkmap[col_name]=3DFalse
- if cons_type =3D=3D 'R':
- keymap[col_name]=3Dreftable.lower()
- =09
- elif cons_type =3D=3D 'P':
- pkmap[col_name]=3DTrue
- =09
- if len(pkmap) =3D=3D 0: raise PrimaryKeyNotFounded, tableName
- =09
- for field, nullAllowed, default, data_type, data_len, data_scale in co=
lData:
- #id is defined as primary key --> ok
- #We let sqlobject raise error if the 'id' is used for another column
- field_name =3D field.lower()=20
- if field_name =3D=3D 'id' and pkmap[field_name]:
- continue
- =09
- colClass, kw =3D self.guessClass(data_type,data_len,data_scale)
- kw['name'] =3D field_name
- =09
- if nullAllowed =3D=3D 'Y' :=20
- nullAllowed=3DFalse
- else:
- nullAllowed=3DTrue
- =09
- kw['notNone'] =3D nullAllowed
- if default is not None:
- kw['default'] =3D default
- =09
- if keymap.has_key(field_name):
- kw['foreignKey'] =3D keymap[field_name]
- =09
- results.append(colClass(**kw))
- =20
- return results
- =20
- _numericTypes=3D['INTEGER', 'INT','SMALLINT']
- _dateTypes=3D['DATE','TIME','TIMESTAMP']
-=09
- def guessClass(self, t, flength, fscale=3DNone):
- """
- An internal method that tries to figure out what Col subclass
- is appropriate given whatever introspective information is
- available -- both very database-specific.
- """
- if t in self._numericTypes:
- return col.IntCol, {}
- # The type returned by the sapdb library for LONG is SapDB_LongReader
- #To get the data call the read member with desired size (default =3D-1=
means get all)
- =09
- elif t.find('LONG') !=3D -1:
- return col.StringCol, {'length': flength,
- 'varchar': False}
- elif t in self._dateTypes:
- return col.DateTimeCol, {}
- elif t =3D=3D 'FIXED':
- return CurrencyCol,{'size':flength,
- 'precision':fscale}
- else:
- return col.Col, {}
+ def sqlAddLimit(self,query,limit):
+ sql =3D query
+ sql =3D sql.replace("SELECT","SELECT ROWNO, ")
+ if sql.find('WHERE') !=3D -1:
+ sql =3D sql + ' AND ' + limit
+ else:
+ sql =3D sql + 'WHERE ' + limit
+ return sql
+
+ def _queryAddLimitOffset(self, query, start, end):
+ if start:
+ raise LowerBoundOfSliceIsNotSupported
+ limit =3D ' ROWNO <=3D %d ' % (end)
+ return self.sqlAddLimit(query,limit)
+
+ =20
+ def createTable(self, soClass):
+ #we create the table in a transaction because the addition of th=
e
+ #table and the sequence must be atomic=20
+
+ #i tried to use the transaction class but i get a recursion limi=
t error =20
+ #t=3Dself.transaction()
+ # t.query('CREATE TABLE %s (\n%s\n)' % \
+ # (soClass._table, self.createColumns(soClass)))
+ #=20
+ # t.query("CREATE SEQUENCE %s" % self.createSequenceName(soClass=
._table))
+ # t.commit()
+ #so use transaction when the problem will be solved
+ self.query('CREATE TABLE %s (\n%s\n)' % \
+ (soClass._table, self.createColumns(soClass)))
+ self.query("CREATE SEQUENCE %s"
+ % self.createSequenceName(soClass._table))
+=20
+ def createColumn(self, soClass, col):
+ return col.maxdbCreateSQL()
+
+ def createIDColumn(self, soClass):
+ return '%s INT PRIMARY KEY' % soClass._idName
+
+ def dropTable(self, tableName,cascade=3DFalse):
+ #we drop the table in a transaction because the removal of the
+ #table and the sequence must be atomic=20
+ #i tried to use the transaction class but i get a recursion limi=
t error
+ # try:
+ # t=3Dself.transaction()
+ # t.query("DROP TABLE %s" % tableName)
+ # t.query("DROP SEQUENCE %s" % self.createSequenceName(table=
Name))
+ # t.commit()
+ # except:
+ # t.rollback()
+ #so use transaction when the problem will be solved
+ self.query("DROP TABLE %s" % tableName)
+ self.query("DROP SEQUENCE %s" % self.createSequenceName(tableNam=
e))
+
+ def joinSQLType(self, join):
+ return 'INT NOT NULL'
+
+ def tableExists(self, tableName):
+ for (table,) in self.queryAll("SELECT OBJECT_NAME FROM ALL_OBJEC=
TS WHERE OBJECT_TYPE=3D'TABLE'"):
+ if table.lower() =3D=3D tableName.lower():
+ return True
+ return False
+
+ def addColumn(self, tableName, column):
+ self.query('ALTER TABLE %s ADD %s' %
+ (tableName,
+ column.maxdbCreateSQL()))
+
+ def delColumn(self, tableName, column):
+ self.query('ALTER TABLE %s DROP COLUMN %s' %
+ (tableName,
+ column.dbName))
+
+ GET_COLUMNS =3D """
+ SELECT COLUMN_NAME, NULLABLE, DATA_DEFAULT, DATA_TYPE,
+ DATA_LENGTH, DATA_SCALE
+ FROM USER_TAB_COLUMNS WHERE TABLE_NAME=3DUPPER('%s')"""
+
+ GET_PK_AND_FK =3D """
+ SELECT constraint_cols.column_name, constraints.constraint_type,
+ refname,reftablename
+ FROM user_cons_columns constraint_cols=20
+ INNER JOIN user_constraints constraints
+ ON constraint_cols.constraint_name =3D constraints.constraint_name
+ LEFT OUTER JOIN show_foreign_key fk
+ ON constraint_cols.column_name =3D fk.columnname
+ WHERE constraints.table_name =3DUPPER('%s')"""
+
+ def columnsFromSchema(self, tableName, soClass):
+ colData =3D self.queryAll(self.GET_COLUMNS
+ % tableName)
+
+ results =3D []
+ keymap =3D {}
+ pkmap=3D{}
+ fkData =3D self.queryAll(self.GET_PK_AND_FK% tableName)
+ for col, cons_type, refcol, reftable in fkData:
+ col_name=3D col.lower()
+ pkmap[col_name]=3DFalse
+ if cons_type =3D=3D 'R':
+ keymap[col_name]=3Dreftable.lower()
+ =20
+ elif cons_type =3D=3D 'P':
+ pkmap[col_name]=3DTrue
+
+ if len(pkmap) =3D=3D 0:
+ raise PrimaryKeyNotFounded, tableName
+
+ for (field, nullAllowed, default, data_type, data_len,
+ data_scale) in colData:
+ # id is defined as primary key --> ok
+ # We let sqlobject raise error if the 'id' is used for anoth=
er column
+ field_name =3D field.lower()=20
+ if field_name =3D=3D 'id' and pkmap[field_name]:
+ continue
+ =20
+ colClass, kw =3D self.guessClass(data_type,data_len,data_sca=
le)
+ kw['name'] =3D field_name
+
+ if nullAllowed =3D=3D 'Y' :=20
+ nullAllowed=3DFalse
+ else:
+ nullAllowed=3DTrue
+
+ kw['notNone'] =3D nullAllowed
+ if default is not None:
+ kw['default'] =3D default
+
+ if keymap.has_key(field_name):
+ kw['foreignKey'] =3D keymap[field_name]
+
+ results.append(colClass(**kw))
+ =20
+ return results
+ =20
+ _numericTypes=3D['INTEGER', 'INT','SMALLINT']
+ _dateTypes=3D['DATE','TIME','TIMESTAMP']
+
+ def guessClass(self, t, flength, fscale=3DNone):
+ """
+ An internal method that tries to figure out what Col subclass
+ is appropriate given whatever introspective information is
+ available -- both very database-specific.
+ """
+ if t in self._numericTypes:
+ return col.IntCol, {}
+ # The type returned by the sapdb library for LONG is
+ # SapDB_LongReader To get the data call the read member with
+ # desired size (default =3D-1 means get all)
+
+ elif t.find('LONG') !=3D -1:
+ return col.StringCol, {'length': flength,
+ 'varchar': False}
+ elif t in self._dateTypes:
+ return col.DateTimeCol, {}
+ elif t =3D=3D 'FIXED':
+ return CurrencyCol,{'size':flength,
+ 'precision':fscale}
+ else:
+ return col.Col, {}
|
|
From: <sub...@co...> - 2004-08-18 02:50:01
|
Author: ianb
Date: 2004-08-17 18:41:14 -0400 (Tue, 17 Aug 2004)
New Revision: 183
Modified:
trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py
Log:
Oops, didn't need that test for :memory:
Modified: trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py 2004-08-17 22:40=
:05 UTC (rev 182)
+++ trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py 2004-08-17 22:41=
:14 UTC (rev 183)
@@ -24,8 +24,6 @@
user, password, host, path, args =3D cls._parseURI(uri)
assert host is None, "SQLite can only be used locally (with a UR=
I like sqlite:///file or sql:/file, not %r)" % uri
assert user is None and password is None, "You may not provide u=
sernames or passwords for SQLite databases"
- if path !=3D ':memory:':
- path =3D '/' + path
return cls(filename=3Dpath, **args)
connectionFromURI =3D classmethod(connectionFromURI)
=20
|
|
From: <sub...@co...> - 2004-08-18 02:48:47
|
Author: ianb
Date: 2004-08-17 18:40:05 -0400 (Tue, 17 Aug 2004)
New Revision: 182
Modified:
trunk/SQLObject/docs/News.txt
trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py
Log:
Allow sqlite:/:memory:
Modified: trunk/SQLObject/docs/News.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/docs/News.txt 2004-08-17 22:37:17 UTC (rev 181)
+++ trunk/SQLObject/docs/News.txt 2004-08-17 22:40:05 UTC (rev 182)
@@ -61,6 +61,9 @@
=20
* SQLite booleans fixed.
=20
+* You can now use ``sqlite:/:memory:`` to store the database in
+ memory.
+
SQLObject 0.5.3
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=20
Modified: trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py 2004-08-17 22:37=
:17 UTC (rev 181)
+++ trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py 2004-08-17 22:40=
:05 UTC (rev 182)
@@ -24,7 +24,9 @@
user, password, host, path, args =3D cls._parseURI(uri)
assert host is None, "SQLite can only be used locally (with a UR=
I like sqlite:///file or sql:/file, not %r)" % uri
assert user is None and password is None, "You may not provide u=
sernames or passwords for SQLite databases"
- return cls(filename=3D'/' + path, **args)
+ if path !=3D ':memory:':
+ path =3D '/' + path
+ return cls(filename=3Dpath, **args)
connectionFromURI =3D classmethod(connectionFromURI)
=20
def _setAutoCommit(self, conn, auto):
|
|
From: <sub...@co...> - 2004-08-18 02:46:01
|
Author: ianb Date: 2004-08-17 18:37:17 -0400 (Tue, 17 Aug 2004) New Revision: 181 Modified: trunk/SQLObject/docs/News.txt Log: Added note about _idType Modified: trunk/SQLObject/docs/News.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/docs/News.txt 2004-08-17 22:34:50 UTC (rev 180) +++ trunk/SQLObject/docs/News.txt 2004-08-17 22:37:17 UTC (rev 181) @@ -51,6 +51,11 @@ * New ``_create(id, **kw)`` method that can be overridden to intercept and modify attempts to insert rows in the database. =20 +* You can specify ``_idType`` in your class, like ``_idType =3D str``. + The default type is ``int``; i.e., IDs are coerced to integers. + This is a temporary interface; a more general specifier for primary + keys will be added later. + Bugs ---- =20 |
|
From: <sub...@co...> - 2004-08-18 02:43:35
|
Author: ianb
Date: 2004-08-17 18:34:50 -0400 (Tue, 17 Aug 2004)
New Revision: 180
Added:
trunk/SQLObject/docs/TODO.txt
Modified:
trunk/SQLObject/tests/test.py
Log:
Started TODO.txt; tested abnormal ID names with _fromDatabase
Added: trunk/SQLObject/docs/TODO.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/docs/TODO.txt 2004-08-17 22:31:28 UTC (rev 179)
+++ trunk/SQLObject/docs/TODO.txt 2004-08-17 22:34:50 UTC (rev 180)
@@ -0,0 +1,10 @@
+TODO
+----
+
+See also some `long-term ideas`__.
+
+.. __: Plan06.html
+
+* ``_fromDatabase`` currently doesn't support IDs that don't fit into
+ the normal naming scheme. It should do so. You can still use
+ ``_idName`` with ``_fromDatabase``.
Modified: trunk/SQLObject/tests/test.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/tests/test.py 2004-08-17 22:31:28 UTC (rev 179)
+++ trunk/SQLObject/tests/test.py 2004-08-17 22:34:50 UTC (rev 180)
@@ -604,7 +604,7 @@
=20
mysqlCreate =3D """
CREATE TABLE IF NOT EXISTS auto_test (
- id INT AUTO_INCREMENT PRIMARY KEY,
+ auto_id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(100),
last_name VARCHAR(200) NOT NULL,
age INT DEFAULT NULL,
@@ -616,7 +616,7 @@
=20
postgresCreate =3D """
CREATE TABLE auto_test (
- id SERIAL,
+ auto_id SERIAL,
first_name VARCHAR(100),
last_name VARCHAR(200) NOT NULL,
age INT DEFAULT 0,
@@ -628,7 +628,7 @@
=20
sybaseCreate =3D """
CREATE TABLE auto_test (
- id integer,
+ auto_id integer,
first_name VARCHAR(100),
last_name VARCHAR(200) NOT NULL,
age INT DEFAULT 0,
@@ -656,6 +656,7 @@
return
class AutoTest(SQLObject):
_fromDatabase =3D True
+ _idName =3D 'auto_id'
_connection =3D connection()
john =3D AutoTest(firstName=3D'john',
lastName=3D'doe',
|
|
From: <sub...@co...> - 2004-08-18 02:40:14
|
Author: ianb
Date: 2004-08-17 18:31:28 -0400 (Tue, 17 Aug 2004)
New Revision: 179
Modified:
trunk/SQLObject/sqlobject/main.py
Log:
Updated fromDatabase for changes in col.py
Modified: trunk/SQLObject/sqlobject/main.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/SQLObject/sqlobject/main.py 2004-08-17 20:43:23 UTC (rev 178)
+++ trunk/SQLObject/sqlobject/main.py 2004-08-17 22:31:28 UTC (rev 179)
@@ -473,7 +473,7 @@
for columnDef in cls._connection.columnsFromSchema(cls._table, c=
ls):
alreadyExists =3D False
for c in cls._columns:
- if c.kw['name'] =3D=3D columnDef.kw['name']:
+ if c.name =3D=3D columnDef.name:
alreadyExists =3D True
break
if not alreadyExists:
|
|
From: <sub...@co...> - 2004-08-18 00:44:32
|
Author: ianb Date: 2004-08-17 16:35:43 -0400 (Tue, 17 Aug 2004) New Revision: 175 Modified: trunk/SQLObject/docs/News.txt Log: Note cascade keyword argument addition Modified: trunk/SQLObject/docs/News.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/docs/News.txt 2004-08-17 20:31:15 UTC (rev 174) +++ trunk/SQLObject/docs/News.txt 2004-08-17 20:35:43 UTC (rev 175) @@ -37,9 +37,17 @@ * We're now using a Subversion repository instead of CVS. It is located at svn://colorstudy.com/trunk/SQLObject=20 =20 -* If you pass ``forceDBName=3DTrue`` to the `*Col` constructors, then +* If you pass ``forceDBName=3DTrue`` to the ``*Col`` constructors, then your column name doesn't have to be restricted to a-z, 0-9, and _. =20 +* ``*Col`` constructors now support cascade: ``cascade=3DNone`` + (default) means no constraint; ``cascade=3DTrue`` means that if the + foreign key is deleted, the object will be deleted; + ``cascade=3DFalse`` means that the delete will fail. ``SET NULL`` is + not implemented, and the constraints are only implemented in the + DBMS, not in SQLObject (i.e., they will not work in databases like + MySQL and SQLite). + Bugs ---- =20 |