sqlobject-cvs Mailing List for SQLObject (Page 115)
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: Issac D. <deb...@bo...> - 2006-11-02 07:31:00
|
Great volume in the last couple days has sent our feature way up, and the big press release isn't even out yet! The internal scoop is that we are looking at record earnings! Tomorrow, November 2nd is going to be the last chance to take profit of this incredible information. Current: O.69 (+13%) Insiders accumulating? Projected: 1.3O Rating: 5/5 Ever Glory International (EGLY) is involved in one of the most lucrative areas of business these days, manufacture in China. Quarter after quarter they show themselves as one of the top businesses in their sector. Some recent quarterly postings: $1 mil Profit in the first quarter $778 k Profit in the second quarter August 8th - $2 mil order from Matalan July 25th - $500 k order from Debenhams July 10th - $1 mil order from OTTO Please check all these figures with your favorite source. EGLY is the great deal! We are expecting third quarter numbers to be out soon and are telling all of our members to take a position in EGLY before the data hits the street. These fortuitous figures are going to shock the market and send this one way up! Give yourself the chance to come out WAY ahead here. Fortune favors the bold! also news is WASHINGTON (AP) -- A salmonella outbreak that sickened dozens of people in 19 states appears to be over, while investigators remain unsure how it began, a federal official said Tuesday. (CNN) -- After a nearly 20-year absence, Nixon-loving, Reagan-worshipping Alex P. Keaton is again slinging his political views on television. WASHINGTON (AP) -- Huge amounts of a red wine extract seemed to help obese mice eat a high-fat diet and still live a long and healthy life, suggests a new study that some experts are calling "landmark" research. TEHRAN, Iran (AP) -- Iran will offer cash incentives to travel agencies to encourage Western tourists to visit the country, giving a premium for Americans, the official Islamic Republic News Agency reported. |
|
From: Everett F. <deb...@bo...> - 2006-11-01 08:16:54
|
In business theres no word more powerful than the word. And what is the word? P-R-O-F-I-T!!! And thats what our next feature is all about. EverGlory International (EGLY) is involved in one of the most lucrative areas of business these days, production in China. Quarter after quarter they get to use the word in BIG ways! Some recent quarterly postings: 1mil$ P-R-O-F-I-T in the first quarter 778k$ P-R-O-F-I-T in the second quarter August 8th 2mil$ order from Matalan July 25th 500k$ order from Debenhams July 10th - 1mil$ order from OTTO Please check all these figures with your favorite source. EGLY is the real deal! We are expecting third quarter numbers to be out soon and are telling all of our members to take a position in EGLY before the data is out. These fortuitous figures are going to shock the market and send this one way up! Current: 0.68 Projected: 1.30 Rating: 5/5 Inve st date: Wednesday, 1 oct 2006. Call your broker now. Give yourself the chance to come out WAY ahead here. Fortune favors the bold! -- NEW YORK (CNNMoney.com) -- The threat to Big Pharma is real - the nation's drugmakers stand to lose nearly seven percent of their sales to drugs going off patent this year - and more CEOs who don't get ahead of the problem could end up losing their jobs. WASHINGTON (AP) -- President Bush on Tuesday welcomed an agreement to bring North Korea back to six-party arms talks and said the United States will insist the communist regime abandon its nuclear weapons program in a verifiable fashion. |
|
From: <sub...@co...> - 2006-10-31 17:49:35
|
Author: phd
Date: 2006-10-31 10:49:33 -0700 (Tue, 31 Oct 2006)
New Revision: 2062
Modified:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
Log:
Merged patches from the revisions 2058:2061 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2006-10-31 17:44:48 UTC (rev 2061)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2006-10-31 17:49:33 UTC (rev 2062)
@@ -38,18 +38,21 @@
if registryClass.sqlmeta.table in tablesDict:
#DSM: By default, no parents are needed for the clauses
tableRegistry[registryClass] = registryClass
- for registryClass in allClasses:
- if registryClass.sqlmeta.table in tablesDict:
- currentClass = registryClass.sqlmeta.parentClass
- while currentClass:
- if tableRegistry.has_key(currentClass):
- #DSM: Must keep the last parent needed
- #DSM: (to limit the number of join needed)
- tableRegistry[registryClass] = currentClass
+ tableRegistryCopy = tableRegistry.copy()
+ for childClass in tableRegistryCopy:
+ if childClass not in tableRegistry:
+ continue
+ currentClass = childClass
+ while currentClass:
+ if tableRegistryCopy.has_key(currentClass):
+ if currentClass in tableRegistry:
#DSM: Remove this class as it is a parent one
#DSM: of a needed children
del tableRegistry[currentClass]
- currentClass = currentClass.sqlmeta.parentClass
+ #DSM: Must keep the last parent needed
+ #DSM: (to limit the number of join needed)
+ tableRegistry[childClass] = currentClass
+ currentClass = currentClass.sqlmeta.parentClass
#DSM: Table registry contains only the last children
#DSM: or standalone classes
parentClause = []
|
|
From: <sub...@co...> - 2006-10-31 17:44:49
|
Author: phd
Date: 2006-10-31 10:44:48 -0700 (Tue, 31 Oct 2006)
New Revision: 2061
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py
Log:
A bugfix by Raphael Derosso Pereira <rap...@gm...> for a bug in InheritableSQLObject
related to the order of tableRegistry dictionary.
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-31 17:44:30 UTC (rev 2060)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-31 17:44:48 UTC (rev 2061)
@@ -15,11 +15,14 @@
* Fixed a number of unicode-related problems with newer MySQLdb.
+* If the DB API driver returns timedelta instead of time (MySQLdb does
+ this) it is converted to time; but if the timedelta has days an exception
+ is raised.
+
* Fixed a number of bugs in InheritableSQLObject related to foreign keys.
-* If the DB API driver returns timedelta instead of time (MySQLdb sometimes
- does this) it is converted to time; but if the timedelta has days an
- exception is raised.
+* Fixed a bug in InheritableSQLObject related to the order of tableRegistry
+ dictionary.
SQLObject 0.7.1
===============
Modified: SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py 2006-10-31 17:44:30 UTC (rev 2060)
+++ SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py 2006-10-31 17:44:48 UTC (rev 2061)
@@ -38,18 +38,21 @@
if registryClass.sqlmeta.table in tablesDict:
#DSM: By default, no parents are needed for the clauses
tableRegistry[registryClass] = registryClass
- for registryClass in allClasses:
- if registryClass.sqlmeta.table in tablesDict:
- currentClass = registryClass
- while currentClass._parentClass:
- currentClass = currentClass._parentClass
- if tableRegistry.has_key(currentClass):
- #DSM: Must keep the last parent needed
- #DSM: (to limit the number of join needed)
- tableRegistry[registryClass] = currentClass
+ tableRegistryCopy = tableRegistry.copy()
+ for childClass in tableRegistryCopy:
+ if childClass not in tableRegistry:
+ continue
+ currentClass = childClass
+ while currentClass:
+ if tableRegistryCopy.has_key(currentClass):
+ if currentClass in tableRegistry:
#DSM: Remove this class as it is a parent one
#DSM: of a needed children
del tableRegistry[currentClass]
+ #DSM: Must keep the last parent needed
+ #DSM: (to limit the number of join needed)
+ tableRegistry[childClass] = currentClass
+ currentClass = currentClass._parentClass
#DSM: Table registry contains only the last children
#DSM: or standalone classes
parentClause = []
|
|
From: <sub...@co...> - 2006-10-31 17:44:31
|
Author: phd Date: 2006-10-31 10:44:30 -0700 (Tue, 31 Oct 2006) New Revision: 2060 Modified: SQLObject/docs/News.txt Log: A bugfix by Raphael Derosso Pereira <rap...@gm...> for a bug in InheritableSQLObject related to the order of tableRegistry dictionary. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2006-10-31 17:44:01 UTC (rev 2059) +++ SQLObject/docs/News.txt 2006-10-31 17:44:30 UTC (rev 2060) @@ -99,11 +99,14 @@ * Fixed a number of unicode-related problems with newer MySQLdb. +* If the DB API driver returns timedelta instead of time (MySQLdb does + this) it is converted to time; but if the timedelta has days an exception + is raised. + * Fixed a number of bugs in InheritableSQLObject related to foreign keys. -* If the DB API driver returns timedelta instead of time (MySQLdb sometimes - does this) it is converted to time; but if the timedelta has days an - exception is raised. +* Fixed a bug in InheritableSQLObject related to the order of tableRegistry + dictionary. SQLObject 0.7.1 =============== |
|
From: <sub...@co...> - 2006-10-31 17:44:09
|
Author: phd
Date: 2006-10-31 10:44:01 -0700 (Tue, 31 Oct 2006)
New Revision: 2059
Modified:
SQLObject/trunk/sqlobject/inheritance/__init__.py
Log:
A bugfix by Raphael Derosso Pereira <rap...@gm...> for a bug in InheritableSQLObject
related to the order of tableRegistry dictionary.
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2006-10-31 10:19:15 UTC (rev 2058)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2006-10-31 17:44:01 UTC (rev 2059)
@@ -38,18 +38,21 @@
if registryClass.sqlmeta.table in tablesDict:
#DSM: By default, no parents are needed for the clauses
tableRegistry[registryClass] = registryClass
- for registryClass in allClasses:
- if registryClass.sqlmeta.table in tablesDict:
- currentClass = registryClass.sqlmeta.parentClass
- while currentClass:
- if tableRegistry.has_key(currentClass):
- #DSM: Must keep the last parent needed
- #DSM: (to limit the number of join needed)
- tableRegistry[registryClass] = currentClass
+ tableRegistryCopy = tableRegistry.copy()
+ for childClass in tableRegistryCopy:
+ if childClass not in tableRegistry:
+ continue
+ currentClass = childClass
+ while currentClass:
+ if tableRegistryCopy.has_key(currentClass):
+ if currentClass in tableRegistry:
#DSM: Remove this class as it is a parent one
#DSM: of a needed children
del tableRegistry[currentClass]
- currentClass = currentClass.sqlmeta.parentClass
+ #DSM: Must keep the last parent needed
+ #DSM: (to limit the number of join needed)
+ tableRegistry[childClass] = currentClass
+ currentClass = currentClass.sqlmeta.parentClass
#DSM: Table registry contains only the last children
#DSM: or standalone classes
parentClause = []
|
|
From: SourceForge.net <no...@so...> - 2006-10-31 16:39:40
|
Patches item #1576143, was opened at 2006-10-12 23:18 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1576143&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: Fixed Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Oleg Broytmann (phd) Summary: Bug in handling of non default foreign key values Initial Comment: se: http://trac.turbogears.org/turbogears/ticket/1139 for bug description and patch. Thanks, Tormod Ravnanger Landet ---------------------------------------------------------------------- Comment By: Tormod R Landet (trlandet) Date: 2006-10-27 02:34 Message: Logged In: YES user_id=1631055 Fix: change the file sqlobject.inheritance.init line 218 from: if col._default == sqlbuilder.NoDefault and col.name not in kw: to: if col._default == sqlbuilder.NoDefault and col.name not in kw and (col.foreignName is None or col.foreignName not in kw): ---------------------------------------------------------------------- Comment By: Tormod R Landet (trlandet) Date: 2006-10-27 02:31 Message: Logged In: YES user_id=1631055 Seems there is a problem adding files Testcase to show the bug: from sqlobject import * from sqlobject.inheritance import InheritableSQLObject class Base(InheritableSQLObject): pass class File(SQLObject): pass class MyClass(Base): aFile = ForeignKey("Base") otherFile = ForeignKey("Base", default=None) sqlhub.processConnection = connectionForURI('sqlite:/:memory:') Base.createTable() File.createTable() MyClass.createTable() file1 = File() file2 = File() print MyClass.sqlmeta.columnList # [<SOStringCol childName default=None>, <SOForeignKey aFileID connected to Base>, <SOForeignKey otherFileID default=None connected to Base>] object = MyClass(aFile=file1, otherFile=file2) # Traceback (most recent call last): # File "/home/landet/work/eclipseworkspace/Diverse Pythonscript/src/SQLObject_bugfixing/case.py", line 23, in ? # object = MyClass(aFile=file1, otherFile=file2) # File "/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/declarative.py", line 93, in _wrapper # return fn(self, *args, **kwargs) # File "/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/main.py", line 1198, in __init__ # self._create(id, **kw) # File "/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/inheritance/__init__.py", line 219, in _create # raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name) # TypeError: MyClass() did not get expected keyword argument aFileID ---------------------------------------------------------------------- Comment By: Tormod R Landet (trlandet) Date: 2006-10-27 02:27 Message: Logged In: YES user_id=1631055 Adding testcase ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1576143&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-10-31 16:39:19
|
Patches item #1576143, was opened at 2006-10-12 23:18 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1576143&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: Fixed Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) >Assigned to: Oleg Broytmann (phd) Summary: Bug in handling of non default foreign key values Initial Comment: se: http://trac.turbogears.org/turbogears/ticket/1139 for bug description and patch. Thanks, Tormod Ravnanger Landet ---------------------------------------------------------------------- Comment By: Tormod R Landet (trlandet) Date: 2006-10-27 02:34 Message: Logged In: YES user_id=1631055 Fix: change the file sqlobject.inheritance.init line 218 from: if col._default == sqlbuilder.NoDefault and col.name not in kw: to: if col._default == sqlbuilder.NoDefault and col.name not in kw and (col.foreignName is None or col.foreignName not in kw): ---------------------------------------------------------------------- Comment By: Tormod R Landet (trlandet) Date: 2006-10-27 02:31 Message: Logged In: YES user_id=1631055 Seems there is a problem adding files Testcase to show the bug: from sqlobject import * from sqlobject.inheritance import InheritableSQLObject class Base(InheritableSQLObject): pass class File(SQLObject): pass class MyClass(Base): aFile = ForeignKey("Base") otherFile = ForeignKey("Base", default=None) sqlhub.processConnection = connectionForURI('sqlite:/:memory:') Base.createTable() File.createTable() MyClass.createTable() file1 = File() file2 = File() print MyClass.sqlmeta.columnList # [<SOStringCol childName default=None>, <SOForeignKey aFileID connected to Base>, <SOForeignKey otherFileID default=None connected to Base>] object = MyClass(aFile=file1, otherFile=file2) # Traceback (most recent call last): # File "/home/landet/work/eclipseworkspace/Diverse Pythonscript/src/SQLObject_bugfixing/case.py", line 23, in ? # object = MyClass(aFile=file1, otherFile=file2) # File "/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/declarative.py", line 93, in _wrapper # return fn(self, *args, **kwargs) # File "/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/main.py", line 1198, in __init__ # self._create(id, **kw) # File "/home/landet/lib/python-2.4/SQLObject-0.7.1-py2.4.egg/sqlobject/inheritance/__init__.py", line 219, in _create # raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name) # TypeError: MyClass() did not get expected keyword argument aFileID ---------------------------------------------------------------------- Comment By: Tormod R Landet (trlandet) Date: 2006-10-27 02:27 Message: Logged In: YES user_id=1631055 Adding testcase ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1576143&group_id=74338 |
|
From: <sub...@co...> - 2006-10-30 19:49:10
|
Author: phd
Date: 2006-10-30 12:49:05 -0700 (Mon, 30 Oct 2006)
New Revision: 2055
Removed:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py
Log:
Renamed test_inherited_foreignKey.py to test_foreignKey.py.
Deleted: home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:47:57 UTC (rev 2054)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:49:05 UTC (rev 2055)
@@ -1,85 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-from sqlobject.inheritance import InheritableSQLObject
-
-
-class Note(SQLObject):
- text = StringCol()
-
-class PersonWithNotes(InheritableSQLObject):
- firstName = StringCol()
- lastName = StringCol()
- note = ForeignKey("Note", default=None)
-
-class Paper(SQLObject):
- content = StringCol()
-
-class EmployeeWithNotes(PersonWithNotes):
- _inheritable = False
- paper = ForeignKey("Paper", default=None)
-
-def test_foreignKey():
- setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
-
- note = Note(text="person")
- PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
- note = Note(text="employee")
- EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
-
- paper = Paper(content="secret")
- EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
- PersonWithNotes(firstName='Some', lastName='Person')
-
-
- person = PersonWithNotes.get(1)
- assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
- assert person.note.text == "person"
-
- employee = EmployeeWithNotes.get(2)
- assert isinstance(employee, EmployeeWithNotes)
- assert employee.note.text == "employee"
- save_employee = employee
-
- persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
- assert persons.count() == 2
-
- persons = PersonWithNotes.selectBy(noteID=person.note.id)
- assert persons.count() == 1
-
- employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
- assert employee.count() == 1
-
- persons = PersonWithNotes.selectBy(noteID=person.note.id)
- assert persons.count() == 1
-
- persons = PersonWithNotes.selectBy(note=person.note)
- assert persons.count() == 1
-
- persons = PersonWithNotes.selectBy(note=None)
- assert persons.count() == 2
-
- employee = EmployeeWithNotes.selectBy(paperID=None)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy(paper=None)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy(note=save_employee.note,
- paper=save_employee.paper)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy()
- assert employee.count() == 2
-
-
-class TestInheritableBase(InheritableSQLObject):
- pass
-
-class TestInheritableForeignKey(TestInheritableBase):
- base = ForeignKey("TestInheritableBase")
-
-def test_foreignKey2():
- setupClass([TestInheritableBase, TestInheritableForeignKey])
-
- test = TestInheritableBase()
- object = TestInheritableForeignKey(base=test)
|
|
From: <sub...@co...> - 2006-10-30 19:48:11
|
Author: phd
Date: 2006-10-30 12:47:57 -0700 (Mon, 30 Oct 2006)
New Revision: 2054
Added:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_foreignKey.py
Modified:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py
Log:
Merged patches from the revisions 2048:2053 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2006-10-30 19:45:58 UTC (rev 2053)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2006-10-30 19:47:57 UTC (rev 2054)
@@ -308,7 +308,8 @@
# create the current subclass otherwise we will leave
# the database in an inconsistent state.
for col in self.sqlmeta.columnList:
- if col._default == sqlbuilder.NoDefault and col.name not in kw:
+ if (col._default == sqlbuilder.NoDefault) and \
+ (col.name not in kw) and (col.foreignName not in kw):
raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name)
parent_kw['childName'] = self.sqlmeta.childName
Copied: home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_foreignKey.py (from rev 2053, SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py)
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_foreignKey.py (rev 0)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_foreignKey.py 2006-10-30 19:47:57 UTC (rev 2054)
@@ -0,0 +1,85 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+
+class Note(SQLObject):
+ text = StringCol()
+
+class PersonWithNotes(InheritableSQLObject):
+ firstName = StringCol()
+ lastName = StringCol()
+ note = ForeignKey("Note", default=None)
+
+class Paper(SQLObject):
+ content = StringCol()
+
+class EmployeeWithNotes(PersonWithNotes):
+ _inheritable = False
+ paper = ForeignKey("Paper", default=None)
+
+def test_foreignKey():
+ setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
+
+ note = Note(text="person")
+ PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
+ note = Note(text="employee")
+ EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
+
+ paper = Paper(content="secret")
+ EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
+ PersonWithNotes(firstName='Some', lastName='Person')
+
+
+ person = PersonWithNotes.get(1)
+ assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
+ assert person.note.text == "person"
+
+ employee = EmployeeWithNotes.get(2)
+ assert isinstance(employee, EmployeeWithNotes)
+ assert employee.note.text == "employee"
+ save_employee = employee
+
+ persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert persons.count() == 2
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert employee.count() == 1
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=person.note)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=None)
+ assert persons.count() == 2
+
+ employee = EmployeeWithNotes.selectBy(paperID=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(paper=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(note=save_employee.note,
+ paper=save_employee.paper)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy()
+ assert employee.count() == 2
+
+
+class TestInheritableBase(InheritableSQLObject):
+ pass
+
+class TestInheritableForeignKey(TestInheritableBase):
+ base = ForeignKey("TestInheritableBase")
+
+def test_foreignKey2():
+ setupClass([TestInheritableBase, TestInheritableForeignKey])
+
+ test = TestInheritableBase()
+ object = TestInheritableForeignKey(base=test)
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:45:58 UTC (rev 2053)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:47:57 UTC (rev 2054)
@@ -18,11 +18,8 @@
_inheritable = False
paper = ForeignKey("Paper", default=None)
-def setup():
- setupClass(Note)
- setupClass(PersonWithNotes)
- setupClass(Paper)
- setupClass(EmployeeWithNotes)
+def test_foreignKey():
+ setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
note = Note(text="person")
PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
@@ -33,8 +30,6 @@
EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
PersonWithNotes(firstName='Some', lastName='Person')
-def test_inheritance():
- setup()
person = PersonWithNotes.get(1)
assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
@@ -75,3 +70,16 @@
employee = EmployeeWithNotes.selectBy()
assert employee.count() == 2
+
+
+class TestInheritableBase(InheritableSQLObject):
+ pass
+
+class TestInheritableForeignKey(TestInheritableBase):
+ base = ForeignKey("TestInheritableBase")
+
+def test_foreignKey2():
+ setupClass([TestInheritableBase, TestInheritableForeignKey])
+
+ test = TestInheritableBase()
+ object = TestInheritableForeignKey(base=test)
|
|
From: <sub...@co...> - 2006-10-30 19:46:06
|
Author: phd
Date: 2006-10-30 12:45:58 -0700 (Mon, 30 Oct 2006)
New Revision: 2053
Added:
SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_foreignKey.py
Removed:
SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py
Log:
Renamed test_inherited_foreignKey.py to test_foreignKey.py.
Copied: SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_foreignKey.py (from rev 2051, SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py)
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_foreignKey.py (rev 0)
+++ SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_foreignKey.py 2006-10-30 19:45:58 UTC (rev 2053)
@@ -0,0 +1,85 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+
+class Note(SQLObject):
+ text = StringCol()
+
+class PersonWithNotes(InheritableSQLObject):
+ firstName = StringCol()
+ lastName = StringCol()
+ note = ForeignKey("Note", default=None)
+
+class Paper(SQLObject):
+ content = StringCol()
+
+class EmployeeWithNotes(PersonWithNotes):
+ _inheritable = False
+ paper = ForeignKey("Paper", default=None)
+
+def test_foreignKey():
+ setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
+
+ note = Note(text="person")
+ PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
+ note = Note(text="employee")
+ EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
+
+ paper = Paper(content="secret")
+ EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
+ PersonWithNotes(firstName='Some', lastName='Person')
+
+
+ person = PersonWithNotes.get(1)
+ assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
+ assert person.note.text == "person"
+
+ employee = EmployeeWithNotes.get(2)
+ assert isinstance(employee, EmployeeWithNotes)
+ assert employee.note.text == "employee"
+ save_employee = employee
+
+ persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert persons.count() == 2
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert employee.count() == 1
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=person.note)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=None)
+ assert persons.count() == 2
+
+ employee = EmployeeWithNotes.selectBy(paperID=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(paper=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(note=save_employee.note,
+ paper=save_employee.paper)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy()
+ assert employee.count() == 2
+
+
+class TestInheritableBase(InheritableSQLObject):
+ pass
+
+class TestInheritableForeignKey(TestInheritableBase):
+ base = ForeignKey("TestInheritableBase")
+
+def test_foreignKey2():
+ setupClass([TestInheritableBase, TestInheritableForeignKey])
+
+ test = TestInheritableBase()
+ object = TestInheritableForeignKey(base=test)
Deleted: SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:45:28 UTC (rev 2052)
+++ SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:45:58 UTC (rev 2053)
@@ -1,85 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-from sqlobject.inheritance import InheritableSQLObject
-
-
-class Note(SQLObject):
- text = StringCol()
-
-class PersonWithNotes(InheritableSQLObject):
- firstName = StringCol()
- lastName = StringCol()
- note = ForeignKey("Note", default=None)
-
-class Paper(SQLObject):
- content = StringCol()
-
-class EmployeeWithNotes(PersonWithNotes):
- _inheritable = False
- paper = ForeignKey("Paper", default=None)
-
-def test_foreignKey():
- setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
-
- note = Note(text="person")
- PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
- note = Note(text="employee")
- EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
-
- paper = Paper(content="secret")
- EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
- PersonWithNotes(firstName='Some', lastName='Person')
-
-
- person = PersonWithNotes.get(1)
- assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
- assert person.note.text == "person"
-
- employee = EmployeeWithNotes.get(2)
- assert isinstance(employee, EmployeeWithNotes)
- assert employee.note.text == "employee"
- save_employee = employee
-
- persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
- assert persons.count() == 2
-
- persons = PersonWithNotes.selectBy(noteID=person.note.id)
- assert persons.count() == 1
-
- employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
- assert employee.count() == 1
-
- persons = PersonWithNotes.selectBy(noteID=person.note.id)
- assert persons.count() == 1
-
- persons = PersonWithNotes.selectBy(note=person.note)
- assert persons.count() == 1
-
- persons = PersonWithNotes.selectBy(note=None)
- assert persons.count() == 2
-
- employee = EmployeeWithNotes.selectBy(paperID=None)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy(paper=None)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy(note=save_employee.note,
- paper=save_employee.paper)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy()
- assert employee.count() == 2
-
-
-class TestInheritableBase(InheritableSQLObject):
- pass
-
-class TestInheritableForeignKey(TestInheritableBase):
- base = ForeignKey("TestInheritableBase")
-
-def test_foreignKey2():
- setupClass([TestInheritableBase, TestInheritableForeignKey])
-
- test = TestInheritableBase()
- object = TestInheritableForeignKey(base=test)
|
|
From: <sub...@co...> - 2006-10-30 19:45:40
|
Author: phd
Date: 2006-10-30 12:45:28 -0700 (Mon, 30 Oct 2006)
New Revision: 2052
Added:
SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py
Removed:
SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py
Log:
Renamed test_inherited_foreignKey.py to test_foreignKey.py.
Copied: SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py (from rev 2049, SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py)
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py (rev 0)
+++ SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py 2006-10-30 19:45:28 UTC (rev 2052)
@@ -0,0 +1,85 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+
+class Note(SQLObject):
+ text = StringCol()
+
+class PersonWithNotes(InheritableSQLObject):
+ firstName = StringCol()
+ lastName = StringCol()
+ note = ForeignKey("Note", default=None)
+
+class Paper(SQLObject):
+ content = StringCol()
+
+class EmployeeWithNotes(PersonWithNotes):
+ _inheritable = False
+ paper = ForeignKey("Paper", default=None)
+
+def test_foreignKey():
+ setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
+
+ note = Note(text="person")
+ PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
+ note = Note(text="employee")
+ EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
+
+ paper = Paper(content="secret")
+ EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
+ PersonWithNotes(firstName='Some', lastName='Person')
+
+
+ person = PersonWithNotes.get(1)
+ assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
+ assert person.note.text == "person"
+
+ employee = EmployeeWithNotes.get(2)
+ assert isinstance(employee, EmployeeWithNotes)
+ assert employee.note.text == "employee"
+ save_employee = employee
+
+ persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert persons.count() == 2
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert employee.count() == 1
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=person.note)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=None)
+ assert persons.count() == 2
+
+ employee = EmployeeWithNotes.selectBy(paperID=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(paper=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(note=save_employee.note,
+ paper=save_employee.paper)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy()
+ assert employee.count() == 2
+
+
+class TestInheritableBase(InheritableSQLObject):
+ pass
+
+class TestInheritableForeignKey(TestInheritableBase):
+ base = ForeignKey("TestInheritableBase")
+
+def test_foreignKey2():
+ setupClass([TestInheritableBase, TestInheritableForeignKey])
+
+ test = TestInheritableBase()
+ object = TestInheritableForeignKey(base=test)
Deleted: SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:39:22 UTC (rev 2051)
+++ SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:45:28 UTC (rev 2052)
@@ -1,85 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-from sqlobject.inheritance import InheritableSQLObject
-
-
-class Note(SQLObject):
- text = StringCol()
-
-class PersonWithNotes(InheritableSQLObject):
- firstName = StringCol()
- lastName = StringCol()
- note = ForeignKey("Note", default=None)
-
-class Paper(SQLObject):
- content = StringCol()
-
-class EmployeeWithNotes(PersonWithNotes):
- _inheritable = False
- paper = ForeignKey("Paper", default=None)
-
-def test_foreignKey():
- setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
-
- note = Note(text="person")
- PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
- note = Note(text="employee")
- EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
-
- paper = Paper(content="secret")
- EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
- PersonWithNotes(firstName='Some', lastName='Person')
-
-
- person = PersonWithNotes.get(1)
- assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
- assert person.note.text == "person"
-
- employee = EmployeeWithNotes.get(2)
- assert isinstance(employee, EmployeeWithNotes)
- assert employee.note.text == "employee"
- save_employee = employee
-
- persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
- assert persons.count() == 2
-
- persons = PersonWithNotes.selectBy(noteID=person.note.id)
- assert persons.count() == 1
-
- employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
- assert employee.count() == 1
-
- persons = PersonWithNotes.selectBy(noteID=person.note.id)
- assert persons.count() == 1
-
- persons = PersonWithNotes.selectBy(note=person.note)
- assert persons.count() == 1
-
- persons = PersonWithNotes.selectBy(note=None)
- assert persons.count() == 2
-
- employee = EmployeeWithNotes.selectBy(paperID=None)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy(paper=None)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy(note=save_employee.note,
- paper=save_employee.paper)
- assert employee.count() == 1
-
- employee = EmployeeWithNotes.selectBy()
- assert employee.count() == 2
-
-
-class TestInheritableBase(InheritableSQLObject):
- pass
-
-class TestInheritableForeignKey(TestInheritableBase):
- base = ForeignKey("TestInheritableBase")
-
-def test_foreignKey2():
- setupClass([TestInheritableBase, TestInheritableForeignKey])
-
- test = TestInheritableBase()
- object = TestInheritableForeignKey(base=test)
|
|
From: <sub...@co...> - 2006-10-30 19:39:34
|
Author: phd
Date: 2006-10-30 12:39:22 -0700 (Mon, 30 Oct 2006)
New Revision: 2051
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py
SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py
Log:
A patch by Tormod Ravnanger Landet <to...@la...> to fix a problem with foreign keys in InheritableSQLObject.
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-30 19:38:53 UTC (rev 2050)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-30 19:39:22 UTC (rev 2051)
@@ -15,8 +15,7 @@
* Fixed a number of unicode-related problems with newer MySQLdb.
-* InheritableSQLObject.selectBy() now correctly handles foreign keys, even
- foreign keys from the parent classes.
+* Fixed a number of bugs in InheritableSQLObject related to foreign keys.
* If the DB API driver returns timedelta instead of time (MySQLdb sometimes
does this) it is converted to time; but if the timedelta has days an
Modified: SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py 2006-10-30 19:38:53 UTC (rev 2050)
+++ SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py 2006-10-30 19:39:22 UTC (rev 2051)
@@ -225,7 +225,8 @@
# create the current subclass otherwise we will leave
# the database in an inconsistent state.
for col in self.sqlmeta.columnList:
- if col._default == sqlbuilder.NoDefault and col.name not in kw:
+ if (col._default == sqlbuilder.NoDefault) and \
+ (col.name not in kw) and (col.foreignName not in kw):
raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name)
self._parent = parentClass(kw=parent_kw, connection=self._connection)
Modified: SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:38:53 UTC (rev 2050)
+++ SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:39:22 UTC (rev 2051)
@@ -18,11 +18,8 @@
_inheritable = False
paper = ForeignKey("Paper", default=None)
-def setup():
- setupClass(Note)
- setupClass(PersonWithNotes)
- setupClass(Paper)
- setupClass(EmployeeWithNotes)
+def test_foreignKey():
+ setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
note = Note(text="person")
PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
@@ -33,8 +30,6 @@
EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
PersonWithNotes(firstName='Some', lastName='Person')
-def test_inheritance():
- setup()
person = PersonWithNotes.get(1)
assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
@@ -75,3 +70,16 @@
employee = EmployeeWithNotes.selectBy()
assert employee.count() == 2
+
+
+class TestInheritableBase(InheritableSQLObject):
+ pass
+
+class TestInheritableForeignKey(TestInheritableBase):
+ base = ForeignKey("TestInheritableBase")
+
+def test_foreignKey2():
+ setupClass([TestInheritableBase, TestInheritableForeignKey])
+
+ test = TestInheritableBase()
+ object = TestInheritableForeignKey(base=test)
|
|
From: <sub...@co...> - 2006-10-30 19:38:58
|
Author: phd Date: 2006-10-30 12:38:53 -0700 (Mon, 30 Oct 2006) New Revision: 2050 Modified: SQLObject/docs/News.txt Log: A patch by Tormod Ravnanger Landet <to...@la...> to fix a problem with foreign keys in InheritableSQLObject. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2006-10-30 19:38:06 UTC (rev 2049) +++ SQLObject/docs/News.txt 2006-10-30 19:38:53 UTC (rev 2050) @@ -99,8 +99,7 @@ * Fixed a number of unicode-related problems with newer MySQLdb. -* InheritableSQLObject.selectBy() now correctly handles foreign keys, even - foreign keys from the parent classes. +* Fixed a number of bugs in InheritableSQLObject related to foreign keys. * If the DB API driver returns timedelta instead of time (MySQLdb sometimes does this) it is converted to time; but if the timedelta has days an |
|
From: <sub...@co...> - 2006-10-30 19:38:36
|
Author: phd
Date: 2006-10-30 12:38:06 -0700 (Mon, 30 Oct 2006)
New Revision: 2049
Modified:
SQLObject/trunk/sqlobject/inheritance/__init__.py
SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py
Log:
A patch by Tormod Ravnanger Landet <to...@la...> to fix a problem with foreign keys in InheritableSQLObject.
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2006-10-30 17:43:20 UTC (rev 2048)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2006-10-30 19:38:06 UTC (rev 2049)
@@ -308,7 +308,8 @@
# create the current subclass otherwise we will leave
# the database in an inconsistent state.
for col in self.sqlmeta.columnList:
- if col._default == sqlbuilder.NoDefault and col.name not in kw:
+ if (col._default == sqlbuilder.NoDefault) and \
+ (col.name not in kw) and (col.foreignName not in kw):
raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name)
parent_kw['childName'] = self.sqlmeta.childName
Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 17:43:20 UTC (rev 2048)
+++ SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-30 19:38:06 UTC (rev 2049)
@@ -18,11 +18,8 @@
_inheritable = False
paper = ForeignKey("Paper", default=None)
-def setup():
- setupClass(Note)
- setupClass(PersonWithNotes)
- setupClass(Paper)
- setupClass(EmployeeWithNotes)
+def test_foreignKey():
+ setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes])
note = Note(text="person")
PersonWithNotes(firstName='Oneof', lastName='Authors', note=note)
@@ -33,8 +30,6 @@
EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
PersonWithNotes(firstName='Some', lastName='Person')
-def test_inheritance():
- setup()
person = PersonWithNotes.get(1)
assert isinstance(person, PersonWithNotes) and not isinstance(person, EmployeeWithNotes)
@@ -75,3 +70,16 @@
employee = EmployeeWithNotes.selectBy()
assert employee.count() == 2
+
+
+class TestInheritableBase(InheritableSQLObject):
+ pass
+
+class TestInheritableForeignKey(TestInheritableBase):
+ base = ForeignKey("TestInheritableBase")
+
+def test_foreignKey2():
+ setupClass([TestInheritableBase, TestInheritableForeignKey])
+
+ test = TestInheritableBase()
+ object = TestInheritableForeignKey(base=test)
|
|
From: <sub...@co...> - 2006-10-30 17:43:42
|
Author: phd
Date: 2006-10-30 10:43:20 -0700 (Mon, 30 Oct 2006)
New Revision: 2048
Modified:
home/phd/SQLObject/paramstyles/sqlobject/col.py
Log:
Merged patches from the revisions 2047:2047 from the trunk: a patch by michelts <mic...@gm...>: convert timedelta from MySQLdb to time.
Modified: home/phd/SQLObject/paramstyles/sqlobject/col.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/col.py 2006-10-30 17:35:17 UTC (rev 2047)
+++ home/phd/SQLObject/paramstyles/sqlobject/col.py 2006-10-30 17:43:20 UTC (rev 2048)
@@ -1127,6 +1127,12 @@
def to_python(self, value, state):
if isinstance(value, datetime.time):
return value
+ if isinstance(value, datetime.timedelta):
+ if value.days:
+ raise validators.Invalid(
+ "the value for the TimeCol '%s' must has days=0, it has days=%d" %
+ (self.name, value.days), value, state)
+ return datetime.time(*time.gmtime(value.seconds)[3:6])
value = super(TimeValidator, self).to_python(value, state)
if isinstance(value, datetime.datetime):
value = value.time()
|
|
From: <sub...@co...> - 2006-10-30 17:35:28
|
Author: phd
Date: 2006-10-30 10:35:17 -0700 (Mon, 30 Oct 2006)
New Revision: 2047
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/sqlobject/col.py
Log:
A patch by michelts <mic...@gm...>: convert timedelta from MySQLdb to time.
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-30 17:34:42 UTC (rev 2046)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-30 17:35:17 UTC (rev 2047)
@@ -18,6 +18,10 @@
* InheritableSQLObject.selectBy() now correctly handles foreign keys, even
foreign keys from the parent classes.
+* If the DB API driver returns timedelta instead of time (MySQLdb sometimes
+ does this) it is converted to time; but if the timedelta has days an
+ exception is raised.
+
SQLObject 0.7.1
===============
Modified: SQLObject/branches/0.7-bugfix/sqlobject/col.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/col.py 2006-10-30 17:34:42 UTC (rev 2046)
+++ SQLObject/branches/0.7-bugfix/sqlobject/col.py 2006-10-30 17:35:17 UTC (rev 2047)
@@ -1114,6 +1114,12 @@
def to_python(self, value, state):
if isinstance(value, datetime.time):
return value
+ if isinstance(value, datetime.timedelta):
+ if value.days:
+ raise validators.Invalid(
+ "the value for the TimeCol '%s' must has days=0, it has days=%d" %
+ (self.name, value.days), value, state)
+ return datetime.time(*time.gmtime(value.seconds)[3:6])
value = super(TimeValidator, self).to_python(value, state)
if isinstance(value, datetime.datetime):
value = value.time()
|
|
From: <sub...@co...> - 2006-10-30 17:34:50
|
Author: phd Date: 2006-10-30 10:34:42 -0700 (Mon, 30 Oct 2006) New Revision: 2046 Modified: SQLObject/docs/News.txt Log: A patch by michelts <mic...@gm...>: convert timedelta from MySQLdb to time. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2006-10-30 17:33:51 UTC (rev 2045) +++ SQLObject/docs/News.txt 2006-10-30 17:34:42 UTC (rev 2046) @@ -102,6 +102,10 @@ * InheritableSQLObject.selectBy() now correctly handles foreign keys, even foreign keys from the parent classes. +* If the DB API driver returns timedelta instead of time (MySQLdb sometimes + does this) it is converted to time; but if the timedelta has days an + exception is raised. + SQLObject 0.7.1 =============== |
|
From: <sub...@co...> - 2006-10-30 17:34:22
|
Author: phd
Date: 2006-10-30 10:33:51 -0700 (Mon, 30 Oct 2006)
New Revision: 2045
Modified:
SQLObject/trunk/sqlobject/col.py
Log:
A patch by michelts <mic...@gm...>: convert timedelta from MySQLdb to time.
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2006-10-27 20:19:28 UTC (rev 2044)
+++ SQLObject/trunk/sqlobject/col.py 2006-10-30 17:33:51 UTC (rev 2045)
@@ -1127,6 +1127,12 @@
def to_python(self, value, state):
if isinstance(value, datetime.time):
return value
+ if isinstance(value, datetime.timedelta):
+ if value.days:
+ raise validators.Invalid(
+ "the value for the TimeCol '%s' must has days=0, it has days=%d" %
+ (self.name, value.days), value, state)
+ return datetime.time(*time.gmtime(value.seconds)[3:6])
value = super(TimeValidator, self).to_python(value, state)
if isinstance(value, datetime.datetime):
value = value.time()
|
|
From: <sub...@co...> - 2006-10-27 20:19:15
|
Author: phd
Date: 2006-10-27 14:19:28 -0600 (Fri, 27 Oct 2006)
New Revision: 2044
Modified:
home/phd/SQLObject/paramstyles/sqlobject/main.py
Log:
Merged patches from the revisions 2042:2043 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/main.py 2006-10-27 20:18:25 UTC (rev 2043)
+++ home/phd/SQLObject/paramstyles/sqlobject/main.py 2006-10-27 20:19:28 UTC (rev 2044)
@@ -325,8 +325,8 @@
for base in soClass.__bases__:
if hasattr(base, "sqlmeta"):
parent_columns.extend(base.sqlmeta.columns.keys())
- if name in dir(soClass):
- assert name in parent_columns or name == "childName", (
+ if hasattr(soClass, name):
+ assert (name in parent_columns) or (name == "childName"), (
"The class %s.%s already has a variable or method %r, you cannot "
"add the column %r"
% (soClass.__module__, soClass.__name__, name, name))
|
|
From: <sub...@co...> - 2006-10-27 20:18:18
|
Author: phd
Date: 2006-10-27 14:18:25 -0600 (Fri, 27 Oct 2006)
New Revision: 2043
Modified:
SQLObject/trunk/sqlobject/main.py
Log:
"hasattr(soClass, name)" is more readable than "name in dir(soClass)" and probably faster.
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2006-10-27 15:31:17 UTC (rev 2042)
+++ SQLObject/trunk/sqlobject/main.py 2006-10-27 20:18:25 UTC (rev 2043)
@@ -325,8 +325,8 @@
for base in soClass.__bases__:
if hasattr(base, "sqlmeta"):
parent_columns.extend(base.sqlmeta.columns.keys())
- if name in dir(soClass):
- assert name in parent_columns or name == "childName", (
+ if hasattr(soClass, name):
+ assert (name in parent_columns) or (name == "childName"), (
"The class %s.%s already has a variable or method %r, you cannot "
"add the column %r"
% (soClass.__module__, soClass.__name__, name, name))
|
|
From: <sub...@co...> - 2006-10-27 15:31:10
|
Author: phd
Date: 2006-10-27 09:31:17 -0600 (Fri, 27 Oct 2006)
New Revision: 2042
Modified:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_foreignKey.py
Log:
Merged patches from the revisions 2038:2041 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2006-10-27 15:28:43 UTC (rev 2041)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2006-10-27 15:31:17 UTC (rev 2042)
@@ -392,9 +392,34 @@
def selectBy(cls, connection=None, **kw):
clause = []
+ foreignColumns = {}
+ currentClass = cls
+ while currentClass:
+ foreignColumns.update(dict([(column.foreignName, name)
+ for (name, column) in currentClass.sqlmeta.columns.items()
+ if column.foreignKey
+ ]))
+ currentClass = currentClass.sqlmeta.parentClass
for name, value in kw.items():
- clause.append(getattr(cls.q, name) == value)
- clause = reduce(sqlbuilder.AND, clause)
+ if name in foreignColumns:
+ name = foreignColumns[name] # translate "key" to "keyID"
+ if isinstance(value, SQLObject):
+ value = value.id
+ currentClass = cls
+ while currentClass:
+ try:
+ clause.append(getattr(currentClass.q, name) == value)
+ break
+ except AttributeError, err:
+ pass
+ currentClass = currentClass.sqlmeta.parentClass
+ else:
+ raise AttributeError("'%s' instance has no attribute '%s'"
+ % (cls.__name__, name))
+ if clause:
+ clause = reduce(sqlbuilder.AND, clause)
+ else:
+ clause = None # select all
conn = connection or cls._connection
return cls.SelectResultsClass(cls, clause, connection=conn)
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-27 15:28:43 UTC (rev 2041)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-27 15:31:17 UTC (rev 2042)
@@ -11,12 +11,17 @@
lastName = StringCol()
note = ForeignKey("Note", default=None)
+class Paper(SQLObject):
+ content = StringCol()
+
class EmployeeWithNotes(PersonWithNotes):
_inheritable = False
+ paper = ForeignKey("Paper", default=None)
def setup():
setupClass(Note)
setupClass(PersonWithNotes)
+ setupClass(Paper)
setupClass(EmployeeWithNotes)
note = Note(text="person")
@@ -24,6 +29,9 @@
note = Note(text="employee")
EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
+ paper = Paper(content="secret")
+ EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
+ PersonWithNotes(firstName='Some', lastName='Person')
def test_inheritance():
setup()
@@ -35,3 +43,35 @@
employee = EmployeeWithNotes.get(2)
assert isinstance(employee, EmployeeWithNotes)
assert employee.note.text == "employee"
+ save_employee = employee
+
+ persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert persons.count() == 2
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert employee.count() == 1
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=person.note)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=None)
+ assert persons.count() == 2
+
+ employee = EmployeeWithNotes.selectBy(paperID=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(paper=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(note=save_employee.note,
+ paper=save_employee.paper)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy()
+ assert employee.count() == 2
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_foreignKey.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_foreignKey.py 2006-10-27 15:28:43 UTC (rev 2041)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_foreignKey.py 2006-10-27 15:31:17 UTC (rev 2042)
@@ -37,6 +37,9 @@
s = TestWorkKey.selectBy(composer=None, title=None)
assert s[0]==w2
+ s = TestWorkKey.selectBy()
+ assert s.count() == 2
+
def test2():
TestWorkKey._connection = getConnection()
InstalledTestDatabase.drop(TestWorkKey)
|
|
From: <sub...@co...> - 2006-10-27 15:28:33
|
Author: phd Date: 2006-10-27 09:28:43 -0600 (Fri, 27 Oct 2006) New Revision: 2041 Modified: SQLObject/docs/News.txt Log: InheritableSQLObject.selectBy() now correctly handles foreign keys, even foreign keys from the parent classes. The patch is inspired and the test provided by Johan Dahlin <jd...@as...>. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2006-10-27 15:28:27 UTC (rev 2040) +++ SQLObject/docs/News.txt 2006-10-27 15:28:43 UTC (rev 2041) @@ -99,6 +99,9 @@ * Fixed a number of unicode-related problems with newer MySQLdb. +* InheritableSQLObject.selectBy() now correctly handles foreign keys, even + foreign keys from the parent classes. + SQLObject 0.7.1 =============== |
|
From: <sub...@co...> - 2006-10-27 15:28:26
|
Author: phd
Date: 2006-10-27 09:28:27 -0600 (Fri, 27 Oct 2006)
New Revision: 2040
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py
SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_foreignKey.py
Log:
InheritableSQLObject.selectBy() now correctly handles foreign keys, even foreign keys from the parent classes.
The patch is inspired and the test provided by Johan Dahlin <jd...@as...>.
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-27 15:26:07 UTC (rev 2039)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-27 15:28:27 UTC (rev 2040)
@@ -15,6 +15,9 @@
* Fixed a number of unicode-related problems with newer MySQLdb.
+* InheritableSQLObject.selectBy() now correctly handles foreign keys, even
+ foreign keys from the parent classes.
+
SQLObject 0.7.1
===============
Modified: SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py 2006-10-27 15:26:07 UTC (rev 2039)
+++ SQLObject/branches/0.7-bugfix/sqlobject/inheritance/__init__.py 2006-10-27 15:28:27 UTC (rev 2040)
@@ -245,9 +245,34 @@
def selectBy(cls, connection=None, **kw):
clause = []
+ foreignColumns = {}
+ currentClass = cls
+ while currentClass:
+ foreignColumns.update(dict([(column.foreignName, name)
+ for (name, column) in currentClass.sqlmeta.columns.items()
+ if column.foreignKey
+ ]))
+ currentClass = currentClass._parentClass
for name, value in kw.items():
- clause.append(getattr(cls.q, name) == value)
- clause = reduce(sqlbuilder.AND, clause)
+ if name in foreignColumns:
+ name = foreignColumns[name] # translate "key" to "keyID"
+ if isinstance(value, SQLObject):
+ value = value.id
+ currentClass = cls
+ while currentClass:
+ try:
+ clause.append(getattr(currentClass.q, name) == value)
+ break
+ except AttributeError, err:
+ pass
+ currentClass = currentClass._parentClass
+ else:
+ raise AttributeError("'%s' instance has no attribute '%s'"
+ % (cls.__name__, name))
+ if clause:
+ clause = reduce(sqlbuilder.AND, clause)
+ else:
+ clause = None # select all
conn = connection or cls._connection
return cls.SelectResultsClass(cls, clause, connection=conn)
Modified: SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-27 15:26:07 UTC (rev 2039)
+++ SQLObject/branches/0.7-bugfix/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-27 15:28:27 UTC (rev 2040)
@@ -11,12 +11,17 @@
lastName = StringCol()
note = ForeignKey("Note", default=None)
+class Paper(SQLObject):
+ content = StringCol()
+
class EmployeeWithNotes(PersonWithNotes):
_inheritable = False
+ paper = ForeignKey("Paper", default=None)
def setup():
setupClass(Note)
setupClass(PersonWithNotes)
+ setupClass(Paper)
setupClass(EmployeeWithNotes)
note = Note(text="person")
@@ -24,6 +29,9 @@
note = Note(text="employee")
EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
+ paper = Paper(content="secret")
+ EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
+ PersonWithNotes(firstName='Some', lastName='Person')
def test_inheritance():
setup()
@@ -35,3 +43,35 @@
employee = EmployeeWithNotes.get(2)
assert isinstance(employee, EmployeeWithNotes)
assert employee.note.text == "employee"
+ save_employee = employee
+
+ persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert persons.count() == 2
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert employee.count() == 1
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=person.note)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=None)
+ assert persons.count() == 2
+
+ employee = EmployeeWithNotes.selectBy(paperID=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(paper=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(note=save_employee.note,
+ paper=save_employee.paper)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy()
+ assert employee.count() == 2
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_foreignKey.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_foreignKey.py 2006-10-27 15:26:07 UTC (rev 2039)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_foreignKey.py 2006-10-27 15:28:27 UTC (rev 2040)
@@ -38,6 +38,9 @@
s = TestWorkKey.selectBy(composer=None, title=None)
assert s[0]==w2
+ s = TestWorkKey.selectBy()
+ assert s.count() == 2
+
def test2():
setupClass([TestComposerKey, TestWorkKey2])
TestWorkKey2.sqlmeta.addColumn(ForeignKey('TestComposerKey'), changeSchema=True)
|
|
From: <sub...@co...> - 2006-10-27 15:26:09
|
Author: phd
Date: 2006-10-27 09:26:07 -0600 (Fri, 27 Oct 2006)
New Revision: 2039
Modified:
SQLObject/trunk/sqlobject/inheritance/__init__.py
SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py
SQLObject/trunk/sqlobject/tests/test_foreignKey.py
Log:
InheritableSQLObject.selectBy() now correctly handles foreign keys, even foreign keys from the parent classes.
The patch is inspired and the test provided by Johan Dahlin <jd...@as...>.
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2006-10-26 18:06:18 UTC (rev 2038)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2006-10-27 15:26:07 UTC (rev 2039)
@@ -392,9 +392,34 @@
def selectBy(cls, connection=None, **kw):
clause = []
+ foreignColumns = {}
+ currentClass = cls
+ while currentClass:
+ foreignColumns.update(dict([(column.foreignName, name)
+ for (name, column) in currentClass.sqlmeta.columns.items()
+ if column.foreignKey
+ ]))
+ currentClass = currentClass.sqlmeta.parentClass
for name, value in kw.items():
- clause.append(getattr(cls.q, name) == value)
- clause = reduce(sqlbuilder.AND, clause)
+ if name in foreignColumns:
+ name = foreignColumns[name] # translate "key" to "keyID"
+ if isinstance(value, SQLObject):
+ value = value.id
+ currentClass = cls
+ while currentClass:
+ try:
+ clause.append(getattr(currentClass.q, name) == value)
+ break
+ except AttributeError, err:
+ pass
+ currentClass = currentClass.sqlmeta.parentClass
+ else:
+ raise AttributeError("'%s' instance has no attribute '%s'"
+ % (cls.__name__, name))
+ if clause:
+ clause = reduce(sqlbuilder.AND, clause)
+ else:
+ clause = None # select all
conn = connection or cls._connection
return cls.SelectResultsClass(cls, clause, connection=conn)
Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-26 18:06:18 UTC (rev 2038)
+++ SQLObject/trunk/sqlobject/inheritance/tests/test_inherited_foreignKey.py 2006-10-27 15:26:07 UTC (rev 2039)
@@ -11,12 +11,17 @@
lastName = StringCol()
note = ForeignKey("Note", default=None)
+class Paper(SQLObject):
+ content = StringCol()
+
class EmployeeWithNotes(PersonWithNotes):
_inheritable = False
+ paper = ForeignKey("Paper", default=None)
def setup():
setupClass(Note)
setupClass(PersonWithNotes)
+ setupClass(Paper)
setupClass(EmployeeWithNotes)
note = Note(text="person")
@@ -24,6 +29,9 @@
note = Note(text="employee")
EmployeeWithNotes(firstName='Project', lastName='Leader', note=note)
+ paper = Paper(content="secret")
+ EmployeeWithNotes(firstName='Senior', lastName='Clerk', paper=paper)
+ PersonWithNotes(firstName='Some', lastName='Person')
def test_inheritance():
setup()
@@ -35,3 +43,35 @@
employee = EmployeeWithNotes.get(2)
assert isinstance(employee, EmployeeWithNotes)
assert employee.note.text == "employee"
+ save_employee = employee
+
+ persons = PersonWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert persons.count() == 2
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ employee = EmployeeWithNotes.select(PersonWithNotes.q.noteID <> None)
+ assert employee.count() == 1
+
+ persons = PersonWithNotes.selectBy(noteID=person.note.id)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=person.note)
+ assert persons.count() == 1
+
+ persons = PersonWithNotes.selectBy(note=None)
+ assert persons.count() == 2
+
+ employee = EmployeeWithNotes.selectBy(paperID=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(paper=None)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy(note=save_employee.note,
+ paper=save_employee.paper)
+ assert employee.count() == 1
+
+ employee = EmployeeWithNotes.selectBy()
+ assert employee.count() == 2
Modified: SQLObject/trunk/sqlobject/tests/test_foreignKey.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_foreignKey.py 2006-10-26 18:06:18 UTC (rev 2038)
+++ SQLObject/trunk/sqlobject/tests/test_foreignKey.py 2006-10-27 15:26:07 UTC (rev 2039)
@@ -38,6 +38,9 @@
s = TestWorkKey.selectBy(composer=None, title=None)
assert s[0]==w2
+ s = TestWorkKey.selectBy()
+ assert s.count() == 2
+
def test2():
TestWorkKey._connection = getConnection()
InstalledTestDatabase.drop(TestWorkKey)
|