sqlobject-cvs Mailing List for SQLObject (Page 107)
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: SourceForge.net <no...@so...> - 2007-01-23 15:17:07
|
Bugs item #1640436, was opened at 2007-01-20 23:14 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1640436&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: SQLObject release (specify) >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Daniel Nogradi (nogradi) >Assigned to: Oleg Broytmann (phd) Summary: order by several columns and inheritance Initial Comment: I've checked the following with sqlite only. SQLObject version: 0.8.0b1 Sql query generation is broken when using several columns as orderBy keyword argument and inherited classes: --------------------------------------------------------------- class parent( InheritableSQLObject ): pass class t( parent ): c = IntCol( ) d = IntCol( ) --------------------------------------------------------------- Using a single orderBy column works: --------------------------------------------------------------- for i in t.select( orderBy=t.q.d ): print i SELECT parent.id, parent.child_name FROM t, parent WHERE (((parent.child_name) = ('t')) AND ((t.id) = (parent.id))) ORDER BY t.d SELECT t.id, t.c, t.d, t.child_name FROM t WHERE ((t.id) = (1)) ---------------------------------------------------------------- but multiple orderBy columns throw an exception in the first query: ---------------------------------------------------------------- for i in t.select( orderBy=( t.q.c, t.q.d ) ): print i SELECT parent.id, parent.child_name FROM parent WHERE ((parent.child_name) = ('t')) ORDER BY t.c, t.d sqlobject.dberrors.OperationalError: no such column: t.c ----------------------------------------------------------------- And it seems that the problem is that the query doesn't have "FROM t, parent" only "FROM parent" (among other things) while in the first case (only one orderBy column) the query was generated correctly. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-01-23 18:17 Message: Logged In: YES user_id=4799 Originator: NO Fixed in the revisions 2230-2232 (trunk, 0.8 branch, docs). Thank you! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1640436&group_id=74338 |
|
From: <sub...@co...> - 2007-01-23 15:17:02
|
Author: phd Date: 2007-01-23 08:16:43 -0700 (Tue, 23 Jan 2007) New Revision: 2232 Modified: SQLObject/docs/News.txt Log: Order by several columns with inheritance. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-01-23 15:16:22 UTC (rev 2231) +++ SQLObject/docs/News.txt 2007-01-23 15:16:43 UTC (rev 2232) @@ -139,6 +139,8 @@ * Fixed a bug in FirebirdConnection caused by column names having trailing spaces. +* Order by several columns with inheritance. + SQLObject 0.7.3 =============== |
|
From: <sub...@co...> - 2007-01-23 15:16:45
|
Author: phd
Date: 2007-01-23 08:16:22 -0700 (Tue, 23 Jan 2007)
New Revision: 2231
Modified:
SQLObject/branches/0.8/sqlobject/inheritance/__init__.py
SQLObject/branches/0.8/sqlobject/inheritance/tests/test_inheritance.py
Log:
Fixed bug 1640436: order by several columns and inheritance.
Modified: SQLObject/branches/0.8/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/inheritance/__init__.py 2007-01-23 15:06:40 UTC (rev 2230)
+++ SQLObject/branches/0.8/sqlobject/inheritance/__init__.py 2007-01-23 15:16:22 UTC (rev 2231)
@@ -13,17 +13,30 @@
basestring = (types.StringType, types.UnicodeType)
+def tablesUsedDict(obj):
+ if hasattr(obj, "tablesUsedDict"):
+ return obj.tablesUsedDict()
+ elif isinstance(obj, (tuple, list)):
+ d = {}
+ for component in obj:
+ print component
+ d.update(tablesUsedDict(component))
+ return d
+ else:
+ return {}
+
+
class InheritableSelectResults(SelectResults):
IterationClass = iteration.InheritableIteration
def __init__(self, sourceClass, clause, clauseTables=None, **ops):
if clause is None or isinstance(clause, str) and clause == 'all':
clause = sqlbuilder.SQLTrueClause
- tablesDict = sqlbuilder.tablesUsedDict(clause)
+ tablesDict = tablesUsedDict(clause)
tablesDict[sourceClass.sqlmeta.table] = 1
orderBy = ops.get('orderBy')
if orderBy and not isinstance(orderBy, basestring):
- tablesDict.update(sqlbuilder.tablesUsedDict(orderBy))
+ tablesDict.update(tablesUsedDict(orderBy))
#DSM: if this class has a parent, we need to link it
#DSM: and be sure the parent is in the table list.
#DSM: The following code is before clauseTables
Modified: SQLObject/branches/0.8/sqlobject/inheritance/tests/test_inheritance.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/inheritance/tests/test_inheritance.py 2007-01-23 15:06:40 UTC (rev 2230)
+++ SQLObject/branches/0.8/sqlobject/inheritance/tests/test_inheritance.py 2007-01-23 15:16:22 UTC (rev 2231)
@@ -79,6 +79,24 @@
person = Employee.byLastName("Leader")
assert person.firstName == "Project"
+ persons = list(InheritablePerson.select(orderBy=InheritablePerson.q.lastName))
+ assert len(persons) == 2
+
+ persons = list(InheritablePerson.select(orderBy=(InheritablePerson.q.lastName, InheritablePerson.q.firstName)))
+ assert len(persons) == 2
+
+ persons = list(Employee.select(orderBy=Employee.q.lastName))
+ assert len(persons) == 1
+
+ persons = list(Employee.select(orderBy=(Employee.q.lastName, Employee.q.firstName)))
+ assert len(persons) == 1
+
+ persons = list(Employee.select(orderBy=Employee.q.position))
+ assert len(persons) == 1
+
+ persons = list(Employee.select(orderBy=(Employee.q.position, Employee.q.lastName)))
+ assert len(persons) == 1
+
def test_addDelColumn():
setup()
|
|
From: <sub...@co...> - 2007-01-23 15:06:59
|
Author: phd
Date: 2007-01-23 08:06:40 -0700 (Tue, 23 Jan 2007)
New Revision: 2230
Modified:
SQLObject/trunk/sqlobject/inheritance/__init__.py
SQLObject/trunk/sqlobject/inheritance/tests/test_inheritance.py
Log:
Fixed bug 1640436: order by several columns and inheritance.
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-01-22 21:59:28 UTC (rev 2229)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-01-23 15:06:40 UTC (rev 2230)
@@ -13,17 +13,30 @@
basestring = (types.StringType, types.UnicodeType)
+def tablesUsedDict(obj):
+ if hasattr(obj, "tablesUsedDict"):
+ return obj.tablesUsedDict()
+ elif isinstance(obj, (tuple, list)):
+ d = {}
+ for component in obj:
+ print component
+ d.update(tablesUsedDict(component))
+ return d
+ else:
+ return {}
+
+
class InheritableSelectResults(SelectResults):
IterationClass = iteration.InheritableIteration
def __init__(self, sourceClass, clause, clauseTables=None, **ops):
if clause is None or isinstance(clause, str) and clause == 'all':
clause = sqlbuilder.SQLTrueClause
- tablesDict = sqlbuilder.tablesUsedDict(clause)
+ tablesDict = tablesUsedDict(clause)
tablesDict[sourceClass.sqlmeta.table] = 1
orderBy = ops.get('orderBy')
if orderBy and not isinstance(orderBy, basestring):
- tablesDict.update(sqlbuilder.tablesUsedDict(orderBy))
+ tablesDict.update(tablesUsedDict(orderBy))
#DSM: if this class has a parent, we need to link it
#DSM: and be sure the parent is in the table list.
#DSM: The following code is before clauseTables
Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_inheritance.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/tests/test_inheritance.py 2007-01-22 21:59:28 UTC (rev 2229)
+++ SQLObject/trunk/sqlobject/inheritance/tests/test_inheritance.py 2007-01-23 15:06:40 UTC (rev 2230)
@@ -79,6 +79,24 @@
person = Employee.byLastName("Leader")
assert person.firstName == "Project"
+ persons = list(InheritablePerson.select(orderBy=InheritablePerson.q.lastName))
+ assert len(persons) == 2
+
+ persons = list(InheritablePerson.select(orderBy=(InheritablePerson.q.lastName, InheritablePerson.q.firstName)))
+ assert len(persons) == 2
+
+ persons = list(Employee.select(orderBy=Employee.q.lastName))
+ assert len(persons) == 1
+
+ persons = list(Employee.select(orderBy=(Employee.q.lastName, Employee.q.firstName)))
+ assert len(persons) == 1
+
+ persons = list(Employee.select(orderBy=Employee.q.position))
+ assert len(persons) == 1
+
+ persons = list(Employee.select(orderBy=(Employee.q.position, Employee.q.lastName)))
+ assert len(persons) == 1
+
def test_addDelColumn():
setup()
|
|
From: SourceForge.net <no...@so...> - 2007-01-23 12:29:04
|
Bugs item #1642143, was opened at 2007-01-23 01:07 Message generated for change (Comment added) made by llucax You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&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: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) Assigned to: Oleg Broytmann (phd) Summary: [PATCH] TypeError:unhashable instance using sqlbuilder.Table Initial Comment: Hi! Maybe this is a pretty weird use case (please let me know if there is a better way to do this). What I wanted was just to store an ordered list of many-to-many relationships. To achieve this, I used an special intermediate table with an extra field for ordering. Then I write some custom SQL queries to do the join using sqlbuilder.table (Table instance) and friends. The problem is I'm getting a TypeError ("TypeError: unhashable instance") when doing that, because Table and Field don't have the __hash__ magic method (and for the records, none SQLExpression does either). Well, long story short, this is fixed by just adding the __hash__ method to SQLExpression class. Here is the patch and a simple testcase. Again, please tell me if there is a cleaner way to achieve this with SQLObject. Thanks! ---------------------------------------------------------------------- >Comment By: Leandro Lucarella (llucax) Date: 2007-01-23 09:29 Message: Logged In: YES user_id=240225 Originator: YES I know I can create the intermediate table using SQLObject, but I don't want to, because this generates an extra 'id' field in the table that is useless. What I really wanted to do was add an "OrderedRelatedJoin" or something like that but I got lost because RelatedJoin is so tied up with dbconnection module. I expected to be just plan (sqlbuilder) SQL in the join module. Another simple solution (but I think not too easy to implement because AFAIK SQLObject is to tied up too to the single primary key) is to let a SQLObject to have a composed primary key and use the two FK as the PK. Anyways, I'm not using the Table object as dict, SQLObject is =) If you run the testcase, you'll get: Traceback (most recent call last): File "testcase.py", line 70, in ? plan.tasks = (Task(name="task1"), Task(name="task2"), Task(name="task3")) File "testcase.py", line 48, in _set_tasks old = frozenset([t.id for t in self.tasks]) File "testcase.py", line 38, in _get_tasks orderBy=task_plan_table.pos, File "/tmp/0.8/sqlobject/main.py", line 1347, in select join=join, forUpdate=forUpdate) File "/tmp/0.8/sqlobject/sresults.py", line 20, in __init__ tablesDict[table] = 1 TypeError: unhashable instance I know I could use plain old strings instead of the Table object instance, but I found the later more pythonic (I feel like I'm not messing arround with raw SQL =D). And BTW, it's a very simple patch (3 lines of code, it's 'def __has__(self): return hash(str(self))' inside SQLExpression class declaration. It couldn't hurt anybody. And as plus it completes a little more the SQLExpression in general so you can use SQLExpressions as dict keys in general. PS. Sorry about the patch, I've posted some others in the past here and nobody complained, maybe there was a change in the policy, that was about... 2 years ago. Damn! The time pass by... ;-P ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-01-23 06:46 Message: Logged In: YES user_id=4799 Originator: NO First, you don't need to create the intermediate table yourself. The development FAQ shows how to do this in SQLObject: http://sqlobject.org/devel/FAQ.html#how-can-i-define-my-own-intermediate-table-in-my-many-to-many-relationship Second, I do not understand where from came the TypeError. Are you trying to use Tables as a dict keys? PS. Patches should be put in patches, really. ;) ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-01-23 01:11 Message: Logged In: YES user_id=240225 Originator: YES The patch apply cleanly to the 0.8 branch too. I hope it make it to 0.8 =) ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-01-23 01:09 Message: Logged In: YES user_id=240225 Originator: YES File Added: sqlexpression.hash.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-01-23 09:46:36
|
Bugs item #1642143, was opened at 2007-01-23 07:07 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&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: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) >Assigned to: Oleg Broytmann (phd) Summary: [PATCH] TypeError:unhashable instance using sqlbuilder.Table Initial Comment: Hi! Maybe this is a pretty weird use case (please let me know if there is a better way to do this). What I wanted was just to store an ordered list of many-to-many relationships. To achieve this, I used an special intermediate table with an extra field for ordering. Then I write some custom SQL queries to do the join using sqlbuilder.table (Table instance) and friends. The problem is I'm getting a TypeError ("TypeError: unhashable instance") when doing that, because Table and Field don't have the __hash__ magic method (and for the records, none SQLExpression does either). Well, long story short, this is fixed by just adding the __hash__ method to SQLExpression class. Here is the patch and a simple testcase. Again, please tell me if there is a cleaner way to achieve this with SQLObject. Thanks! ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-01-23 12:46 Message: Logged In: YES user_id=4799 Originator: NO First, you don't need to create the intermediate table yourself. The development FAQ shows how to do this in SQLObject: http://sqlobject.org/devel/FAQ.html#how-can-i-define-my-own-intermediate-table-in-my-many-to-many-relationship Second, I do not understand where from came the TypeError. Are you trying to use Tables as a dict keys? PS. Patches should be put in patches, really. ;) ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-01-23 07:11 Message: Logged In: YES user_id=240225 Originator: YES The patch apply cleanly to the 0.8 branch too. I hope it make it to 0.8 =) ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-01-23 07:09 Message: Logged In: YES user_id=240225 Originator: YES File Added: sqlexpression.hash.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-01-23 04:11:48
|
Bugs item #1642143, was opened at 2007-01-23 01:07 Message generated for change (Comment added) made by llucax You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&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: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) Assigned to: Nobody/Anonymous (nobody) Summary: [PATCH] TypeError:unhashable instance using sqlbuilder.Table Initial Comment: Hi! Maybe this is a pretty weird use case (please let me know if there is a better way to do this). What I wanted was just to store an ordered list of many-to-many relationships. To achieve this, I used an special intermediate table with an extra field for ordering. Then I write some custom SQL queries to do the join using sqlbuilder.table (Table instance) and friends. The problem is I'm getting a TypeError ("TypeError: unhashable instance") when doing that, because Table and Field don't have the __hash__ magic method (and for the records, none SQLExpression does either). Well, long story short, this is fixed by just adding the __hash__ method to SQLExpression class. Here is the patch and a simple testcase. Again, please tell me if there is a cleaner way to achieve this with SQLObject. Thanks! ---------------------------------------------------------------------- >Comment By: Leandro Lucarella (llucax) Date: 2007-01-23 01:11 Message: Logged In: YES user_id=240225 Originator: YES The patch apply cleanly to the 0.8 branch too. I hope it make it to 0.8 =) ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-01-23 01:09 Message: Logged In: YES user_id=240225 Originator: YES File Added: sqlexpression.hash.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-01-23 04:09:37
|
Bugs item #1642143, was opened at 2007-01-23 01:07 Message generated for change (Comment added) made by llucax You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&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: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) Assigned to: Nobody/Anonymous (nobody) Summary: [PATCH] TypeError:unhashable instance using sqlbuilder.Table Initial Comment: Hi! Maybe this is a pretty weird use case (please let me know if there is a better way to do this). What I wanted was just to store an ordered list of many-to-many relationships. To achieve this, I used an special intermediate table with an extra field for ordering. Then I write some custom SQL queries to do the join using sqlbuilder.table (Table instance) and friends. The problem is I'm getting a TypeError ("TypeError: unhashable instance") when doing that, because Table and Field don't have the __hash__ magic method (and for the records, none SQLExpression does either). Well, long story short, this is fixed by just adding the __hash__ method to SQLExpression class. Here is the patch and a simple testcase. Again, please tell me if there is a cleaner way to achieve this with SQLObject. Thanks! ---------------------------------------------------------------------- >Comment By: Leandro Lucarella (llucax) Date: 2007-01-23 01:09 Message: Logged In: YES user_id=240225 Originator: YES File Added: sqlexpression.hash.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-01-23 04:07:23
|
Bugs item #1642143, was opened at 2007-01-23 01:07 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=1642143&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: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) Assigned to: Nobody/Anonymous (nobody) Summary: [PATCH] TypeError:unhashable instance using sqlbuilder.Table Initial Comment: Hi! Maybe this is a pretty weird use case (please let me know if there is a better way to do this). What I wanted was just to store an ordered list of many-to-many relationships. To achieve this, I used an special intermediate table with an extra field for ordering. Then I write some custom SQL queries to do the join using sqlbuilder.table (Table instance) and friends. The problem is I'm getting a TypeError ("TypeError: unhashable instance") when doing that, because Table and Field don't have the __hash__ magic method (and for the records, none SQLExpression does either). Well, long story short, this is fixed by just adding the __hash__ method to SQLExpression class. Here is the patch and a simple testcase. Again, please tell me if there is a cleaner way to achieve this with SQLObject. Thanks! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1642143&group_id=74338 |
|
From: <sub...@co...> - 2007-01-22 21:59:40
|
Author: novalis
Date: 2007-01-22 14:59:28 -0700 (Mon, 22 Jan 2007)
New Revision: 2229
Modified:
SQLObject/trunk/sqlobject/versioning/__init__.py
SQLObject/trunk/sqlobject/versioning/test/test_version.py
Log:
do not restore attributes that are extra to the version
Modified: SQLObject/trunk/sqlobject/versioning/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-22 21:26:24 UTC (rev 2228)
+++ SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-22 21:59:28 UTC (rev 2229)
@@ -7,6 +7,8 @@
del values['id']
del values['masterID']
del values['dateArchived']
+ for col in self.extraCols:
+ del values[col]
self.masterClass.get(self.masterID).set(**values)
def nextVersion(self):
@@ -65,6 +67,7 @@
attrs = {'dateArchived': DateTimeCol(default=datetime.now),
'master': ForeignKey(self.soClass.__name__),
'masterClass' : self.soClass,
+ 'extraCols' : self.extraCols
}
getColumns (attrs, self.soClass)
Modified: SQLObject/trunk/sqlobject/versioning/test/test_version.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-22 21:26:24 UTC (rev 2228)
+++ SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-22 21:59:28 UTC (rev 2229)
@@ -121,6 +121,13 @@
assert monarchy.name == "USA"
assert monarchy.monarch == "Emperor Norton I"
+ extra = Extra(name='fleem')
+ extra.set(name='morx')
+ assert extra.name == "morx"
+ extra.versions[0].restore()
+ assert extra.name == "fleem"
+
+
def test_next():
setup()
base = Base(name='first', value=1)
|
|
From: <sub...@co...> - 2007-01-22 21:26:36
|
Author: novalis
Date: 2007-01-22 14:26:24 -0700 (Mon, 22 Jan 2007)
New Revision: 2228
Modified:
SQLObject/trunk/sqlobject/versioning/__init__.py
Log:
make version objects act like instances of their master class
Modified: SQLObject/trunk/sqlobject/versioning/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-22 13:31:01 UTC (rev 2227)
+++ SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-22 21:26:24 UTC (rev 2228)
@@ -33,6 +33,12 @@
return super(Version, cls).select(clause, *args, **kw)
select = classmethod(select)
+ def __getattr__(self, attr):
+ if self.__dict__.has_key(attr):
+ return self.__dict__[attr]
+ else:
+ return getattr(self.master, attr)
+
def getColumns(columns, cls):
for column, defi in cls.sqlmeta.columnDefinitions.items():
if column.endswith("ID") and isinstance(defi, ForeignKey):
@@ -69,6 +75,9 @@
(Version,),
attrs)
+ if '_connection' in self.soClass.__dict__:
+ self.versionClass._connection = self.soClass.__dict__['_connection']
+
events.listen(self.createTable,
soClass, events.CreateTableSignal)
events.listen(self.rowUpdate, soClass,
|
|
From: <sub...@co...> - 2007-01-22 13:31:06
|
Author: phd Date: 2007-01-22 06:31:01 -0700 (Mon, 22 Jan 2007) New Revision: 2227 Modified: SQLObject/tags/0.8.0b2/setup.cfg SQLObject/tags/0.8.0b2/setup.py Log: Stupid me. Commited to the wrong branch. Modified: SQLObject/tags/0.8.0b2/setup.cfg =================================================================== --- SQLObject/tags/0.8.0b2/setup.cfg 2007-01-22 13:30:00 UTC (rev 2226) +++ SQLObject/tags/0.8.0b2/setup.cfg 2007-01-22 13:31:01 UTC (rev 2227) @@ -1,10 +1,6 @@ [easy_install] #find_links = http://svn.pythonpaste.org/package_index.html -[egg_info] -tag_build = dev -tag_svn_revision = true - [pudge] theme = pythonpaste.org docs = docs/index.txt docs/SQLObject.txt docs/TODO.txt Modified: SQLObject/tags/0.8.0b2/setup.py =================================================================== --- SQLObject/tags/0.8.0b2/setup.py 2007-01-22 13:30:00 UTC (rev 2226) +++ SQLObject/tags/0.8.0b2/setup.py 2007-01-22 13:31:01 UTC (rev 2227) @@ -28,7 +28,7 @@ """ setup(name="SQLObject", - version="0.8", + version="0.8.0b2", description="Object-Relational Manager, aka database wrapper", long_description="""\ SQLObject is a popular *Object Relational Manager* for providing an |
|
From: <sub...@co...> - 2007-01-22 13:30:06
|
Author: phd Date: 2007-01-22 06:30:00 -0700 (Mon, 22 Jan 2007) New Revision: 2226 Modified: SQLObject/branches/0.8/setup.cfg SQLObject/branches/0.8/setup.py Log: Stupid me. Commited to the wrong branch. Modified: SQLObject/branches/0.8/setup.cfg =================================================================== --- SQLObject/branches/0.8/setup.cfg 2007-01-22 13:28:16 UTC (rev 2225) +++ SQLObject/branches/0.8/setup.cfg 2007-01-22 13:30:00 UTC (rev 2226) @@ -1,6 +1,10 @@ [easy_install] #find_links = http://svn.pythonpaste.org/package_index.html +[egg_info] +tag_build = dev +tag_svn_revision = true + [pudge] theme = pythonpaste.org docs = docs/index.txt docs/SQLObject.txt docs/TODO.txt Modified: SQLObject/branches/0.8/setup.py =================================================================== --- SQLObject/branches/0.8/setup.py 2007-01-22 13:28:16 UTC (rev 2225) +++ SQLObject/branches/0.8/setup.py 2007-01-22 13:30:00 UTC (rev 2226) @@ -28,7 +28,7 @@ """ setup(name="SQLObject", - version="0.8.0b2", + version="0.8", description="Object-Relational Manager, aka database wrapper", long_description="""\ SQLObject is a popular *Object Relational Manager* for providing an |
|
From: <sub...@co...> - 2007-01-22 13:28:23
|
Author: phd Date: 2007-01-22 06:28:16 -0700 (Mon, 22 Jan 2007) New Revision: 2225 Modified: SQLObject/branches/0.8/setup.cfg SQLObject/branches/0.8/setup.py Log: Version 0.8.0b2 Modified: SQLObject/branches/0.8/setup.cfg =================================================================== --- SQLObject/branches/0.8/setup.cfg 2007-01-22 13:26:50 UTC (rev 2224) +++ SQLObject/branches/0.8/setup.cfg 2007-01-22 13:28:16 UTC (rev 2225) @@ -1,10 +1,6 @@ [easy_install] #find_links = http://svn.pythonpaste.org/package_index.html -[egg_info] -tag_build = dev -tag_svn_revision = true - [pudge] theme = pythonpaste.org docs = docs/index.txt docs/SQLObject.txt docs/TODO.txt Modified: SQLObject/branches/0.8/setup.py =================================================================== --- SQLObject/branches/0.8/setup.py 2007-01-22 13:26:50 UTC (rev 2224) +++ SQLObject/branches/0.8/setup.py 2007-01-22 13:28:16 UTC (rev 2225) @@ -28,7 +28,7 @@ """ setup(name="SQLObject", - version="0.8", + version="0.8.0b2", description="Object-Relational Manager, aka database wrapper", long_description="""\ SQLObject is a popular *Object Relational Manager* for providing an |
|
From: <sub...@co...> - 2007-01-22 13:26:56
|
Author: phd Date: 2007-01-22 06:26:50 -0700 (Mon, 22 Jan 2007) New Revision: 2224 Added: SQLObject/tags/0.8.0b2/ Log: SQLObject 0.8.0b2 Copied: SQLObject/tags/0.8.0b2 (from rev 2223, SQLObject/branches/0.8) |
|
From: <sub...@co...> - 2007-01-22 13:23:53
|
Author: phd Date: 2007-01-22 06:23:48 -0700 (Mon, 22 Jan 2007) New Revision: 2223 Modified: SQLObject/tags/0.7.3b1/setup.cfg Log: Do not add SVN revision. Modified: SQLObject/tags/0.7.3b1/setup.cfg =================================================================== --- SQLObject/tags/0.7.3b1/setup.cfg 2007-01-22 13:14:11 UTC (rev 2222) +++ SQLObject/tags/0.7.3b1/setup.cfg 2007-01-22 13:23:48 UTC (rev 2223) @@ -1,7 +1,3 @@ -[egg_info] -tag_build = a -tag_svn_revision = true - [pudge] title = SQLObject dest = docs/html |
|
From: <sub...@co...> - 2007-01-22 13:14:15
|
Author: phd Date: 2007-01-22 06:14:11 -0700 (Mon, 22 Jan 2007) New Revision: 2222 Modified: SQLObject/branches/0.7-bugfix/docs/News.txt Log: No, it is only "b1". :( Modified: SQLObject/branches/0.7-bugfix/docs/News.txt =================================================================== --- SQLObject/branches/0.7-bugfix/docs/News.txt 2007-01-22 13:13:16 UTC (rev 2221) +++ SQLObject/branches/0.7-bugfix/docs/News.txt 2007-01-22 13:14:11 UTC (rev 2222) @@ -10,8 +10,6 @@ SQLObject 0.7.3 =============== -Released 22 Jan 2007. - Bug Fixes --------- |
|
From: <sub...@co...> - 2007-01-22 13:13:22
|
Author: phd Date: 2007-01-22 06:13:16 -0700 (Mon, 22 Jan 2007) New Revision: 2221 Modified: SQLObject/branches/0.7-bugfix/docs/News.txt Log: Released 22 Jan 2007. Modified: SQLObject/branches/0.7-bugfix/docs/News.txt =================================================================== --- SQLObject/branches/0.7-bugfix/docs/News.txt 2007-01-22 13:12:32 UTC (rev 2220) +++ SQLObject/branches/0.7-bugfix/docs/News.txt 2007-01-22 13:13:16 UTC (rev 2221) @@ -10,6 +10,8 @@ SQLObject 0.7.3 =============== +Released 22 Jan 2007. + Bug Fixes --------- |
|
From: <sub...@co...> - 2007-01-22 13:12:38
|
Author: phd
Date: 2007-01-22 06:12:32 -0700 (Mon, 22 Jan 2007)
New Revision: 2220
Modified:
SQLObject/tags/0.7.3b1/setup.py
Log:
Version 0.7.3b1
Modified: SQLObject/tags/0.7.3b1/setup.py
===================================================================
--- SQLObject/tags/0.7.3b1/setup.py 2007-01-22 13:09:56 UTC (rev 2219)
+++ SQLObject/tags/0.7.3b1/setup.py 2007-01-22 13:12:32 UTC (rev 2220)
@@ -19,7 +19,7 @@
DistributionMetadata.download_url = None
setup(name="SQLObject",
- version="0.7.2",
+ version="0.7.3b1",
description="Object-Relational Manager, aka database wrapper",
long_description="""\
SQLObject is a popular *Object Relational Manager* for providing an
@@ -52,7 +52,7 @@
author="Ian Bicking",
author_email="ia...@co...",
url="http://sqlobject.org",
- download_url="http://cheeseshop.python.org/pypi/SQLObject/0.7.2",
+ download_url="http://cheeseshop.python.org/pypi/SQLObject/0.7.3b1",
license="LGPL",
packages=["sqlobject"] + ['sqlobject.%s' % package for package in subpackages],
scripts=["scripts/sqlobject-admin"],
|
|
From: <sub...@co...> - 2007-01-22 13:10:01
|
Author: phd Date: 2007-01-22 06:09:56 -0700 (Mon, 22 Jan 2007) New Revision: 2219 Removed: SQLObject/tags/0.7.2/0.7-bugfix/ Log: Removed wrong directory |
|
From: <sub...@co...> - 2007-01-22 13:09:21
|
Author: phd Date: 2007-01-22 06:09:13 -0700 (Mon, 22 Jan 2007) New Revision: 2218 Added: SQLObject/tags/0.7.3b1/ Log: SQLObject 0.7.3b1 Copied: SQLObject/tags/0.7.3b1 (from rev 2217, SQLObject/branches/0.7-bugfix) |
|
From: SourceForge.net <no...@so...> - 2007-01-20 20:14:11
|
Bugs item #1640436, was opened at 2007-01-20 21:14 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=1640436&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: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Private: No Submitted By: Daniel Nogradi (nogradi) Assigned to: Nobody/Anonymous (nobody) Summary: order by several columns and inheritance Initial Comment: I've checked the following with sqlite only. SQLObject version: 0.8.0b1 Sql query generation is broken when using several columns as orderBy keyword argument and inherited classes: --------------------------------------------------------------- class parent( InheritableSQLObject ): pass class t( parent ): c = IntCol( ) d = IntCol( ) --------------------------------------------------------------- Using a single orderBy column works: --------------------------------------------------------------- for i in t.select( orderBy=t.q.d ): print i SELECT parent.id, parent.child_name FROM t, parent WHERE (((parent.child_name) = ('t')) AND ((t.id) = (parent.id))) ORDER BY t.d SELECT t.id, t.c, t.d, t.child_name FROM t WHERE ((t.id) = (1)) ---------------------------------------------------------------- but multiple orderBy columns throw an exception in the first query: ---------------------------------------------------------------- for i in t.select( orderBy=( t.q.c, t.q.d ) ): print i SELECT parent.id, parent.child_name FROM parent WHERE ((parent.child_name) = ('t')) ORDER BY t.c, t.d sqlobject.dberrors.OperationalError: no such column: t.c ----------------------------------------------------------------- And it seems that the problem is that the query doesn't have "FROM t, parent" only "FROM parent" (among other things) while in the first case (only one orderBy column) the query was generated correctly. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1640436&group_id=74338 |
|
From: <sub...@co...> - 2007-01-17 14:57:59
|
Author: phd
Date: 2007-01-17 07:57:43 -0700 (Wed, 17 Jan 2007)
New Revision: 2216
Removed:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_encapsulate_hiding.py
Modified:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
home/phd/SQLObject/paramstyles/sqlobject/main.py
home/phd/SQLObject/paramstyles/sqlobject/versioning/test/test_version.py
Log:
Merged patches from the revisions 2213:2215 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2007-01-17 14:56:19 UTC (rev 2215)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2007-01-17 14:57:43 UTC (rev 2216)
@@ -1,6 +1,6 @@
from sqlobject import sqlbuilder
from sqlobject import classregistry
-from sqlobject.col import StringCol, ForeignKey, BoolCol
+from sqlobject.col import StringCol, ForeignKey
from sqlobject.main import sqlmeta, SQLObject, SelectResults, True, False, \
makeProperties, getterName, setterName
import iteration
@@ -63,12 +63,6 @@
parentClause.append(currentClass.q.id == parentClass.q.id)
currentClass = parentClass
tablesDict[currentClass.sqlmeta.table] = 1
-
- for (currentClass, minParentClass) in tableRegistry.items():
- if InheritableSQLObject in minParentClass.__bases__:
- parentClause.append(minParentClass.q.doneConstructing == True)
- break
-
clause = reduce(sqlbuilder.AND, parentClause, clause)
super(InheritableSelectResults, self).__init__(sourceClass,
@@ -198,7 +192,7 @@
currentClass = cls.sqlmeta.parentClass
while currentClass:
for column in currentClass.sqlmeta.columnDefinitions.values():
- if column.name == 'doneConstructing' or column.name == 'childName':
+ if column.name == 'childName':
continue
if type(column) == ForeignKey:
continue
@@ -296,12 +290,6 @@
sqlmeta.addColumn(StringCol(name='childName',
# limit string length to get VARCHAR and not CLOB
length=255, default=None))
-
- #only on top-level classes
- if InheritableSQLObject in cls.__bases__:
- #add the doneConstructing column to make half-constructed tasks invisible
- sqlmeta.addColumn(BoolCol(name='doneConstructing', default=False))
-
if not sqlmeta.columnList:
# There are no columns - call addColumn to propagate columns
# from parent classes to children
@@ -312,7 +300,7 @@
sqlmeta.addJoin(None)
_notifyFinishClassCreation = classmethod(_notifyFinishClassCreation)
- def _create(self, id, last_derived=False, **kw):
+ def _create(self, id, **kw):
#DSM: If we were called by a children class,
#DSM: we must retreive the properties dictionary.
@@ -343,7 +331,7 @@
raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name)
parent_kw['childName'] = self.sqlmeta.childName
- self._parent = parentClass(last_derived=False, kw=parent_kw,
+ self._parent = parentClass(kw=parent_kw,
connection=self._connection)
id = self._parent.id
Deleted: home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_encapsulate_hiding.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_encapsulate_hiding.py 2007-01-17 14:56:19 UTC (rev 2215)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_encapsulate_hiding.py 2007-01-17 14:57:43 UTC (rev 2216)
@@ -1,48 +0,0 @@
-from py.test import raises
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-from sqlobject.inheritance import InheritableSQLObject
-
-def first_position():
- employees = Employee.select()
- if employees.count():
- return employees[0].position
- else:
- return "Lackey"
-
-def first_floor():
- janitors = Janitor.select()
- if janitors.count():
- return janitors[0].floor
- else:
- return 0
-
-
-class InheritablePerson(InheritableSQLObject):
- firstName = StringCol()
- lastName = StringCol(alternateID=True, length=255)
-
-class Employee(InheritablePerson):
- position = StringCol(default=first_position)
-
-class Janitor(Employee):
- _inheritable = False
- floor = IntCol(default=first_floor)
-
-def setup():
- setupClass(InheritablePerson)
- setupClass(Employee)
- setupClass(Janitor)
-
-def test_liveness():
-
- setup()
- emp = Employee(firstName='Igor', lastName='Humpback')
- assert emp.position == "Lackey"
- emp.position = "Grunt"
-
- emp = Employee(firstName='Frank', lastName='Furter')
- assert emp.position == "Grunt"
-
- jan = Janitor(firstName="George", lastName="Bush")
- assert jan.floor == 0
Modified: home/phd/SQLObject/paramstyles/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-01-17 14:56:19 UTC (rev 2215)
+++ home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-01-17 14:57:43 UTC (rev 2216)
@@ -1203,7 +1203,7 @@
else:
return joinClass.get(id)
- def __init__(self, last_derived = True, **kw):
+ def __init__(self, **kw):
# We shadow the sqlmeta class with an instance of sqlmeta
# that points to us (our sqlmeta buddy object; where the
# sqlmeta class is our class's buddy class)
@@ -1231,15 +1231,12 @@
else:
id = None
- self._create(id, last_derived=False, **kw)
-
- if last_derived and hasattr(self, 'doneConstructing'):
- self.doneConstructing = True
-
+ self._create(id, **kw)
for func in post_funcs:
func(self)
- def _create(self, id, last_derived=False,**kw):
+ def _create(self, id, **kw):
+
self.sqlmeta._creating = True
self._SO_createValues = {}
self._SO_validatorState = SQLObjectState(self)
Modified: home/phd/SQLObject/paramstyles/sqlobject/versioning/test/test_version.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/versioning/test/test_version.py 2007-01-17 14:56:19 UTC (rev 2215)
+++ home/phd/SQLObject/paramstyles/sqlobject/versioning/test/test_version.py 2007-01-17 14:57:43 UTC (rev 2216)
@@ -48,7 +48,12 @@
def setup():
- for cls in [MyClass, Base, Child, Government, Monarchy, VChild, HasForeign, Extra]:
+ classes = [MyClass, Base, Child, Government, Monarchy, VChild, Extra]
+ if hasattr(HasForeign, "_connection"):
+ classes.insert(0, HasForeign)
+ else:
+ classes.append(HasForeign)
+ for cls in classes:
if hasattr(cls, 'versions') and hasattr(cls, "_connection") and \
cls._connection.tableExists(cls.sqlmeta.table):
setupClass(cls.versions.versionClass)
|
|
From: <sub...@co...> - 2007-01-17 14:56:34
|
Author: phd
Date: 2007-01-17 07:56:19 -0700 (Wed, 17 Jan 2007)
New Revision: 2215
Modified:
SQLObject/trunk/sqlobject/versioning/test/test_version.py
Log:
Create HasForeign after the Base, but clear it before -
req-d for databases with strict referential integrity.
Modified: SQLObject/trunk/sqlobject/versioning/test/test_version.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-17 14:52:24 UTC (rev 2214)
+++ SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-17 14:56:19 UTC (rev 2215)
@@ -48,7 +48,12 @@
def setup():
- for cls in [MyClass, Base, Child, Government, Monarchy, VChild, HasForeign, Extra]:
+ classes = [MyClass, Base, Child, Government, Monarchy, VChild, Extra]
+ if hasattr(HasForeign, "_connection"):
+ classes.insert(0, HasForeign)
+ else:
+ classes.append(HasForeign)
+ for cls in classes:
if hasattr(cls, 'versions') and hasattr(cls, "_connection") and \
cls._connection.tableExists(cls.sqlmeta.table):
setupClass(cls.versions.versionClass)
|
|
From: <sub...@co...> - 2007-01-17 14:52:38
|
Author: phd
Date: 2007-01-17 07:52:24 -0700 (Wed, 17 Jan 2007)
New Revision: 2214
Removed:
SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py
Modified:
SQLObject/trunk/sqlobject/inheritance/__init__.py
SQLObject/trunk/sqlobject/main.py
Log:
Reverted "prevent half-constructed rows" patch.
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-01-16 14:20:47 UTC (rev 2213)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-01-17 14:52:24 UTC (rev 2214)
@@ -1,6 +1,6 @@
from sqlobject import sqlbuilder
from sqlobject import classregistry
-from sqlobject.col import StringCol, ForeignKey, BoolCol
+from sqlobject.col import StringCol, ForeignKey
from sqlobject.main import sqlmeta, SQLObject, SelectResults, True, False, \
makeProperties, getterName, setterName
import iteration
@@ -63,12 +63,6 @@
parentClause.append(currentClass.q.id == parentClass.q.id)
currentClass = parentClass
tablesDict[currentClass.sqlmeta.table] = 1
-
- for (currentClass, minParentClass) in tableRegistry.items():
- if InheritableSQLObject in minParentClass.__bases__:
- parentClause.append(minParentClass.q.doneConstructing == True)
- break
-
clause = reduce(sqlbuilder.AND, parentClause, clause)
super(InheritableSelectResults, self).__init__(sourceClass,
@@ -198,7 +192,7 @@
currentClass = cls.sqlmeta.parentClass
while currentClass:
for column in currentClass.sqlmeta.columnDefinitions.values():
- if column.name == 'doneConstructing' or column.name == 'childName':
+ if column.name == 'childName':
continue
if type(column) == ForeignKey:
continue
@@ -296,12 +290,6 @@
sqlmeta.addColumn(StringCol(name='childName',
# limit string length to get VARCHAR and not CLOB
length=255, default=None))
-
- #only on top-level classes
- if InheritableSQLObject in cls.__bases__:
- #add the doneConstructing column to make half-constructed tasks invisible
- sqlmeta.addColumn(BoolCol(name='doneConstructing', default=False))
-
if not sqlmeta.columnList:
# There are no columns - call addColumn to propagate columns
# from parent classes to children
@@ -312,7 +300,7 @@
sqlmeta.addJoin(None)
_notifyFinishClassCreation = classmethod(_notifyFinishClassCreation)
- def _create(self, id, last_derived=False, **kw):
+ def _create(self, id, **kw):
#DSM: If we were called by a children class,
#DSM: we must retreive the properties dictionary.
@@ -343,7 +331,7 @@
raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name)
parent_kw['childName'] = self.sqlmeta.childName
- self._parent = parentClass(last_derived=False, kw=parent_kw,
+ self._parent = parentClass(kw=parent_kw,
connection=self._connection)
id = self._parent.id
Deleted: SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py 2007-01-16 14:20:47 UTC (rev 2213)
+++ SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py 2007-01-17 14:52:24 UTC (rev 2214)
@@ -1,48 +0,0 @@
-from py.test import raises
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-from sqlobject.inheritance import InheritableSQLObject
-
-def first_position():
- employees = Employee.select()
- if employees.count():
- return employees[0].position
- else:
- return "Lackey"
-
-def first_floor():
- janitors = Janitor.select()
- if janitors.count():
- return janitors[0].floor
- else:
- return 0
-
-
-class InheritablePerson(InheritableSQLObject):
- firstName = StringCol()
- lastName = StringCol(alternateID=True, length=255)
-
-class Employee(InheritablePerson):
- position = StringCol(default=first_position)
-
-class Janitor(Employee):
- _inheritable = False
- floor = IntCol(default=first_floor)
-
-def setup():
- setupClass(InheritablePerson)
- setupClass(Employee)
- setupClass(Janitor)
-
-def test_liveness():
-
- setup()
- emp = Employee(firstName='Igor', lastName='Humpback')
- assert emp.position == "Lackey"
- emp.position = "Grunt"
-
- emp = Employee(firstName='Frank', lastName='Furter')
- assert emp.position == "Grunt"
-
- jan = Janitor(firstName="George", lastName="Bush")
- assert jan.floor == 0
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2007-01-16 14:20:47 UTC (rev 2213)
+++ SQLObject/trunk/sqlobject/main.py 2007-01-17 14:52:24 UTC (rev 2214)
@@ -1203,7 +1203,7 @@
else:
return joinClass.get(id)
- def __init__(self, last_derived = True, **kw):
+ def __init__(self, **kw):
# We shadow the sqlmeta class with an instance of sqlmeta
# that points to us (our sqlmeta buddy object; where the
# sqlmeta class is our class's buddy class)
@@ -1231,15 +1231,12 @@
else:
id = None
- self._create(id, last_derived=False, **kw)
-
- if last_derived and hasattr(self, 'doneConstructing'):
- self.doneConstructing = True
-
+ self._create(id, **kw)
for func in post_funcs:
func(self)
- def _create(self, id, last_derived=False,**kw):
+ def _create(self, id, **kw):
+
self.sqlmeta._creating = True
self._SO_createValues = {}
self._SO_validatorState = SQLObjectState(self)
|