sqlobject-cvs Mailing List for SQLObject (Page 102)
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...> - 2007-03-02 14:43:26
|
Author: phd
Date: 2007-03-02 07:43:22 -0700 (Fri, 02 Mar 2007)
New Revision: 2366
Modified:
SQLObject/docs/News.txt
SQLObject/docs/SQLObject.txt
Log:
New column SetCol to support MySQL SET type.
Modified: SQLObject/docs/News.txt
===================================================================
--- SQLObject/docs/News.txt 2007-03-02 14:40:52 UTC (rev 2365)
+++ SQLObject/docs/News.txt 2007-03-02 14:43:22 UTC (rev 2366)
@@ -43,6 +43,8 @@
* New column TimestampCol to support MySQL TIMESTAMP type.
+* New column SetCol to support MySQL SET type.
+
Small Features
--------------
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2007-03-02 14:40:52 UTC (rev 2365)
+++ SQLObject/docs/SQLObject.txt 2007-03-02 14:43:22 UTC (rev 2366)
@@ -1110,6 +1110,9 @@
http://archives.postgresql.org/pgsql-sql/2004-12/msg00065.php for
more details).
+`SetCol`:
+ Supports MySQL SET type.
+
`FloatCol`:
Floats.
@@ -1719,6 +1722,7 @@
* `KeyCol`
* `ForeignKey`
* `EnumCol`
+* `SetCol`
* `DateTimeCol`
* `DateCol`
* `TimeCol`
|
|
From: SourceForge.net <no...@so...> - 2007-03-02 14:41:20
|
Patches item #1450581, was opened at 2006-03-15 21:08 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1450581&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: No support for MySQL SET type Initial Comment: I am not certain whether or not the other databases other than MySQL have a SET type, but it does provide the ability to choose multiple values from your standard ENUM-like choices. The patch adds a SetCol object with a setValues keyword, used to specify the values in the form of a tuple. Values are converted to the comma-delimited SQL string for SQL queries, and the return values are converted back into a tuple. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-03-02 17:41 Message: Logged In: YES user_id=4799 Originator: NO Applied in the revision 2365. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-03-21 13:00 Message: Logged In: YES user_id=4799 Please add documentation and tests. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1450581&group_id=74338 |
|
From: <sub...@co...> - 2007-03-02 14:40:57
|
Author: phd
Date: 2007-03-02 07:40:52 -0700 (Fri, 02 Mar 2007)
New Revision: 2365
Modified:
SQLObject/trunk/sqlobject/col.py
Log:
Applied the patch 1450581: support for MySQL SET type.
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2007-03-02 14:35:15 UTC (rev 2364)
+++ SQLObject/trunk/sqlobject/col.py 2007-03-02 14:40:52 UTC (rev 2365)
@@ -958,6 +958,43 @@
baseClass = SOEnumCol
+class SetValidator(validators.Validator):
+ """
+ Translates Python tuples into SQL comma-delimited SET strings.
+ """
+
+ def to_python(self, value, state):
+ if not isinstance(value, str):
+ raise validators.Invalid("expected a value string, got % instead" % \
+ (value), value, state)
+ return tuple(value.split(","))
+
+ def from_python(self, value, state):
+ if not isinstance(value, tuple):
+ value = (value,)
+ return ",".join([v for v in value])
+
+class SOSetCol(SOCol):
+ def __init__(self, **kw):
+ self.setValues = popKey(kw, 'setValues', None)
+ assert self.setValues is not None, \
+ 'You must provide a setValues keyword argument'
+ super(SOSetCol, self).__init__(**kw)
+
+ def autoConstraints(self):
+ return [consts.isString, consts.InList(self.setValues)]
+
+ def createValidators(self):
+ return [SetValidator(name = self.name, setValues = self.setValues)] + \
+ super(SOSetCol, self).createValidators()
+
+ def _mysqlType(self):
+ return "SET(%s)" % ', '.join([sqlbuilder.sqlrepr(v, 'mysql') for v in self.enumValues])
+
+class SetCol(Col):
+ baseClass = SOSetCol
+
+
if datetime_available:
class DateTimeValidator(validators.DateValidator):
def to_python(self, value, state):
@@ -1387,6 +1424,7 @@
class PickleCol(BLOBCol):
baseClass = SOPickleCol
+
def popKey(kw, name, default=None):
if not kw.has_key(name):
return default
|
|
From: <sub...@co...> - 2007-03-02 14:35:18
|
Author: phd Date: 2007-03-02 07:35:15 -0700 (Fri, 02 Mar 2007) New Revision: 2364 Modified: SQLObject/docs/News.txt Log: Support for MySQL INT type attributes: UNSIGNED, ZEROFILL. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-03-02 14:34:18 UTC (rev 2363) +++ SQLObject/docs/News.txt 2007-03-02 14:35:15 UTC (rev 2364) @@ -46,6 +46,8 @@ Small Features -------------- +* Support for MySQL INT type attributes: UNSIGNED, ZEROFILL. + Bug Fixes --------- |
|
From: SourceForge.net <no...@so...> - 2007-03-02 14:34:54
|
Patches item #1450576, was opened at 2006-03-15 21:03 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1450576&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: No support for INT type attributes: UNSIGNED, etc. Initial Comment: Patch attached to add keyword support for UNSIGNED, ZEROFILL, and length specifiers for the IntCol class. Most of these functions can be done with checks and formatting from the python side, but I feel they should be declared in the underlying DB structure as well. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-03-02 17:34 Message: Logged In: YES user_id=4799 Originator: NO Applied in the revision 2363. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-03-21 12:58 Message: Logged In: YES user_id=4799 Please add documentation and tests. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1450576&group_id=74338 |
|
From: <sub...@co...> - 2007-03-02 14:34:25
|
Author: phd
Date: 2007-03-02 07:34:18 -0700 (Fri, 02 Mar 2007)
New Revision: 2363
Modified:
SQLObject/trunk/sqlobject/col.py
Log:
Applied the patch 1450576: support for MySQL INT type attributes: UNSIGNED, ZEROFILL.
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2007-03-02 14:28:10 UTC (rev 2362)
+++ SQLObject/trunk/sqlobject/col.py 2007-03-02 14:34:18 UTC (rev 2363)
@@ -594,6 +594,11 @@
class SOIntCol(SOCol):
# 3-03 @@: support precision, maybe max and min directly
+ def __init__(self, **kw):
+ self.length = popKey(kw, 'length')
+ self.unsigned = bool(popKey(kw, 'unsigned'))
+ self.zerofill = bool(popKey(kw, 'unsigned'))
+ SOCol.__init__(self, **kw)
def autoConstraints(self):
return [consts.isInt]
@@ -602,8 +607,21 @@
return [IntValidator(name=self.name)] + \
super(SOIntCol, self).createValidators()
+ def addSQLAttrs(self, str):
+ _ret = str
+ if str is None or len(str) < 1:
+ return None
+
+ if self.length >= 1:
+ _ret = "%s(%d)" % (_ret, self.length)
+ if self.unsigned:
+ _ret = _ret + " UNSIGNED"
+ if self.zerofill:
+ _ret = _reg + " ZEROFILL"
+ return _ret
+
def _sqlType(self):
- return 'INT'
+ return self.addSQLAttrs("INT")
class IntCol(Col):
baseClass = SOIntCol
|
|
From: <sub...@co...> - 2007-03-02 14:28:13
|
Author: phd
Date: 2007-03-02 07:28:10 -0700 (Fri, 02 Mar 2007)
New Revision: 2362
Modified:
SQLObject/docs/News.txt
SQLObject/docs/SQLObject.txt
Log:
New column TimestampCol to support MySQL TIMESTAMP type.
Modified: SQLObject/docs/News.txt
===================================================================
--- SQLObject/docs/News.txt 2007-03-02 14:24:15 UTC (rev 2361)
+++ SQLObject/docs/News.txt 2007-03-02 14:28:10 UTC (rev 2362)
@@ -41,6 +41,8 @@
* Use logging if it's available and is configured via DB URI.
+* New column TimestampCol to support MySQL TIMESTAMP type.
+
Small Features
--------------
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2007-03-02 14:24:15 UTC (rev 2361)
+++ SQLObject/docs/SQLObject.txt 2007-03-02 14:28:10 UTC (rev 2362)
@@ -1084,6 +1084,9 @@
`TimeCol`:
A time (usually returned as an datetime or mxDateTime object).
+`TimestampCol`:
+ Supports MySQL TIMESTAMP type.
+
`DecimalCol`:
Base-10, precise number. Uses the keyword arguments `size` for
number of digits stored, and `precision` for the number of digits
@@ -1719,6 +1722,7 @@
* `DateTimeCol`
* `DateCol`
* `TimeCol`
+* `TimestampCol`
* `DecimalCol`
* `CurrencyCol`
|
|
From: SourceForge.net <no...@so...> - 2007-03-02 14:25:21
|
Patches item #1450570, was opened at 2006-03-15 20:59 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1450570&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: No support for MySQL TIMESTAMP type Initial Comment: SQLObject does support a DatetimeCol for MySQL, but does not have support for the TIMESTAMP column type. Databases will usually support either one or the other (or neither and a CHECK type), but MySQL uses both DATETIME and TIMESTAMP and they each perform a different role. For example, if you want to record the time a row was initially created: CREATE TABLE test ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, value INT, time_added TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); The CURRENT_TIMESTAMP and NOW() functions are not supported with the DATETIME column. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-03-02 17:25 Message: Logged In: YES user_id=4799 Originator: NO Applied in the revision 2361. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-03-21 12:57 Message: Logged In: YES user_id=4799 Please add documentation and tests. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1450570&group_id=74338 |
|
From: <sub...@co...> - 2007-03-02 14:24:24
|
Author: phd
Date: 2007-03-02 07:24:15 -0700 (Fri, 02 Mar 2007)
New Revision: 2361
Modified:
SQLObject/trunk/sqlobject/col.py
SQLObject/trunk/sqlobject/mysql/mysqlconnection.py
Log:
Applied the patch 1450570: support for MySQL TIMESTAMP type.
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2007-02-28 16:44:42 UTC (rev 2360)
+++ SQLObject/trunk/sqlobject/col.py 2007-03-02 14:24:15 UTC (rev 2361)
@@ -1063,7 +1063,6 @@
% DATETIME_IMPLEMENTATION)
now = staticmethod(now)
-
if datetime_available:
class DateValidator(DateTimeValidator):
def to_python(self, value, state):
@@ -1180,6 +1179,21 @@
baseClass = SOTimeCol
+class SOTimestampCol(SODateTimeCol):
+ """
+ Necessary to support MySQL's use of TIMESTAMP versus DATETIME types
+ """
+
+ def __init__(self, **kw):
+ SOCol.__init__(self, **kw)
+
+ def _mysqlType(self):
+ return 'TIMESTAMP'
+
+class TimestampCol(Col):
+ baseClass = SOTimestampCol
+
+
try:
from decimal import Decimal
except ImportError:
Modified: SQLObject/trunk/sqlobject/mysql/mysqlconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2007-02-28 16:44:42 UTC (rev 2360)
+++ SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2007-03-02 14:24:15 UTC (rev 2361)
@@ -236,6 +236,10 @@
'varchar': False}
elif t.startswith('datetime'):
return col.DateTimeCol, {}
+ elif t.startswith('date'):
+ return col.DateCol, {}
+ elif t.startswith('timestamp'):
+ return col.TimestampCol, {}
elif t.startswith('bool'):
return col.BoolCol, {}
elif t.startswith('tinyblob'):
|
|
From: SourceForge.net <no...@so...> - 2007-02-28 16:45:36
|
Patches item #1671023, was opened at 2007-02-28 19:17 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1671023&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) >Assigned to: Oleg Broytmann (phd) Summary: ForeignKey referential integrity documentation Initial Comment: A patch against svn r2352 to include some referential integrity documentation. Please review orthography and grammar since my english is not that good =) ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-02-28 19:45 Message: Logged In: YES user_id=4799 Originator: NO Applied and committed in the branches 0.7, 0.8 and to the trunk in the revisions 2358-2360. Thank you! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1671023&group_id=74338 |
|
From: <sub...@co...> - 2007-02-28 16:45:21
|
Author: phd
Date: 2007-02-28 09:44:42 -0700 (Wed, 28 Feb 2007)
New Revision: 2360
Modified:
SQLObject/docs/SQLObject.txt
Log:
Applied patch 1671023: ForeignKey referential integrity documentation.
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2007-02-28 16:44:23 UTC (rev 2359)
+++ SQLObject/docs/SQLObject.txt 2007-02-28 16:44:42 UTC (rev 2360)
@@ -1111,7 +1111,9 @@
Floats.
`ForeignKey`:
- A key to another table/class. Use like ``user = ForeignKey('User')``.
+ A key to another table/class. Use like ``user = ForeignKey('User')``. It
+ can check for referential integrity using the keyword argument `cascade`,
+ please see ForeignKey_ for details.
`IntCol`:
Integers.
@@ -1165,10 +1167,43 @@
Relationships Between Classes/Tables
------------------------------------
+ForeignKey
+~~~~~~~~~~
+
You can use the `ForeignKey` to handle foreign references in a table,
but for back references and many-to-many relationships you'll use
joins.
+`ForeignKey` allows you to specify referential integrity using the keyword
+`cascade`, which can have these values:
+
+`None`:
+ No action is taken on related deleted columns (this is the default).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be kept
+ untouched (with ``perdonID=1``).
+`False`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will fail (sets ``ON DELETE RESTRICT``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe) a `SQLObjectIntegrityError` exception will be raised,
+ because the `Address` with id 1 (123 W Main St) has a reference
+ (``personID=1``) to it.
+`True`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will delete all the related objects too (sets ``ON DELETE
+ CASCADE``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be deleted too.
+`'null'`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will set the `ForeignKey` column to `NULL`/`None` (sets
+ ``ON DELETE SET NULL``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be kept but
+ the reference to person will be set to `NULL`/`None` (``perdonID=None``).
+
+
MultipleJoin and SQLMultipleJoin: One-to-Many
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
From: <sub...@co...> - 2007-02-28 16:45:06
|
Author: phd
Date: 2007-02-28 09:44:23 -0700 (Wed, 28 Feb 2007)
New Revision: 2359
Modified:
SQLObject/branches/0.8/docs/SQLObject.txt
Log:
Applied patch 1671023: ForeignKey referential integrity documentation.
Modified: SQLObject/branches/0.8/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.8/docs/SQLObject.txt 2007-02-28 16:43:55 UTC (rev 2358)
+++ SQLObject/branches/0.8/docs/SQLObject.txt 2007-02-28 16:44:23 UTC (rev 2359)
@@ -1110,7 +1110,9 @@
Floats.
`ForeignKey`:
- A key to another table/class. Use like ``user = ForeignKey('User')``.
+ A key to another table/class. Use like ``user = ForeignKey('User')``. It
+ can check for referential integrity using the keyword argument `cascade`,
+ please see ForeignKey_ for details.
`IntCol`:
Integers.
@@ -1164,10 +1166,43 @@
Relationships Between Classes/Tables
------------------------------------
+ForeignKey
+~~~~~~~~~~
+
You can use the `ForeignKey` to handle foreign references in a table,
but for back references and many-to-many relationships you'll use
joins.
+`ForeignKey` allows you to specify referential integrity using the keyword
+`cascade`, which can have these values:
+
+`None`:
+ No action is taken on related deleted columns (this is the default).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be kept
+ untouched (with ``perdonID=1``).
+`False`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will fail (sets ``ON DELETE RESTRICT``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe) a `SQLObjectIntegrityError` exception will be raised,
+ because the `Address` with id 1 (123 W Main St) has a reference
+ (``personID=1``) to it.
+`True`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will delete all the related objects too (sets ``ON DELETE
+ CASCADE``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be deleted too.
+`'null'`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will set the `ForeignKey` column to `NULL`/`None` (sets
+ ``ON DELETE SET NULL``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be kept but
+ the reference to person will be set to `NULL`/`None` (``perdonID=None``).
+
+
MultipleJoin and SQLMultipleJoin: One-to-Many
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
From: <sub...@co...> - 2007-02-28 16:44:14
|
Author: phd
Date: 2007-02-28 09:43:55 -0700 (Wed, 28 Feb 2007)
New Revision: 2358
Modified:
SQLObject/branches/0.7/docs/SQLObject.txt
Log:
Applied patch 1671023: ForeignKey referential integrity documentation.
Modified: SQLObject/branches/0.7/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.7/docs/SQLObject.txt 2007-02-28 15:32:29 UTC (rev 2357)
+++ SQLObject/branches/0.7/docs/SQLObject.txt 2007-02-28 16:43:55 UTC (rev 2358)
@@ -1109,7 +1109,9 @@
Floats.
`ForeignKey`:
- A key to another table/class. Use like ``user = ForeignKey('User')``.
+ A key to another table/class. Use like ``user = ForeignKey('User')``. It
+ can check for referential integrity using the keyword argument `cascade`,
+ please see ForeignKey_ for details.
`IntCol`:
Integers.
@@ -1163,10 +1165,43 @@
Relationships Between Classes/Tables
------------------------------------
+ForeignKey
+~~~~~~~~~~
+
You can use the `ForeignKey` to handle foreign references in a table,
but for back references and many-to-many relationships you'll use
joins.
+`ForeignKey` allows you to specify referential integrity using the keyword
+`cascade`, which can have these values:
+
+`None`:
+ No action is taken on related deleted columns (this is the default).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be kept
+ untouched (with ``perdonID=1``).
+`False`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will fail (sets ``ON DELETE RESTRICT``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe) a `SQLObjectIntegrityError` exception will be raised,
+ because the `Address` with id 1 (123 W Main St) has a reference
+ (``personID=1``) to it.
+`True`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will delete all the related objects too (sets ``ON DELETE
+ CASCADE``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be deleted too.
+`'null'`:
+ Deletion of an object that has other objects related to it using a
+ `ForeignKey` will set the `ForeignKey` column to `NULL`/`None` (sets
+ ``ON DELETE SET NULL``).
+ Following the Person/Address example, if you delete the object `Person` with
+ id 1 (Jonh Doe), the `Address` with id 1 (123 W Main St) will be kept but
+ the reference to person will be set to `NULL`/`None` (``perdonID=None``).
+
+
MultipleJoin and SQLMultipleJoin: One-to-Many
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
From: SourceForge.net <no...@so...> - 2007-02-28 16:17:57
|
Patches item #1671023, was opened at 2007-02-28 13:17 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1671023&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) Assigned to: Nobody/Anonymous (nobody) Summary: ForeignKey referential integrity documentation Initial Comment: A patch against svn r2352 to include some referential integrity documentation. Please review orthography and grammar since my english is not that good =) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1671023&group_id=74338 |
|
From: <sub...@co...> - 2007-02-28 15:32:35
|
Author: phd
Date: 2007-02-28 08:32:29 -0700 (Wed, 28 Feb 2007)
New Revision: 2357
Modified:
home/phd/SQLObject/paramstyles/sqlobject/manager/command.py
Log:
Merged patches from the revisions 2352:2356 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/manager/command.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/manager/command.py 2007-02-28 15:27:46 UTC (rev 2356)
+++ home/phd/SQLObject/paramstyles/sqlobject/manager/command.py 2007-02-28 15:32:29 UTC (rev 2357)
@@ -16,6 +16,7 @@
from sqlobject import col
from sqlobject.util import moduleloader
from sqlobject.declarative import DeclarativeMeta
+from sqlobject.classregistry import findClass
# It's not very unsafe to use tempnam like we are doing:
warnings.filterwarnings(
@@ -181,6 +182,81 @@
help = ''
+ def orderClassesByDependencyLevel(self, classes):
+ """
+ Return classes ordered by their depth in the class dependency
+ tree (this is *not* the inheritance tree), from the
+ top level (independant) classes to the deepest level.
+ The dependency tree is defined by the foreign key relations.
+ """
+ # @@: written as a self-contained function for now, to prevent
+ # having to modify any core SQLObject component and namespace
+ # contamination.
+ # yemartin - 2006-08-08
+
+ class SQLObjectCircularReferenceError(Exception): pass
+
+ def findReverseDependencies(cls):
+ """
+ Return a list of classes that cls depends on. Note that
+ "depends on" here mean "has a foreign key pointing to".
+ """
+ depended = []
+ for col in cls.sqlmeta.columnList:
+ if col.foreignKey:
+ other = findClass(col.foreignKey,
+ col.soClass.sqlmeta.registry)
+ if other not in depended:
+ depended.append(other)
+ return depended
+
+ # Cache to save already calculated dependency levels.
+ dependency_levels = {}
+ def calculateDependencyLevel(cls, dependency_stack=[]):
+ """
+ Recursively calculate the dependency level of cls, while
+ using the dependency_stack to detect any circular reference.
+ """
+ # Return value from the cache if already calculated
+ if dependency_levels.has_key(cls):
+ return dependency_levels[cls]
+ # Check for circular references
+ if cls in dependency_stack:
+ dependency_stack.append(cls)
+ raise SQLObjectCircularReferenceError, (
+ "Found a circular reference: %s " %
+ (' --> '.join([x.__name__
+ for x in dependency_stack])))
+ dependency_stack.append(cls)
+ # Recursively inspect dependent classes.
+ depended = findReverseDependencies(cls)
+ if depended:
+ level = max([calculateDependencyLevel(x, dependency_stack)
+ for x in depended]) + 1
+ else:
+ level = 0
+ dependency_levels[cls] = level
+ return level
+
+ # Now simply calculate and sort by dependency levels:
+ try:
+ sorter = []
+ for cls in classes:
+ level = calculateDependencyLevel(cls)
+ sorter.append((level, cls))
+ sorter.sort()
+ ordered_classes = [cls for level, cls in sorter]
+ except SQLObjectCircularReferenceError, msg:
+ # Failsafe: return the classes as-is if a circular reference
+ # prevented the dependency levels to be calculated.
+ print ("Warning: a circular reference was detected in the "
+ "model. Unable to sort the classes by dependency: they "
+ "will be treated in alphabetic order. This may or may "
+ "not work depending on your database backend. "
+ "The error was:\n%s" % msg)
+ return classes
+ return ordered_classes
+
def __classinit__(cls, new_args):
if cls.__bases__ == (object,):
# This abstract base class
@@ -285,7 +361,7 @@
else:
print 'No eggs specified'
sys.exit(1)
- return all
+ return self.orderClassesByDependencyLevel(all)
def classes_from_module(self, module):
all = []
@@ -613,7 +689,7 @@
v = self.options.verbose
dropped = 0
not_existing = 0
- for soClass in self.classes():
+ for soClass in self.classes().__reversed__():
exists = soClass._connection.tableExists(soClass.sqlmeta.table)
if v >= 1:
if exists:
|
|
From: <sub...@co...> - 2007-02-28 15:27:49
|
Author: phd Date: 2007-02-28 08:27:46 -0700 (Wed, 28 Feb 2007) New Revision: 2356 Modified: SQLObject/docs/News.txt Log: Another round of changes to create/drop the tables in the right order in the command-line client `sqlobject-admin`. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-02-28 15:27:23 UTC (rev 2355) +++ SQLObject/docs/News.txt 2007-02-28 15:27:46 UTC (rev 2356) @@ -157,6 +157,15 @@ * Fixed aggregators and accumulators with inheritance. +SQLObject 0.7.4 +=============== + +Bug Fixes +--------- + +* Another round of changes to create/drop the tables in the right order + in the command-line client `sqlobject-admin`. + SQLObject 0.7.3 =============== |
|
From: <sub...@co...> - 2007-02-28 15:27:25
|
Author: phd
Date: 2007-02-28 08:27:23 -0700 (Wed, 28 Feb 2007)
New Revision: 2355
Modified:
SQLObject/trunk/sqlobject/manager/command.py
Log:
Create/drop the tables in the order of dependency level.
Modified: SQLObject/trunk/sqlobject/manager/command.py
===================================================================
--- SQLObject/trunk/sqlobject/manager/command.py 2007-02-28 15:27:04 UTC (rev 2354)
+++ SQLObject/trunk/sqlobject/manager/command.py 2007-02-28 15:27:23 UTC (rev 2355)
@@ -16,6 +16,7 @@
from sqlobject import col
from sqlobject.util import moduleloader
from sqlobject.declarative import DeclarativeMeta
+from sqlobject.classregistry import findClass
# It's not very unsafe to use tempnam like we are doing:
warnings.filterwarnings(
@@ -181,6 +182,81 @@
help = ''
+ def orderClassesByDependencyLevel(self, classes):
+ """
+ Return classes ordered by their depth in the class dependency
+ tree (this is *not* the inheritance tree), from the
+ top level (independant) classes to the deepest level.
+ The dependency tree is defined by the foreign key relations.
+ """
+ # @@: written as a self-contained function for now, to prevent
+ # having to modify any core SQLObject component and namespace
+ # contamination.
+ # yemartin - 2006-08-08
+
+ class SQLObjectCircularReferenceError(Exception): pass
+
+ def findReverseDependencies(cls):
+ """
+ Return a list of classes that cls depends on. Note that
+ "depends on" here mean "has a foreign key pointing to".
+ """
+ depended = []
+ for col in cls.sqlmeta.columnList:
+ if col.foreignKey:
+ other = findClass(col.foreignKey,
+ col.soClass.sqlmeta.registry)
+ if other not in depended:
+ depended.append(other)
+ return depended
+
+ # Cache to save already calculated dependency levels.
+ dependency_levels = {}
+ def calculateDependencyLevel(cls, dependency_stack=[]):
+ """
+ Recursively calculate the dependency level of cls, while
+ using the dependency_stack to detect any circular reference.
+ """
+ # Return value from the cache if already calculated
+ if dependency_levels.has_key(cls):
+ return dependency_levels[cls]
+ # Check for circular references
+ if cls in dependency_stack:
+ dependency_stack.append(cls)
+ raise SQLObjectCircularReferenceError, (
+ "Found a circular reference: %s " %
+ (' --> '.join([x.__name__
+ for x in dependency_stack])))
+ dependency_stack.append(cls)
+ # Recursively inspect dependent classes.
+ depended = findReverseDependencies(cls)
+ if depended:
+ level = max([calculateDependencyLevel(x, dependency_stack)
+ for x in depended]) + 1
+ else:
+ level = 0
+ dependency_levels[cls] = level
+ return level
+
+ # Now simply calculate and sort by dependency levels:
+ try:
+ sorter = []
+ for cls in classes:
+ level = calculateDependencyLevel(cls)
+ sorter.append((level, cls))
+ sorter.sort()
+ ordered_classes = [cls for level, cls in sorter]
+ except SQLObjectCircularReferenceError, msg:
+ # Failsafe: return the classes as-is if a circular reference
+ # prevented the dependency levels to be calculated.
+ print ("Warning: a circular reference was detected in the "
+ "model. Unable to sort the classes by dependency: they "
+ "will be treated in alphabetic order. This may or may "
+ "not work depending on your database backend. "
+ "The error was:\n%s" % msg)
+ return classes
+ return ordered_classes
+
def __classinit__(cls, new_args):
if cls.__bases__ == (object,):
# This abstract base class
@@ -285,7 +361,7 @@
else:
print 'No eggs specified'
sys.exit(1)
- return all
+ return self.orderClassesByDependencyLevel(all)
def classes_from_module(self, module):
all = []
@@ -613,7 +689,7 @@
v = self.options.verbose
dropped = 0
not_existing = 0
- for soClass in self.classes():
+ for soClass in self.classes().__reversed__():
exists = soClass._connection.tableExists(soClass.sqlmeta.table)
if v >= 1:
if exists:
|
|
From: <sub...@co...> - 2007-02-28 15:27:12
|
Author: phd
Date: 2007-02-28 08:27:04 -0700 (Wed, 28 Feb 2007)
New Revision: 2354
Modified:
SQLObject/branches/0.8/docs/News.txt
SQLObject/branches/0.8/sqlobject/manager/command.py
Log:
Create/drop the tables in the order of dependency level.
Modified: SQLObject/branches/0.8/docs/News.txt
===================================================================
--- SQLObject/branches/0.8/docs/News.txt 2007-02-28 15:26:01 UTC (rev 2353)
+++ SQLObject/branches/0.8/docs/News.txt 2007-02-28 15:27:04 UTC (rev 2354)
@@ -115,6 +115,15 @@
* Fixed aggregators and accumulators with inheritance.
+SQLObject 0.7.4
+===============
+
+Bug Fixes
+---------
+
+* Another round of changes to create/drop the tables in the right order
+ in the command-line client `sqlobject-admin`.
+
SQLObject 0.7.3
===============
Modified: SQLObject/branches/0.8/sqlobject/manager/command.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/manager/command.py 2007-02-28 15:26:01 UTC (rev 2353)
+++ SQLObject/branches/0.8/sqlobject/manager/command.py 2007-02-28 15:27:04 UTC (rev 2354)
@@ -16,6 +16,7 @@
from sqlobject import col
from sqlobject.util import moduleloader
from sqlobject.declarative import DeclarativeMeta
+from sqlobject.classregistry import findClass
# It's not very unsafe to use tempnam like we are doing:
warnings.filterwarnings(
@@ -181,6 +182,81 @@
help = ''
+ def orderClassesByDependencyLevel(self, classes):
+ """
+ Return classes ordered by their depth in the class dependency
+ tree (this is *not* the inheritance tree), from the
+ top level (independant) classes to the deepest level.
+ The dependency tree is defined by the foreign key relations.
+ """
+ # @@: written as a self-contained function for now, to prevent
+ # having to modify any core SQLObject component and namespace
+ # contamination.
+ # yemartin - 2006-08-08
+
+ class SQLObjectCircularReferenceError(Exception): pass
+
+ def findReverseDependencies(cls):
+ """
+ Return a list of classes that cls depends on. Note that
+ "depends on" here mean "has a foreign key pointing to".
+ """
+ depended = []
+ for col in cls.sqlmeta.columnList:
+ if col.foreignKey:
+ other = findClass(col.foreignKey,
+ col.soClass.sqlmeta.registry)
+ if other not in depended:
+ depended.append(other)
+ return depended
+
+ # Cache to save already calculated dependency levels.
+ dependency_levels = {}
+ def calculateDependencyLevel(cls, dependency_stack=[]):
+ """
+ Recursively calculate the dependency level of cls, while
+ using the dependency_stack to detect any circular reference.
+ """
+ # Return value from the cache if already calculated
+ if dependency_levels.has_key(cls):
+ return dependency_levels[cls]
+ # Check for circular references
+ if cls in dependency_stack:
+ dependency_stack.append(cls)
+ raise SQLObjectCircularReferenceError, (
+ "Found a circular reference: %s " %
+ (' --> '.join([x.__name__
+ for x in dependency_stack])))
+ dependency_stack.append(cls)
+ # Recursively inspect dependent classes.
+ depended = findReverseDependencies(cls)
+ if depended:
+ level = max([calculateDependencyLevel(x, dependency_stack)
+ for x in depended]) + 1
+ else:
+ level = 0
+ dependency_levels[cls] = level
+ return level
+
+ # Now simply calculate and sort by dependency levels:
+ try:
+ sorter = []
+ for cls in classes:
+ level = calculateDependencyLevel(cls)
+ sorter.append((level, cls))
+ sorter.sort()
+ ordered_classes = [cls for level, cls in sorter]
+ except SQLObjectCircularReferenceError, msg:
+ # Failsafe: return the classes as-is if a circular reference
+ # prevented the dependency levels to be calculated.
+ print ("Warning: a circular reference was detected in the "
+ "model. Unable to sort the classes by dependency: they "
+ "will be treated in alphabetic order. This may or may "
+ "not work depending on your database backend. "
+ "The error was:\n%s" % msg)
+ return classes
+ return ordered_classes
+
def __classinit__(cls, new_args):
if cls.__bases__ == (object,):
# This abstract base class
@@ -285,7 +361,7 @@
else:
print 'No eggs specified'
sys.exit(1)
- return all
+ return self.orderClassesByDependencyLevel(all)
def classes_from_module(self, module):
all = []
@@ -613,7 +689,7 @@
v = self.options.verbose
dropped = 0
not_existing = 0
- for soClass in self.classes():
+ for soClass in self.classes().__reversed__():
exists = soClass._connection.tableExists(soClass.sqlmeta.table)
if v >= 1:
if exists:
|
|
From: <sub...@co...> - 2007-02-28 15:26:10
|
Author: phd
Date: 2007-02-28 08:26:01 -0700 (Wed, 28 Feb 2007)
New Revision: 2353
Modified:
SQLObject/branches/0.7/docs/News.txt
SQLObject/branches/0.7/sqlobject/manager/command.py
Log:
Create/drop the tables in the order of dependency level.
Modified: SQLObject/branches/0.7/docs/News.txt
===================================================================
--- SQLObject/branches/0.7/docs/News.txt 2007-02-26 17:30:42 UTC (rev 2352)
+++ SQLObject/branches/0.7/docs/News.txt 2007-02-28 15:26:01 UTC (rev 2353)
@@ -7,6 +7,15 @@
.. _start:
+SQLObject 0.7.4
+===============
+
+Bug Fixes
+---------
+
+* Another round of changes to create/drop the tables in the right order
+ in the command-line client `sqlobject-admin`.
+
SQLObject 0.7.3
===============
Modified: SQLObject/branches/0.7/sqlobject/manager/command.py
===================================================================
--- SQLObject/branches/0.7/sqlobject/manager/command.py 2007-02-26 17:30:42 UTC (rev 2352)
+++ SQLObject/branches/0.7/sqlobject/manager/command.py 2007-02-28 15:26:01 UTC (rev 2353)
@@ -18,6 +18,7 @@
from sqlobject import col
from sqlobject.util import moduleloader
from sqlobject.declarative import DeclarativeMeta
+from sqlobject.classregistry import findClass
# It's not very unsafe to use tempnam like we are doing:
warnings.filterwarnings(
@@ -183,6 +184,81 @@
help = ''
+ def orderClassesByDependencyLevel(self, classes):
+ """
+ Return classes ordered by their depth in the class dependency
+ tree (this is *not* the inheritance tree), from the
+ top level (independant) classes to the deepest level.
+ The dependency tree is defined by the foreign key relations.
+ """
+ # @@: written as a self-contained function for now, to prevent
+ # having to modify any core SQLObject component and namespace
+ # contamination.
+ # yemartin - 2006-08-08
+
+ class SQLObjectCircularReferenceError(Exception): pass
+
+ def findReverseDependencies(cls):
+ """
+ Return a list of classes that cls depends on. Note that
+ "depends on" here mean "has a foreign key pointing to".
+ """
+ depended = []
+ for col in cls.sqlmeta.columnList:
+ if col.foreignKey:
+ other = findClass(col.foreignKey,
+ col.soClass.sqlmeta.registry)
+ if other not in depended:
+ depended.append(other)
+ return depended
+
+ # Cache to save already calculated dependency levels.
+ dependency_levels = {}
+ def calculateDependencyLevel(cls, dependency_stack=[]):
+ """
+ Recursively calculate the dependency level of cls, while
+ using the dependency_stack to detect any circular reference.
+ """
+ # Return value from the cache if already calculated
+ if dependency_levels.has_key(cls):
+ return dependency_levels[cls]
+ # Check for circular references
+ if cls in dependency_stack:
+ dependency_stack.append(cls)
+ raise SQLObjectCircularReferenceError, (
+ "Found a circular reference: %s " %
+ (' --> '.join([x.__name__
+ for x in dependency_stack])))
+ dependency_stack.append(cls)
+ # Recursively inspect dependent classes.
+ depended = findReverseDependencies(cls)
+ if depended:
+ level = max([calculateDependencyLevel(x, dependency_stack)
+ for x in depended]) + 1
+ else:
+ level = 0
+ dependency_levels[cls] = level
+ return level
+
+ # Now simply calculate and sort by dependency levels:
+ try:
+ sorter = []
+ for cls in classes:
+ level = calculateDependencyLevel(cls)
+ sorter.append((level, cls))
+ sorter.sort()
+ ordered_classes = [cls for level, cls in sorter]
+ except SQLObjectCircularReferenceError, msg:
+ # Failsafe: return the classes as-is if a circular reference
+ # prevented the dependency levels to be calculated.
+ print ("Warning: a circular reference was detected in the "
+ "model. Unable to sort the classes by dependency: they "
+ "will be treated in alphabetic order. This may or may "
+ "not work depending on your database backend. "
+ "The error was:\n%s" % msg)
+ return classes
+ return ordered_classes
+
def __classinit__(cls, new_args):
if cls.__bases__ == (object,):
# This abstract base class
@@ -287,7 +363,7 @@
else:
print 'No eggs specified'
sys.exit(1)
- return all
+ return self.orderClassesByDependencyLevel(all)
def classes_from_module(self, module):
all = []
@@ -589,7 +665,7 @@
v = self.options.verbose
dropped = 0
not_existing = 0
- for soClass in self.classes():
+ for soClass in self.classes().__reversed__():
exists = soClass._connection.tableExists(soClass.sqlmeta.table)
if v >= 1:
if exists:
|
|
From: SourceForge.net <no...@so...> - 2007-02-28 11:29:15
|
Bugs item #1670239, was opened at 2007-02-27 21:37 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1670239&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: None >Status: Closed >Resolution: Works For Me Priority: 5 Private: No Submitted By: Vladimir Chukharev (chukharevv) >Assigned to: Oleg Broytmann (phd) Summary: orderBy='..' conflicts with distinct=True in select() Initial Comment: I tried to execute select() with parameters orderBy and distinct for inheritable tables. Any of the two parameters can be used alone, but if they are used together, an error occurs. The following example is printed in Python shell: from datetime import datetime from sqlobject import * from sqlobject.sqlbuilder import * from sqlobject.inheritance import InheritableSQLObject sqlhub.processConnection = connectionForURI('postgres:///test') class Base(InheritableSQLObject): created = DateTimeCol(default=DateTimeCol.now()) class BaseSample(Base): name = StringCol(length=40, alternateID=True) BaseSample.createTable(ifNotExists=True) Base.createTable(ifNotExists=True) sample = BaseSample(name='Sample1') order=BaseSample.q.created Two working calls of select(). print list(BaseSample.select(orderBy=order)) [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] print list(BaseSample.select(distinct=True)) [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] Now the error. print list(BaseSample.select(orderBy=order, distinct=True)) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sresults.py", line 155, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sresults.py", line 163, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 364, in iterSelect select, keepConnection=False) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/inheritance/iteration.py", line 10, in __init__ super(InheritableIteration, self).__init__(dbconn, rawconn, select, keepConnection) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 704, in __init__ self.dbconn._executeRetry(self.rawconn, self.cursor, self.query) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 298, in _executeRetry return cursor.execute(query) psycopg.ProgrammingError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list SELECT DISTINCT base_sample.id, base_sample.child_name, base_sample.name FROM base, base_sample WHERE ((1 = 1) AND ((base_sample.id) = (base.id))) ORDER BY base.created Additional information. SQLObject-0.7.1dev_r1860 TurboGears-1.0b1 Ubuntu $ uname -a Linux svetlana-desktop 2.6.15-28-amd64-generic #1 SMP PREEMPT Thu Feb 1 15:53:41 UTC 2007 x86_64 GNU/Linux ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-02-28 14:29 Message: Logged In: YES user_id=4799 Originator: NO Works in SQLObject 0.8: from datetime import datetime from sqlobject import * from sqlobject.inheritance import InheritableSQLObject from sqlobject.sqlbuilder import * __connection__ = "postgres:/test?debug=1" class Base(InheritableSQLObject): created = DateTimeCol(default=DateTimeCol.now()) class BaseSample(Base): name = StringCol(length=40, alternateID=True) Base.createTable(ifNotExists=True) BaseSample.createTable(ifNotExists=True) sample = BaseSample(name='Sample1') order=BaseSample.q.created print list(BaseSample.select(orderBy=order)) print list(BaseSample.select(distinct=True)) print list(BaseSample.select(orderBy=order, distinct=True)) Debugging output; please note base.created is in the select list in the last SELECT DISTINCT query: 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'base' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'base' 1/COMMIT : auto 1/Query : CREATE TABLE base ( id SERIAL PRIMARY KEY, created TIMESTAMP, child_name VARCHAR(255) ) 1/QueryR : CREATE TABLE base ( id SERIAL PRIMARY KEY, created TIMESTAMP, child_name VARCHAR(255) ) 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'base_sample' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'base_sample' 1/COMMIT : auto 1/Query : CREATE TABLE base_sample ( id SERIAL PRIMARY KEY, name VARCHAR(40) NOT NULL UNIQUE, child_name VARCHAR(255) ) 1/QueryR : CREATE TABLE base_sample ( id SERIAL PRIMARY KEY, name VARCHAR(40) NOT NULL UNIQUE, child_name VARCHAR(255) ) 1/COMMIT : auto 1/QueryIns: INSERT INTO base (id, child_name, created) VALUES (1, 'BaseSample', '2007-02-28 14:24:22') 1/COMMIT : auto 1/QueryOne: SELECT created, child_name FROM base WHERE id = (1) 1/QueryR : SELECT created, child_name FROM base WHERE id = (1) 1/COMMIT : auto 1/QueryIns: INSERT INTO base_sample (id, name, child_name) VALUES (1, 'Sample1', NULL) 1/COMMIT : auto 1/QueryOne: SELECT name, child_name FROM base_sample WHERE id = (1) 1/QueryR : SELECT name, child_name FROM base_sample WHERE id = (1) 1/COMMIT : auto 1/Select : SELECT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/QueryR : SELECT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] 1/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) 1/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] 1/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] PS. I hope you understand the difference between created = DateTimeCol(default=DateTimeCol.now()) and created = DateTimeCol(default=DateTimeCol.now) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1670239&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-02-28 11:15:38
|
Bugs item #1665322, was opened at 2007-02-21 18:30 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1665322&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Open Resolution: Wont Fix Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) Assigned to: Oleg Broytmann (phd) Summary: InheritableSQLObject childName column in sqlmeta.columns Initial Comment: from sqlobject import * from sqlobject.inheritance import InheritableSQLObject __connection__ = 'sqlite:///:memory:' class Base(InheritableSQLObject): base = IntCol() Base.createTable() print j.Base.sqlmeta.columns {'base': <SOIntCol base>, 'childName': <SOStringCol childName default=None>} I think 'childName' should not be "listed" in sqlmeta.columns because it's a SQLObject "artifact" (just like 'id' column). This complicate automatic conversion from SQLObject to other types (like TurboJson's jsonify_sqlobject() function). ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-02-28 14:15 Message: Logged In: YES user_id=4799 Originator: NO Reopened; see bug 1665328 for details. Now waiting for a patch... ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-02-23 16:22 Message: Logged In: YES user_id=240225 Originator: YES Because it doesn't behave like a real column (1665328 is an example, a regular column is inherited to all it's descendant, and the "None" behavior is another example too) and it's not user data. But I understand you don't see a great advantage on fixing it, i'll try to work on it when I have some time if you agree something is wrong and are interested in patches for this... (and don't want to work on a patch that it will not be accepted). ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-02-23 15:35 Message: Logged In: YES user_id=4799 Originator: NO Why is it a bug? It works as advertised. It is a real column, and it presents in .columns. In any case it would be so hard to fix, and fixing it gives so little advantage - I am not going to work on it. But I can test a patch if one appears. ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-02-23 15:08 Message: Logged In: YES user_id=240225 Originator: YES Ok, it should be hard to fix, but don't you agree it's a bug? Shouldn't be emulated like the "id" column? It's not user data. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-02-22 22:41 Message: Logged In: YES user_id=4799 Originator: NO SQLObject emulates "id" columns. Unlike that fictional column childName is a real column. There is no way to remove it from .columns. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1665322&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-02-28 11:09:51
|
Patches item #1450564, was opened at 2006-03-15 20:52 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1450564&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed Resolution: Invalid Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) >Assigned to: Oleg Broytmann (phd) Summary: Limit keyword does not with orderBy Initial Comment: When performing a select query over a table, the limit keyword will not be used if orderBy is specified. For example, class Test(SQLObject): total IntCol(notNull=True) # create SQL connection and stuff ... res = Test.select(orderBy='total', limit=10) The results will contain every row from Test, since the resultant SQL query is similar to "SELECT id, total FROM test ORDER BY total" No LIMIT attribute is ever specified. Looking at the code, this is because limit will only work when used with the start or end keyword. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-03-21 12:57 Message: Logged In: YES user_id=4799 Please add documentation and tests. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-03-21 12:53 Message: Logged In: YES user_id=4799 The query should be res = Test.select(orderBy='total')[:10] ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1450564&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-02-27 18:37:45
|
Bugs item #1670239, was opened at 2007-02-27 18:37 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1670239&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Vladimir Chukharev (chukharevv) Assigned to: Nobody/Anonymous (nobody) Summary: orderBy='..' conflicts with distinct=True in select() Initial Comment: I tried to execute select() with parameters orderBy and distinct for inheritable tables. Any of the two parameters can be used alone, but if they are used together, an error occurs. The following example is printed in Python shell: from datetime import datetime from sqlobject import * from sqlobject.sqlbuilder import * from sqlobject.inheritance import InheritableSQLObject sqlhub.processConnection = connectionForURI('postgres:///test') class Base(InheritableSQLObject): created = DateTimeCol(default=DateTimeCol.now()) class BaseSample(Base): name = StringCol(length=40, alternateID=True) BaseSample.createTable(ifNotExists=True) Base.createTable(ifNotExists=True) sample = BaseSample(name='Sample1') order=BaseSample.q.created Two working calls of select(). print list(BaseSample.select(orderBy=order)) [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] print list(BaseSample.select(distinct=True)) [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] Now the error. print list(BaseSample.select(orderBy=order, distinct=True)) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sresults.py", line 155, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sresults.py", line 163, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 364, in iterSelect select, keepConnection=False) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/inheritance/iteration.py", line 10, in __init__ super(InheritableIteration, self).__init__(dbconn, rawconn, select, keepConnection) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 704, in __init__ self.dbconn._executeRetry(self.rawconn, self.cursor, self.query) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 298, in _executeRetry return cursor.execute(query) psycopg.ProgrammingError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list SELECT DISTINCT base_sample.id, base_sample.child_name, base_sample.name FROM base, base_sample WHERE ((1 = 1) AND ((base_sample.id) = (base.id))) ORDER BY base.created Additional information. SQLObject-0.7.1dev_r1860 TurboGears-1.0b1 Ubuntu $ uname -a Linux svetlana-desktop 2.6.15-28-amd64-generic #1 SMP PREEMPT Thu Feb 1 15:53:41 UTC 2007 x86_64 GNU/Linux ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1670239&group_id=74338 |
|
From: <sub...@co...> - 2007-02-26 17:30:56
|
Author: luke
Date: 2007-02-26 10:30:42 -0700 (Mon, 26 Feb 2007)
New Revision: 2352
Modified:
SQLObject/branches/sqlbuilder-views/sqlobject/converters.py
SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py
SQLObject/branches/sqlbuilder-views/sqlobject/views.py
Log:
cleaner sqlrepr/tablesUsed caching, stable view column list for unions
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/converters.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/converters.py 2007-02-23 19:11:57 UTC (rev 2351)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/converters.py 2007-02-26 17:30:42 UTC (rev 2352)
@@ -237,17 +237,20 @@
(type(obj), repr(obj))
return converter(obj, db)
else:
-# return reprFunc(db)
- cache = getattr(obj, '_sqlreprCache', {})
- if not isinstance(cache, dict):
- #Alias etc
- cache = {}
- ret = cache.get(db, None)
+ doCache = hasattr(db, 'doSQLReprCache')
+ ret = None
+ if doCache:
+ cache = getattr(obj, '_sqlreprCache', {})
+ if not isinstance(cache, dict):
+ #Alias etc
+ cache = {}
+ ret = cache.get(db, None)
if ret is None:
ret = reprFunc(db)
- try:
- cache[db] = ret
- obj._sqlreprCache = cache
- except TypeError:
- pass
+ if doCache:
+ try:
+ cache[db] = ret
+ obj._sqlreprCache = cache
+ except TypeError:
+ pass
return ret
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py 2007-02-23 19:11:57 UTC (rev 2351)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py 2007-02-26 17:30:42 UTC (rev 2352)
@@ -188,7 +188,14 @@
def tablesUsed(self, db):
return self.tablesUsedDict(db).keys()
def tablesUsedDict(self, db):
- tables = getattr(db, 'tableCache', {}).get(id(self), None)
+ doCache = hasattr(db, 'doTablesUsedCache')
+ tables = None
+ if doCache:
+ cache = getattr(self, '_tablesUsedCache', {})
+ if not isinstance(cache, dict):
+ #Alias etc
+ cache = {}
+ tables = cache.get(db, None)
if tables is None:
tables = {}
for table in self.tablesUsedImmediate():
@@ -197,7 +204,12 @@
tables[table] = 1
for component in self.components():
tables.update(tablesUsedDict(component, db))
- getattr(db, 'tableCache', {})[id(self)] = tables
+ if doCache:
+ try:
+ cache[db] = tables
+ self._tablesUsedCache = cache
+ except TypeError:
+ pass
return tables
def tablesUsedImmediate(self):
return []
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/views.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/views.py 2007-02-23 19:11:57 UTC (rev 2351)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/views.py 2007-02-26 17:30:42 UTC (rev 2352)
@@ -88,7 +88,9 @@
columns = [ColumnAS(cls.sqlmeta.idName, 'id')]
# {sqlrepr-key: [restriction, *aggregate-column]}
aggregates = {'':[None]}
- for n,col in cls.sqlmeta.columns.iteritems():
+ inverseColumns = dict([(y,x) for x,y in cls.sqlmeta.columns.iteritems()])
+ for col in cls.sqlmeta.columnList:
+ n = inverseColumns[col]
ascol = ColumnAS(col.dbName, n)
if isAggregate(col.dbName):
restriction = getattr(col, 'aggregateClause',None)
@@ -109,8 +111,9 @@
clause=clause)
aggregates = aggregates.values()
+ #print cls.__name__, sqlrepr(aggregates, dbName)
- if len(aggregates) > 1:
+ if aggregates != [[None]]:
join = []
last_alias = "%s_base" % alias
last_id = "id"
|
|
From: <sub...@co...> - 2007-02-23 17:21:57
|
Author: luke
Date: 2007-02-23 10:21:51 -0700 (Fri, 23 Feb 2007)
New Revision: 2350
Modified:
SQLObject/branches/sqlbuilder-views/sqlobject/conftest.py
Log:
uncommit my conftest cheat
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/conftest.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/conftest.py 2007-02-23 17:21:12 UTC (rev 2349)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/conftest.py 2007-02-23 17:21:51 UTC (rev 2350)
@@ -16,7 +16,7 @@
except ImportError: # Python 2.2
pass
else:
- pass #pkg_resources.require('SQLObject')
+ pkg_resources.require('SQLObject')
connectionShortcuts = {
'mysql': 'mysql://test@localhost/test',
|