sqlobject-cvs Mailing List for SQLObject (Page 99)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
(9) |
Apr
(74) |
May
(29) |
Jun
(16) |
Jul
(28) |
Aug
(10) |
Sep
(57) |
Oct
(9) |
Nov
(29) |
Dec
(12) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(7) |
Feb
(14) |
Mar
(6) |
Apr
(3) |
May
(12) |
Jun
(34) |
Jul
(9) |
Aug
(29) |
Sep
(22) |
Oct
(2) |
Nov
(15) |
Dec
(52) |
| 2005 |
Jan
(47) |
Feb
(78) |
Mar
(14) |
Apr
(35) |
May
(33) |
Jun
(16) |
Jul
(26) |
Aug
(63) |
Sep
(40) |
Oct
(96) |
Nov
(96) |
Dec
(123) |
| 2006 |
Jan
(159) |
Feb
(144) |
Mar
(64) |
Apr
(31) |
May
(88) |
Jun
(48) |
Jul
(16) |
Aug
(64) |
Sep
(87) |
Oct
(92) |
Nov
(56) |
Dec
(76) |
| 2007 |
Jan
(94) |
Feb
(103) |
Mar
(126) |
Apr
(123) |
May
(85) |
Jun
(11) |
Jul
(130) |
Aug
(47) |
Sep
(65) |
Oct
(70) |
Nov
(12) |
Dec
(11) |
| 2008 |
Jan
(30) |
Feb
(55) |
Mar
(88) |
Apr
(20) |
May
(50) |
Jun
|
Jul
(38) |
Aug
(1) |
Sep
(9) |
Oct
(5) |
Nov
(6) |
Dec
(39) |
| 2009 |
Jan
(8) |
Feb
(16) |
Mar
(3) |
Apr
(33) |
May
(44) |
Jun
(1) |
Jul
(10) |
Aug
(33) |
Sep
(74) |
Oct
(22) |
Nov
|
Dec
(15) |
| 2010 |
Jan
(28) |
Feb
(22) |
Mar
(46) |
Apr
(29) |
May
(1) |
Jun
(1) |
Jul
(27) |
Aug
(8) |
Sep
(5) |
Oct
(33) |
Nov
(24) |
Dec
(41) |
| 2011 |
Jan
(4) |
Feb
(12) |
Mar
(35) |
Apr
(29) |
May
(19) |
Jun
(16) |
Jul
(32) |
Aug
(25) |
Sep
(5) |
Oct
(11) |
Nov
(21) |
Dec
(12) |
| 2012 |
Jan
(3) |
Feb
(4) |
Mar
(20) |
Apr
(4) |
May
(25) |
Jun
(13) |
Jul
|
Aug
|
Sep
(2) |
Oct
(25) |
Nov
(9) |
Dec
(1) |
| 2013 |
Jan
(6) |
Feb
(8) |
Mar
|
Apr
(10) |
May
(31) |
Jun
(7) |
Jul
(18) |
Aug
(33) |
Sep
(4) |
Oct
(16) |
Nov
|
Dec
(27) |
| 2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(11) |
May
(39) |
Jun
(8) |
Jul
(11) |
Aug
(4) |
Sep
|
Oct
(27) |
Nov
|
Dec
(71) |
| 2015 |
Jan
(17) |
Feb
(47) |
Mar
(33) |
Apr
|
May
|
Jun
(9) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
| 2016 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
(12) |
Jun
(7) |
Jul
(9) |
Aug
(31) |
Sep
(8) |
Oct
(3) |
Nov
(15) |
Dec
(1) |
| 2017 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(8) |
May
(10) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(4) |
Dec
(5) |
| 2018 |
Jan
(2) |
Feb
(8) |
Mar
|
Apr
(4) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
(1) |
Feb
(16) |
Mar
(1) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
| 2021 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
(1) |
Dec
(4) |
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
|
| 2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
| 2025 |
Jan
|
Feb
(4) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
|
From: <sub...@co...> - 2007-03-19 16:54:29
|
Author: phd Date: 2007-03-19 10:52:52 -0600 (Mon, 19 Mar 2007) New Revision: 2431 Added: SQLObject/tags/0.8.1/ Log: Tagging 0.8.1 Copied: SQLObject/tags/0.8.1 (from rev 2430, SQLObject/branches/0.8) |
|
From: <sub...@co...> - 2007-03-19 16:49:42
|
Author: phd Date: 2007-03-19 10:49:26 -0600 (Mon, 19 Mar 2007) New Revision: 2430 Modified: SQLObject/docs/News.txt Log: SQLObject 0.8.1 released 19 Mar 2007. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-03-19 16:48:32 UTC (rev 2429) +++ SQLObject/docs/News.txt 2007-03-19 16:49:26 UTC (rev 2430) @@ -63,6 +63,8 @@ SQLObject 0.8.1 =============== +Released 19 Mar 2007. + Bug Fixes --------- |
|
From: <sub...@co...> - 2007-03-19 16:48:42
|
Author: phd
Date: 2007-03-19 10:48:32 -0600 (Mon, 19 Mar 2007)
New Revision: 2429
Modified:
SQLObject/branches/0.8/docs/News.txt
SQLObject/branches/0.8/setup.py
Log:
Releasing version 0.8.1.
Modified: SQLObject/branches/0.8/docs/News.txt
===================================================================
--- SQLObject/branches/0.8/docs/News.txt 2007-03-19 16:26:00 UTC (rev 2428)
+++ SQLObject/branches/0.8/docs/News.txt 2007-03-19 16:48:32 UTC (rev 2429)
@@ -10,6 +10,8 @@
SQLObject 0.8.1
===============
+Released 19 Mar 2007.
+
Bug Fixes
---------
Modified: SQLObject/branches/0.8/setup.py
===================================================================
--- SQLObject/branches/0.8/setup.py 2007-03-19 16:26:00 UTC (rev 2428)
+++ SQLObject/branches/0.8/setup.py 2007-03-19 16:48:32 UTC (rev 2429)
@@ -28,7 +28,7 @@
"""
setup(name="SQLObject",
- version="0.8.1b1",
+ version="0.8.1",
description="Object-Relational Manager, aka database wrapper",
long_description="""\
SQLObject is a popular *Object Relational Manager* for providing an
|
|
From: <sub...@co...> - 2007-03-19 16:27:37
|
Author: phd Date: 2007-03-19 10:26:00 -0600 (Mon, 19 Mar 2007) New Revision: 2428 Modified: SQLObject/tags/0.7.4/setup.cfg Log: Releasing stable version 0.7.4. Modified: SQLObject/tags/0.7.4/setup.cfg =================================================================== --- SQLObject/tags/0.7.4/setup.cfg 2007-03-19 16:23:35 UTC (rev 2427) +++ SQLObject/tags/0.7.4/setup.cfg 2007-03-19 16:26:00 UTC (rev 2428) @@ -1,7 +1,3 @@ -[egg_info] -tag_build = a -tag_svn_revision = true - [pudge] title = SQLObject dest = docs/html |
|
From: <sub...@co...> - 2007-03-19 16:25:17
|
Author: phd Date: 2007-03-19 10:23:35 -0600 (Mon, 19 Mar 2007) New Revision: 2427 Added: SQLObject/tags/0.7.4/ Log: Tagging 0.7.4 Copied: SQLObject/tags/0.7.4 (from rev 2426, SQLObject/branches/0.7) |
|
From: <sub...@co...> - 2007-03-19 16:22:27
|
Author: phd Date: 2007-03-19 10:22:03 -0600 (Mon, 19 Mar 2007) New Revision: 2426 Modified: SQLObject/docs/News.txt Log: SQLObject 0.7.4 released 19 Mar 2007. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-03-19 16:21:19 UTC (rev 2425) +++ SQLObject/docs/News.txt 2007-03-19 16:22:03 UTC (rev 2426) @@ -187,6 +187,8 @@ SQLObject 0.7.4 =============== +Released 19 Mar 2007. + Small Features -------------- |
|
From: <sub...@co...> - 2007-03-19 16:21:30
|
Author: phd Date: 2007-03-19 10:21:19 -0600 (Mon, 19 Mar 2007) New Revision: 2425 Modified: SQLObject/branches/0.8/docs/News.txt Log: SQLObject 0.7.4 released 19 Mar 2007. Modified: SQLObject/branches/0.8/docs/News.txt =================================================================== --- SQLObject/branches/0.8/docs/News.txt 2007-03-19 16:20:19 UTC (rev 2424) +++ SQLObject/branches/0.8/docs/News.txt 2007-03-19 16:21:19 UTC (rev 2425) @@ -134,6 +134,8 @@ SQLObject 0.7.4 =============== +Released 19 Mar 2007. + Small Features -------------- |
|
From: <sub...@co...> - 2007-03-19 16:20:34
|
Author: phd Date: 2007-03-19 10:20:19 -0600 (Mon, 19 Mar 2007) New Revision: 2424 Modified: SQLObject/branches/0.7/docs/News.txt Log: Released 19 Mar 2007. Modified: SQLObject/branches/0.7/docs/News.txt =================================================================== --- SQLObject/branches/0.7/docs/News.txt 2007-03-19 16:19:27 UTC (rev 2423) +++ SQLObject/branches/0.7/docs/News.txt 2007-03-19 16:20:19 UTC (rev 2424) @@ -10,6 +10,8 @@ SQLObject 0.7.4 =============== +Released 19 Mar 2007. + Small Features -------------- |
|
From: <sub...@co...> - 2007-03-19 16:19:40
|
Author: phd
Date: 2007-03-19 10:19:27 -0600 (Mon, 19 Mar 2007)
New Revision: 2423
Modified:
SQLObject/branches/0.7/setup.py
Log:
Releasing version 0.7.4.
Modified: SQLObject/branches/0.7/setup.py
===================================================================
--- SQLObject/branches/0.7/setup.py 2007-03-16 19:53:06 UTC (rev 2422)
+++ SQLObject/branches/0.7/setup.py 2007-03-19 16:19:27 UTC (rev 2423)
@@ -19,7 +19,7 @@
DistributionMetadata.download_url = None
setup(name="SQLObject",
- version="0.7.4b1",
+ version="0.7.4",
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.4b1",
+ download_url="http://cheeseshop.python.org/pypi/SQLObject/0.7.4",
license="LGPL",
packages=["sqlobject"] + ['sqlobject.%s' % package for package in subpackages],
scripts=["scripts/sqlobject-admin"],
|
|
From: SourceForge.net <no...@so...> - 2007-03-19 16:06:25
|
Bugs item #1670239, was opened at 2007-02-27 21:37 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1670239&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: None Status: Open Resolution: Works For Me Priority: 5 Private: No Submitted By: Vladimir Chukharev (chukharevv) Assigned to: Oleg Broytmann (phd) Summary: orderBy='..' conflicts with distinct=True in select() Initial Comment: I tried to execute select() with parameters orderBy and distinct for inheritable tables. Any of the two parameters can be used alone, but if they are used together, an error occurs. The following example is printed in Python shell: from datetime import datetime from sqlobject import * from sqlobject.sqlbuilder import * from sqlobject.inheritance import InheritableSQLObject sqlhub.processConnection = connectionForURI('postgres:///test') class Base(InheritableSQLObject): created = DateTimeCol(default=DateTimeCol.now()) class BaseSample(Base): name = StringCol(length=40, alternateID=True) BaseSample.createTable(ifNotExists=True) Base.createTable(ifNotExists=True) sample = BaseSample(name='Sample1') order=BaseSample.q.created Two working calls of select(). print list(BaseSample.select(orderBy=order)) [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] print list(BaseSample.select(distinct=True)) [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] Now the error. print list(BaseSample.select(orderBy=order, distinct=True)) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sresults.py", line 155, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sresults.py", line 163, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 364, in iterSelect select, keepConnection=False) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/inheritance/iteration.py", line 10, in __init__ super(InheritableIteration, self).__init__(dbconn, rawconn, select, keepConnection) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 704, in __init__ self.dbconn._executeRetry(self.rawconn, self.cursor, self.query) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 298, in _executeRetry return cursor.execute(query) psycopg.ProgrammingError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list SELECT DISTINCT base_sample.id, base_sample.child_name, base_sample.name FROM base, base_sample WHERE ((1 = 1) AND ((base_sample.id) = (base.id))) ORDER BY base.created Additional information. SQLObject-0.7.1dev_r1860 TurboGears-1.0b1 Ubuntu $ uname -a Linux svetlana-desktop 2.6.15-28-amd64-generic #1 SMP PREEMPT Thu Feb 1 15:53:41 UTC 2007 x86_64 GNU/Linux ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-03-19 19:04 Message: Logged In: YES user_id=4799 Originator: NO Seems your database is stricter than mine as my Postgres 7.4 allows this: 9/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base, base_sample WHERE (((base.child_name) = ('BaseSample')) AND ((base_sample.id) = (base.id))) ORDER BY base_sample.name 9/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base, base_sample WHERE (((base.child_name) = ('BaseSample')) AND ((base_sample.id) = (base.id))) ORDER BY base_sample.name 9/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 9/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) [<BaseSample 1 name='Sample1' created='datetime.datetime...)'>] Well, that's a problem... The lack of 'distinct' parameter from Select() is not intentional - just nobody has implemented it. There is an open bug report about that. It can be fixed, and it's being fixed in the sqlbuilder-views branch by Luke Opperman: http://svn.colorstudy.com/SQLObject/branches/sqlbuilder-views/ . I will ask Luke when and how he is going to merge the branch into the trunk. ---------------------------------------------------------------------- Comment By: Vladimir Chukharev (chukharevv) Date: 2007-03-17 11:27 Message: Logged In: YES user_id=607106 Originator: YES Thanks a lot for your followup. We have upgraded our system for the use of SO 0.8 (BTW, some changes to our code were needed with the names of foreign key fields, perhaps something about possible incompatibility of the versions is due for the release notes). Indeed, the previous example now works. But the same conflict remains, just the table changed from Base to BaseSample for our test. As a continuation of your commands: print list(BaseSample.select(orderBy=BaseSample.q.name, distinct=True)) 1/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base, base_sample WHERE (((base.child_name) = ('BaseSample')) AND ((base_sample.id) = (base.id))) ORDER BY base_sample.name 1/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base, base_sample WHERE (((base.child_name) = ('BaseSample')) AND ((base_sample.id) = (base.id))) ORDER BY base_sample.name Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/sresults.py", line 160, in __iter__ return iter(list(self.lazyIter())) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/sresults.py", line 168, in lazyIter return conn.iterSelect(self) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/dbconnection.py", line 374, in iterSelect select, keepConnection=False) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/inheritance/iteration.py", line 10, in __init__ super(InheritableIteration, self).__init__(dbconn, rawconn, select, keepConnection) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/dbconnection.py", line 760, in __init__ self.dbconn._executeRetry(self.rawconn, self.cursor, self.query) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/dbconnection.py", line 308, in _executeRetry return cursor.execute(query) psycopg.ProgrammingError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list SELECT DISTINCT base.id, base.created, base.child_name FROM base, base_sample WHERE (((base.child_name) = ('BaseSample')) AND ((base_sample.id) = (base.id))) ORDER BY base_sample.name Thanks again, V. Chukharev PS. As a side note, is lack of distinct parameter from Select() intentional and can that be fixed? PPS. Thanks for spotting now() insead of now. It was forgotten after some experiments with both variants. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-02-28 14:29 Message: Logged In: YES user_id=4799 Originator: NO Works in SQLObject 0.8: from datetime import datetime from sqlobject import * from sqlobject.inheritance import InheritableSQLObject from sqlobject.sqlbuilder import * __connection__ = "postgres:/test?debug=1" class Base(InheritableSQLObject): created = DateTimeCol(default=DateTimeCol.now()) class BaseSample(Base): name = StringCol(length=40, alternateID=True) Base.createTable(ifNotExists=True) BaseSample.createTable(ifNotExists=True) sample = BaseSample(name='Sample1') order=BaseSample.q.created print list(BaseSample.select(orderBy=order)) print list(BaseSample.select(distinct=True)) print list(BaseSample.select(orderBy=order, distinct=True)) Debugging output; please note base.created is in the select list in the last SELECT DISTINCT query: 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'base' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'base' 1/COMMIT : auto 1/Query : CREATE TABLE base ( id SERIAL PRIMARY KEY, created TIMESTAMP, child_name VARCHAR(255) ) 1/QueryR : CREATE TABLE base ( id SERIAL PRIMARY KEY, created TIMESTAMP, child_name VARCHAR(255) ) 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'base_sample' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'base_sample' 1/COMMIT : auto 1/Query : CREATE TABLE base_sample ( id SERIAL PRIMARY KEY, name VARCHAR(40) NOT NULL UNIQUE, child_name VARCHAR(255) ) 1/QueryR : CREATE TABLE base_sample ( id SERIAL PRIMARY KEY, name VARCHAR(40) NOT NULL UNIQUE, child_name VARCHAR(255) ) 1/COMMIT : auto 1/QueryIns: INSERT INTO base (id, child_name, created) VALUES (1, 'BaseSample', '2007-02-28 14:24:22') 1/COMMIT : auto 1/QueryOne: SELECT created, child_name FROM base WHERE id = (1) 1/QueryR : SELECT created, child_name FROM base WHERE id = (1) 1/COMMIT : auto 1/QueryIns: INSERT INTO base_sample (id, name, child_name) VALUES (1, 'Sample1', NULL) 1/COMMIT : auto 1/QueryOne: SELECT name, child_name FROM base_sample WHERE id = (1) 1/QueryR : SELECT name, child_name FROM base_sample WHERE id = (1) 1/COMMIT : auto 1/Select : SELECT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/QueryR : SELECT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] 1/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) 1/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] 1/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] PS. I hope you understand the difference between created = DateTimeCol(default=DateTimeCol.now()) and created = DateTimeCol(default=DateTimeCol.now) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1670239&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-03-19 15:49:25
|
Bugs item #1663785, was opened at 2007-02-19 22:49 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1663785&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: MySQL Group: SQLObject from repository >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: dado1945 (dado1945) Assigned to: Oleg Broytmann (phd) Summary: ADD CONSTRAINT fails Initial Comment: Environment: Windows, MySql 5.0, SQLObject from svn Description: (1) It seems SQLObject creates tables alphabetically and adds constraints after creation of each table. It might happen that required table is not created yet for constraint. It is interesting that "sql sql" shows that constraints will be added after all tables are created. (2) Another problem is that foreign key and id has different types (INT and INT UNSIGNED). Because of those two problems constrain creation fails. E.g. this query: ALTER TABLE blog ADD CONSTRAINT blog_language_id_exists FOREIGN KEY (language_id) REFERENCES language (id) gives following error: sqlobject.dberrors.OperationalError: Can't create table '.\tp\#sql-1b8_35.frm' (errno: 150) (1) This problem might be solved by changing line 590 in file sqlobject\manager\command.py: tableConstraints = soClass.createTable() to: tableConstraints = soClass.createTable(applyConstraints=False) I guess the same fix is required by line 583. (2) I think foreign key type must be changed to UNSIGNED INT but I have not found part where to do that. Because of that I just removed UNSIGNED from sqlobject\mysql\mysqlconnection.py line 172. That's not the best fix but the fastest one I have found. Note: I guess this problem might exist for some other databases as well. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-03-19 18:49 Message: Logged In: YES user_id=4799 Originator: NO It's been fixed in r2381: http://sourceforge.net/mailarchive/forum.php?thread_id=31822124&forum_id=32002. All keys are now signed. ---------------------------------------------------------------------- Comment By: dado1945 (dado1945) Date: 2007-02-20 20:01 Message: Logged In: YES user_id=1533929 Originator: YES 1. Thanks :) 2. I don't think it must be UNSIGNED. I think foreign key must have the same type as id. Let's take your example and change a little bit. I have added UNSIGNED to parent id: CREATE TABLE parent(id INT UNSIGNED NOT NULL, PRIMARY KEY (id) ) TYPE=INNODB; CREATE TABLE child(id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE ) TYPE=INNODB; Now child.parent_id and parent.id has different types (even if both are 32 bits). That's not good behavior and that's happens in SQLObject's MySQL case. parent.id will always be UNSIGNED INT (sqlobject\mysql\mysqlconnection.py line 172) and foreign key will be INT (I don't know where it comes from). ADD CONSTRAIN seems to check if types are equal and fails. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-02-20 18:58 Message: Logged In: YES user_id=4799 Originator: NO 1. Fixed in the SVN, revision 2329. 2. In the MySQL Reference Manual there is an example: CREATE TABLE parent(id INT NOT NULL, PRIMARY KEY (id) ) TYPE=INNODB; CREATE TABLE child(id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE ) TYPE=INNODB; So it seems a foreign keys have no obligation to be UNSIGNED. Why do you think they *must* be UNSIGNED? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1663785&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-03-17 08:28:06
|
Bugs item #1670239, was opened at 2007-02-27 18:37 Message generated for change (Comment added) made by chukharevv You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1670239&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: None >Status: Open Resolution: Works For Me Priority: 5 Private: No Submitted By: Vladimir Chukharev (chukharevv) Assigned to: Oleg Broytmann (phd) Summary: orderBy='..' conflicts with distinct=True in select() Initial Comment: I tried to execute select() with parameters orderBy and distinct for inheritable tables. Any of the two parameters can be used alone, but if they are used together, an error occurs. The following example is printed in Python shell: from datetime import datetime from sqlobject import * from sqlobject.sqlbuilder import * from sqlobject.inheritance import InheritableSQLObject sqlhub.processConnection = connectionForURI('postgres:///test') class Base(InheritableSQLObject): created = DateTimeCol(default=DateTimeCol.now()) class BaseSample(Base): name = StringCol(length=40, alternateID=True) BaseSample.createTable(ifNotExists=True) Base.createTable(ifNotExists=True) sample = BaseSample(name='Sample1') order=BaseSample.q.created Two working calls of select(). print list(BaseSample.select(orderBy=order)) [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] print list(BaseSample.select(distinct=True)) [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] Now the error. print list(BaseSample.select(orderBy=order, distinct=True)) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sresults.py", line 155, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/sresults.py", line 163, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 364, in iterSelect select, keepConnection=False) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/inheritance/iteration.py", line 10, in __init__ super(InheritableIteration, self).__init__(dbconn, rawconn, select, keepConnection) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 704, in __init__ self.dbconn._executeRetry(self.rawconn, self.cursor, self.query) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py", line 298, in _executeRetry return cursor.execute(query) psycopg.ProgrammingError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list SELECT DISTINCT base_sample.id, base_sample.child_name, base_sample.name FROM base, base_sample WHERE ((1 = 1) AND ((base_sample.id) = (base.id))) ORDER BY base.created Additional information. SQLObject-0.7.1dev_r1860 TurboGears-1.0b1 Ubuntu $ uname -a Linux svetlana-desktop 2.6.15-28-amd64-generic #1 SMP PREEMPT Thu Feb 1 15:53:41 UTC 2007 x86_64 GNU/Linux ---------------------------------------------------------------------- >Comment By: Vladimir Chukharev (chukharevv) Date: 2007-03-17 08:27 Message: Logged In: YES user_id=607106 Originator: YES Thanks a lot for your followup. We have upgraded our system for the use of SO 0.8 (BTW, some changes to our code were needed with the names of foreign key fields, perhaps something about possible incompatibility of the versions is due for the release notes). Indeed, the previous example now works. But the same conflict remains, just the table changed from Base to BaseSample for our test. As a continuation of your commands: print list(BaseSample.select(orderBy=BaseSample.q.name, distinct=True)) 1/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base, base_sample WHERE (((base.child_name) = ('BaseSample')) AND ((base_sample.id) = (base.id))) ORDER BY base_sample.name 1/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base, base_sample WHERE (((base.child_name) = ('BaseSample')) AND ((base_sample.id) = (base.id))) ORDER BY base_sample.name Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/sresults.py", line 160, in __iter__ return iter(list(self.lazyIter())) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/sresults.py", line 168, in lazyIter return conn.iterSelect(self) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/dbconnection.py", line 374, in iterSelect select, keepConnection=False) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/inheritance/iteration.py", line 10, in __init__ super(InheritableIteration, self).__init__(dbconn, rawconn, select, keepConnection) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/dbconnection.py", line 760, in __init__ self.dbconn._executeRetry(self.rawconn, self.cursor, self.query) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/dbconnection.py", line 308, in _executeRetry return cursor.execute(query) psycopg.ProgrammingError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list SELECT DISTINCT base.id, base.created, base.child_name FROM base, base_sample WHERE (((base.child_name) = ('BaseSample')) AND ((base_sample.id) = (base.id))) ORDER BY base_sample.name Thanks again, V. Chukharev PS. As a side note, is lack of distinct parameter from Select() intentional and can that be fixed? PPS. Thanks for spotting now() insead of now. It was forgotten after some experiments with both variants. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2007-02-28 11:29 Message: Logged In: YES user_id=4799 Originator: NO Works in SQLObject 0.8: from datetime import datetime from sqlobject import * from sqlobject.inheritance import InheritableSQLObject from sqlobject.sqlbuilder import * __connection__ = "postgres:/test?debug=1" class Base(InheritableSQLObject): created = DateTimeCol(default=DateTimeCol.now()) class BaseSample(Base): name = StringCol(length=40, alternateID=True) Base.createTable(ifNotExists=True) BaseSample.createTable(ifNotExists=True) sample = BaseSample(name='Sample1') order=BaseSample.q.created print list(BaseSample.select(orderBy=order)) print list(BaseSample.select(distinct=True)) print list(BaseSample.select(orderBy=order, distinct=True)) Debugging output; please note base.created is in the select list in the last SELECT DISTINCT query: 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'base' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'base' 1/COMMIT : auto 1/Query : CREATE TABLE base ( id SERIAL PRIMARY KEY, created TIMESTAMP, child_name VARCHAR(255) ) 1/QueryR : CREATE TABLE base ( id SERIAL PRIMARY KEY, created TIMESTAMP, child_name VARCHAR(255) ) 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'base_sample' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'base_sample' 1/COMMIT : auto 1/Query : CREATE TABLE base_sample ( id SERIAL PRIMARY KEY, name VARCHAR(40) NOT NULL UNIQUE, child_name VARCHAR(255) ) 1/QueryR : CREATE TABLE base_sample ( id SERIAL PRIMARY KEY, name VARCHAR(40) NOT NULL UNIQUE, child_name VARCHAR(255) ) 1/COMMIT : auto 1/QueryIns: INSERT INTO base (id, child_name, created) VALUES (1, 'BaseSample', '2007-02-28 14:24:22') 1/COMMIT : auto 1/QueryOne: SELECT created, child_name FROM base WHERE id = (1) 1/QueryR : SELECT created, child_name FROM base WHERE id = (1) 1/COMMIT : auto 1/QueryIns: INSERT INTO base_sample (id, name, child_name) VALUES (1, 'Sample1', NULL) 1/COMMIT : auto 1/QueryOne: SELECT name, child_name FROM base_sample WHERE id = (1) 1/QueryR : SELECT name, child_name FROM base_sample WHERE id = (1) 1/COMMIT : auto 1/Select : SELECT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/QueryR : SELECT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] 1/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) 1/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] 1/Select : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/QueryR : SELECT DISTINCT base.id, base.created, base.child_name FROM base WHERE ((base.child_name) = ('BaseSample')) ORDER BY base.created 1/Select children of the class BaseSample: SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/QueryR : SELECT base_sample.id, base_sample.name, base_sample.child_name FROM base_sample WHERE ((base_sample.id) = (1)) 1/COMMIT : auto [<BaseSample 1L name='Sample1' created='datetime.datetime...)'>] PS. I hope you understand the difference between created = DateTimeCol(default=DateTimeCol.now()) and created = DateTimeCol(default=DateTimeCol.now) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1670239&group_id=74338 |
|
From: <sub...@co...> - 2007-03-16 16:03:57
|
Author: phd
Date: 2007-03-16 10:03:48 -0600 (Fri, 16 Mar 2007)
New Revision: 2420
Modified:
home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
Log:
Merged patches from the revisions 2413:2419 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2007-03-16 16:01:50 UTC (rev 2419)
+++ home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2007-03-16 16:03:48 UTC (rev 2420)
@@ -1032,7 +1032,7 @@
conn.rollback()
raise
else:
- conn.commit()
+ conn.commit(close=True)
return value
finally:
self.threadConnection = old_conn
|
|
From: <sub...@co...> - 2007-03-16 16:02:00
|
Author: phd Date: 2007-03-16 10:01:50 -0600 (Fri, 16 Mar 2007) New Revision: 2419 Modified: SQLObject/docs/News.txt Log: Fixed ConnectionHub.doInTransaction() - close low-level connection on commit() to prevent connections leaking. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-03-16 16:01:27 UTC (rev 2418) +++ SQLObject/docs/News.txt 2007-03-16 16:01:50 UTC (rev 2419) @@ -73,6 +73,9 @@ * Fixed and simplified DatabaseIndex.get(). +* Fixed ConnectionHub.doInTransaction() - close low-level connection on + commit() to prevent connections leaking. + SQLObject 0.8.0 =============== |
|
From: <sub...@co...> - 2007-03-16 16:01:30
|
Author: phd
Date: 2007-03-16 10:01:27 -0600 (Fri, 16 Mar 2007)
New Revision: 2418
Modified:
SQLObject/branches/0.8/docs/News.txt
SQLObject/branches/0.8/sqlobject/dbconnection.py
Log:
Fixed ConnectionHub.doInTransaction() - close low-level connection on commit()
to prevent connections leaking.
Modified: SQLObject/branches/0.8/docs/News.txt
===================================================================
--- SQLObject/branches/0.8/docs/News.txt 2007-03-16 16:01:08 UTC (rev 2417)
+++ SQLObject/branches/0.8/docs/News.txt 2007-03-16 16:01:27 UTC (rev 2418)
@@ -20,6 +20,9 @@
* Fixed and simplified DatabaseIndex.get().
+* Fixed ConnectionHub.doInTransaction() - close low-level connection on
+ commit() to prevent connections leaking.
+
SQLObject 0.8.0
===============
Modified: SQLObject/branches/0.8/sqlobject/dbconnection.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/dbconnection.py 2007-03-16 16:01:08 UTC (rev 2417)
+++ SQLObject/branches/0.8/sqlobject/dbconnection.py 2007-03-16 16:01:27 UTC (rev 2418)
@@ -983,7 +983,7 @@
conn.rollback()
raise
else:
- conn.commit()
+ conn.commit(close=True)
return value
finally:
self.threadConnection = old_conn
|
|
From: <sub...@co...> - 2007-03-16 16:01:27
|
Author: phd
Date: 2007-03-16 10:01:08 -0600 (Fri, 16 Mar 2007)
New Revision: 2417
Modified:
SQLObject/trunk/sqlobject/dbconnection.py
Log:
Fixed ConnectionHub.doInTransaction() - close low-level connection on commit()
to prevent connections leaking.
Modified: SQLObject/trunk/sqlobject/dbconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/dbconnection.py 2007-03-16 15:46:23 UTC (rev 2416)
+++ SQLObject/trunk/sqlobject/dbconnection.py 2007-03-16 16:01:08 UTC (rev 2417)
@@ -1021,7 +1021,7 @@
conn.rollback()
raise
else:
- conn.commit()
+ conn.commit(close=True)
return value
finally:
self.threadConnection = old_conn
|
|
From: <sub...@co...> - 2007-03-16 15:46:34
|
Author: phd
Date: 2007-03-16 09:46:23 -0600 (Fri, 16 Mar 2007)
New Revision: 2416
Modified:
SQLObject/branches/0.7/docs/SQLObject.txt
Log:
Documentation update - connection pooling and transactions.
Modified: SQLObject/branches/0.7/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.7/docs/SQLObject.txt 2007-03-16 15:46:03 UTC (rev 2415)
+++ SQLObject/branches/0.7/docs/SQLObject.txt 2007-03-16 15:46:23 UTC (rev 2416)
@@ -1313,6 +1313,19 @@
Similar to `MultipleJoin`, but returns just one object, not a list.
+Connection pooling
+------------------
+
+Connection object acquires a new low-level DB API connection from the pool
+and stores it; the low-level connection is removed from the pool;
+"releasing" means "return it to the pool". For single-threaded programs
+there is one connection in the pool.
+
+If the pool is empty a new low-level connection opened; if one has
+disabled pooling (by setting conn._pool = None) the connection will be
+closed instead of returning to the pool.
+
+
Transactions
------------
@@ -1331,15 +1344,19 @@
database connection, and `commit` and `rollback` just pass that
message to the low-level connection.
-If you want to begin a new transaction after a .rollback() call .begin().
+One can call as much .commit()'s, but after a .rollback() one has to call
+.begin().
If you want to use transactions you should also turn `_cacheValues`
-off, like:
+off, like::
class Person(SQLObject):
- _cacheValue = False
- # ...
+ _cacheValues = False
+This, though, makes attribute access very slow (SQLObject queries database
+for an every attribute access). If one wants to set `_cacheValues = True`
+one has to synchronize objects between threads herself.
+
Automatic Schema Generation
---------------------------
|
|
From: <sub...@co...> - 2007-03-16 15:46:16
|
Author: phd
Date: 2007-03-16 09:46:03 -0600 (Fri, 16 Mar 2007)
New Revision: 2415
Modified:
SQLObject/branches/0.8/docs/SQLObject.txt
Log:
Documentation update - connection pooling and transactions.
Modified: SQLObject/branches/0.8/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.8/docs/SQLObject.txt 2007-03-16 15:45:41 UTC (rev 2414)
+++ SQLObject/branches/0.8/docs/SQLObject.txt 2007-03-16 15:46:03 UTC (rev 2415)
@@ -1314,6 +1314,19 @@
Similar to `MultipleJoin`, but returns just one object, not a list.
+Connection pooling
+------------------
+
+Connection object acquires a new low-level DB API connection from the pool
+and stores it; the low-level connection is removed from the pool;
+"releasing" means "return it to the pool". For single-threaded programs
+there is one connection in the pool.
+
+If the pool is empty a new low-level connection opened; if one has
+disabled pooling (by setting conn._pool = None) the connection will be
+closed instead of returning to the pool.
+
+
Transactions
------------
@@ -1332,8 +1345,20 @@
database connection, and `commit` and `rollback` just pass that
message to the low-level connection.
-If you want to begin a new transaction after a .rollback() call .begin().
+One can call as much .commit()'s, but after a .rollback() one has to call
+.begin(). The last .commit() should be called as .commit(close=True) to
+release low-level connection.
+If you want to use transactions you should also turn `_cacheValues`
+off, like::
+
+ class Person(SQLObject):
+ _cacheValue = False
+
+This, though, makes attribute access very slow (SQLObject queries database
+for an every attribute access). If one wants to set `_cacheValue = True`
+one has to synchronize objects between threads herself.
+
You can use SELECT FOR UPDATE in those databases that support it::
Person.select(Person.q.name=="value", forUpdate=True)
|
|
From: <sub...@co...> - 2007-03-16 15:45:47
|
Author: phd
Date: 2007-03-16 09:45:41 -0600 (Fri, 16 Mar 2007)
New Revision: 2414
Modified:
SQLObject/docs/SQLObject.txt
Log:
Documentation update - connection pooling and transactions.
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2007-03-15 19:37:51 UTC (rev 2413)
+++ SQLObject/docs/SQLObject.txt 2007-03-16 15:45:41 UTC (rev 2414)
@@ -1323,6 +1323,19 @@
Similar to `MultipleJoin`, but returns just one object, not a list.
+Connection pooling
+------------------
+
+Connection object acquires a new low-level DB API connection from the pool
+and stores it; the low-level connection is removed from the pool;
+"releasing" means "return it to the pool". For single-threaded programs
+there is one connection in the pool.
+
+If the pool is empty a new low-level connection opened; if one has
+disabled pooling (by setting conn._pool = None) the connection will be
+closed instead of returning to the pool.
+
+
Transactions
------------
@@ -1341,8 +1354,20 @@
database connection, and `commit` and `rollback` just pass that
message to the low-level connection.
-If you want to begin a new transaction after a .rollback() call .begin().
+One can call as much .commit()'s, but after a .rollback() one has to call
+.begin(). The last .commit() should be called as .commit(close=True) to
+release low-level connection.
+If you want to use transactions you should also turn `_cacheValues`
+off, like::
+
+ class Person(SQLObject):
+ _cacheValue = False
+
+This, though, makes attribute access very slow (SQLObject queries database
+for an every attribute access). If one wants to set `_cacheValue = True`
+one has to synchronize objects between threads herself.
+
You can use SELECT FOR UPDATE in those databases that support it::
Person.select(Person.q.name=="value", forUpdate=True)
|
|
From: <sub...@co...> - 2007-03-14 16:41:08
|
Author: phd
Date: 2007-03-14 10:41:05 -0600 (Wed, 14 Mar 2007)
New Revision: 2411
Added:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_indexes.py
Removed:
home/phd/SQLObject/paramstyles/sqlobject/tests/test_index_get.py
Modified:
home/phd/SQLObject/paramstyles/sqlobject/index.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_indexes.py
Log:
Merged patches from the revisions 2406:2410 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/index.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/index.py 2007-03-14 16:19:05 UTC (rev 2410)
+++ home/phd/SQLObject/paramstyles/sqlobject/index.py 2007-03-14 16:41:05 UTC (rev 2411)
@@ -23,19 +23,18 @@
raise TypeError, "You cannot mix named and unnamed arguments"
columns = [d['column'] for d in self.descriptions
if d.has_key('column')]
- if kw:
- args = []
- for i in xrange(len(columns)):
- args.append(kw[columns[i].name])
- del kw[columns[i].name]
- if kw or len(args) != len(columns):
+ if kw and len(kw) != len(columns) or args and len(args) != len(columns):
raise TypeError, ("get() takes exactly %d argument and an optional "
"named argument 'connection' (%d given)" % (
len(columns), len(args)+len(kw)))
- cols = [c.name for c in columns]
- dbcols = [c.dbName for c in columns]
- return self.soClass._SO_fetchAlternateID(cols, dbcols, args,
- connection=connection, idxName=self.name)
+ if args:
+ kw = {}
+ for i in range(len(args)):
+ if columns[i].foreignName is not None:
+ kw[columns[i].foreignName] = args[i]
+ else:
+ kw[columns[i].name] = args[i]
+ return self.soClass.selectBy(connection=connection, **kw).getOne()
def convertColumns(self, columns):
"""
Copied: home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_indexes.py (from rev 2410, SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py)
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_indexes.py (rev 0)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_indexes.py 2007-03-14 16:41:05 UTC (rev 2411)
@@ -0,0 +1,40 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+
+class InheritedPersonIndexGet(InheritableSQLObject):
+ first_name = StringCol(notNone=True)
+ last_name = StringCol(notNone=True)
+ age = IntCol()
+ pk = DatabaseIndex(first_name, last_name, unique=True)
+
+class InheritedEmployeeIndexGet(InheritedPersonIndexGet):
+ security_number = IntCol()
+ experience = IntCol()
+ sec_index = DatabaseIndex(security_number, unique=True)
+
+class InheritedSalesManIndexGet(InheritedEmployeeIndexGet):
+ _inheritable = False
+ skill = IntCol()
+
+
+def test_index_get_1():
+ setupClass([InheritedPersonIndexGet, InheritedEmployeeIndexGet, InheritedSalesManIndexGet])
+
+ InheritedSalesManIndexGet(first_name='Michael', last_name='Pallin', age=65, security_number=2304,
+ experience=2, skill=10)
+ InheritedEmployeeIndexGet(first_name='Eric', last_name='Idle', age=63, security_number=3402,
+ experience=9)
+ InheritedPersonIndexGet(first_name='Terry', last_name='Guilliam', age=64)
+
+ InheritedPersonIndexGet.pk.get('Michael', 'Pallin')
+ InheritedEmployeeIndexGet.pk.get('Michael', 'Pallin')
+ InheritedSalesManIndexGet.pk.get('Michael', 'Pallin')
+ InheritedPersonIndexGet.pk.get('Eric', 'Idle')
+ InheritedEmployeeIndexGet.pk.get('Eric', 'Idle')
+ InheritedPersonIndexGet.pk.get(first_name='Terry', last_name='Guilliam')
+ InheritedEmployeeIndexGet.sec_index.get(2304)
+ InheritedEmployeeIndexGet.sec_index.get(3402)
+ InheritedSalesManIndexGet.sec_index.get(2304)
+ InheritedSalesManIndexGet.sec_index.get(3402)
Deleted: home/phd/SQLObject/paramstyles/sqlobject/tests/test_index_get.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_index_get.py 2007-03-14 16:19:05 UTC (rev 2410)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_index_get.py 2007-03-14 16:41:05 UTC (rev 2411)
@@ -1,47 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-
-class PersonIndexGet(SQLObject):
- firstName = StringCol()
- lastName = StringCol()
- age = IntCol(alternateID=True)
- nameIndex = DatabaseIndex(firstName, lastName, unique=True)
-
-def test_1():
- setupClass(PersonIndexGet, force=True)
-
- PersonIndexGet(firstName='Eric', lastName='Idle', age=62)
- PersonIndexGet(firstName='Terry', lastName='Gilliam', age=65)
- PersonIndexGet(firstName='John', lastName='Cleese', age=66)
-
- PersonIndexGet.get(1)
- PersonIndexGet.nameIndex.get('Terry', 'Gilliam')
- PersonIndexGet.nameIndex.get(firstName='John', lastName='Cleese')
-
- try:
- print PersonIndexGet.nameIndex.get(firstName='Graham', lastName='Chapman')
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry', lastName='Gilliam')
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry', 'Gilliam', 65)
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry')
- except Exception, e:
- pass
- else:
- raise AssertError
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_indexes.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_indexes.py 2007-03-14 16:19:05 UTC (rev 2410)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_indexes.py 2007-03-14 16:41:05 UTC (rev 2411)
@@ -14,14 +14,11 @@
nameIndex2 = DatabaseIndex(name, number)
nameIndex3 = DatabaseIndex({'column': name,
'length': 3})
-
class SOIndex2(SQLObject):
-
name = StringCol()
-
nameIndex = DatabaseIndex({'expression': 'lower(name)'})
-def test_1():
+def test_indexes_1():
setupClass(SOIndex1)
n = 0
for name in 'blah blech boring yep yort snort'.split():
@@ -39,8 +36,76 @@
else:
assert 0, "Exception expected."
-def test_2():
+def test_indexes_2():
if not supports('expressionIndex'):
return
setupClass(SOIndex2)
SOIndex2(name='')
+
+
+class PersonIndexGet(SQLObject):
+ firstName = StringCol()
+ lastName = StringCol()
+ age = IntCol(alternateID=True)
+ nameIndex = DatabaseIndex(firstName, lastName, unique=True)
+
+def test_index_get_1():
+ setupClass(PersonIndexGet, force=True)
+
+ PersonIndexGet(firstName='Eric', lastName='Idle', age=62)
+ PersonIndexGet(firstName='Terry', lastName='Gilliam', age=65)
+ PersonIndexGet(firstName='John', lastName='Cleese', age=66)
+
+ PersonIndexGet.get(1)
+ PersonIndexGet.nameIndex.get('Terry', 'Gilliam')
+ PersonIndexGet.nameIndex.get(firstName='John', lastName='Cleese')
+
+ try:
+ print PersonIndexGet.nameIndex.get(firstName='Graham', lastName='Chapman')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry', lastName='Gilliam')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry', 'Gilliam', 65)
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+
+class PersonIndexGet2(SQLObject):
+ name = StringCol(alternateID=True)
+ age = IntCol()
+ addresses = MultipleJoin('AddressIndexGet2')
+
+class AddressIndexGet2(SQLObject):
+ person = ForeignKey('PersonIndexGet2', notNone=True)
+ type = StringCol(notNone=True)
+ street = StringCol(notNone=True)
+ pk = DatabaseIndex(person, type, unique=True)
+
+def test_index_get_2():
+ setupClass([PersonIndexGet2, AddressIndexGet2])
+
+ p = PersonIndexGet2(name='Terry Guilliam', age=64)
+ AddressIndexGet2(person=p, type='home', street='Terry Street 234')
+ AddressIndexGet2(person=p, type='work', street='Guilliam Street 234')
+
+ AddressIndexGet2.pk.get(p, 'work')
+ AddressIndexGet2.pk.get(person=p, type='work')
|
|
From: SourceForge.net <no...@so...> - 2007-03-14 16:39:19
|
Patches item #1675319, was opened at 2007-03-07 01:31 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1675319&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) >Assigned to: Oleg Broytmann (phd) Summary: DatabaseIndex.get() fix and simplification. Initial Comment: This is a reimplementation of DatabaseIndex.get() using selectBy() + getOne(). The current implementation had some issues with inheritance and when passing objects if a member of the index was a ForeingKey (passing something=something fails where somethingID=something.id works). This implementations is: 1) Simpler. 2) Smarter. Don't reinvent the wheel (uses existing, more tested and more robust functions). 3) Backward compatible. Attached is the patch, and 2 testcases: one testing Inheritance and the other object arguments passing. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-03-14 19:39 Message: Logged In: YES user_id=4799 Originator: NO Applied in the revisions 2407-2410. Thank you! ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-03-07 01:35 Message: Logged In: YES user_id=240225 Originator: YES File Added: DatabaseIndex.get-selectBy.getOne.patch ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-03-07 01:32 Message: Logged In: YES user_id=240225 Originator: YES File Added: test.inherit.py ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-03-07 01:32 Message: Logged In: YES user_id=240225 Originator: YES File Added: test.ids.py ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1675319&group_id=74338 |
|
From: <sub...@co...> - 2007-03-14 16:19:14
|
Author: phd Date: 2007-03-14 10:19:05 -0600 (Wed, 14 Mar 2007) New Revision: 2410 Modified: SQLObject/docs/News.txt Log: Fixed and simplified DatabaseIndex.get(). Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-03-14 16:18:35 UTC (rev 2409) +++ SQLObject/docs/News.txt 2007-03-14 16:19:05 UTC (rev 2410) @@ -71,6 +71,8 @@ * Fixed return value from Firebird/MaxdbConnection.createTable(). +* Fixed and simplified DatabaseIndex.get(). + SQLObject 0.8.0 =============== |
|
From: <sub...@co...> - 2007-03-14 16:18:38
|
Author: phd
Date: 2007-03-14 10:18:35 -0600 (Wed, 14 Mar 2007)
New Revision: 2409
Added:
SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py
Removed:
SQLObject/trunk/sqlobject/tests/test_index_get.py
Modified:
SQLObject/trunk/sqlobject/index.py
SQLObject/trunk/sqlobject/tests/test_indexes.py
Log:
Applied the patch 1675319: DatabaseIndex.get() fix and simplification.
Merged tests/test_index_get.py into tests/test_indexes.py.
Modified: SQLObject/trunk/sqlobject/index.py
===================================================================
--- SQLObject/trunk/sqlobject/index.py 2007-03-14 15:53:09 UTC (rev 2408)
+++ SQLObject/trunk/sqlobject/index.py 2007-03-14 16:18:35 UTC (rev 2409)
@@ -23,19 +23,18 @@
raise TypeError, "You cannot mix named and unnamed arguments"
columns = [d['column'] for d in self.descriptions
if d.has_key('column')]
- if kw:
- args = []
- for i in xrange(len(columns)):
- args.append(kw[columns[i].name])
- del kw[columns[i].name]
- if kw or len(args) != len(columns):
+ if kw and len(kw) != len(columns) or args and len(args) != len(columns):
raise TypeError, ("get() takes exactly %d argument and an optional "
"named argument 'connection' (%d given)" % (
len(columns), len(args)+len(kw)))
- cols = [c.name for c in columns]
- dbcols = [c.dbName for c in columns]
- return self.soClass._SO_fetchAlternateID(cols, dbcols, args,
- connection=connection, idxName=self.name)
+ if args:
+ kw = {}
+ for i in range(len(args)):
+ if columns[i].foreignName is not None:
+ kw[columns[i].foreignName] = args[i]
+ else:
+ kw[columns[i].name] = args[i]
+ return self.soClass.selectBy(connection=connection, **kw).getOne()
def convertColumns(self, columns):
"""
Copied: SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py (from rev 2408, SQLObject/branches/0.8/sqlobject/inheritance/tests/test_indexes.py)
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py (rev 0)
+++ SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py 2007-03-14 16:18:35 UTC (rev 2409)
@@ -0,0 +1,40 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+
+class InheritedPersonIndexGet(InheritableSQLObject):
+ first_name = StringCol(notNone=True)
+ last_name = StringCol(notNone=True)
+ age = IntCol()
+ pk = DatabaseIndex(first_name, last_name, unique=True)
+
+class InheritedEmployeeIndexGet(InheritedPersonIndexGet):
+ security_number = IntCol()
+ experience = IntCol()
+ sec_index = DatabaseIndex(security_number, unique=True)
+
+class InheritedSalesManIndexGet(InheritedEmployeeIndexGet):
+ _inheritable = False
+ skill = IntCol()
+
+
+def test_index_get_1():
+ setupClass([InheritedPersonIndexGet, InheritedEmployeeIndexGet, InheritedSalesManIndexGet])
+
+ InheritedSalesManIndexGet(first_name='Michael', last_name='Pallin', age=65, security_number=2304,
+ experience=2, skill=10)
+ InheritedEmployeeIndexGet(first_name='Eric', last_name='Idle', age=63, security_number=3402,
+ experience=9)
+ InheritedPersonIndexGet(first_name='Terry', last_name='Guilliam', age=64)
+
+ InheritedPersonIndexGet.pk.get('Michael', 'Pallin')
+ InheritedEmployeeIndexGet.pk.get('Michael', 'Pallin')
+ InheritedSalesManIndexGet.pk.get('Michael', 'Pallin')
+ InheritedPersonIndexGet.pk.get('Eric', 'Idle')
+ InheritedEmployeeIndexGet.pk.get('Eric', 'Idle')
+ InheritedPersonIndexGet.pk.get(first_name='Terry', last_name='Guilliam')
+ InheritedEmployeeIndexGet.sec_index.get(2304)
+ InheritedEmployeeIndexGet.sec_index.get(3402)
+ InheritedSalesManIndexGet.sec_index.get(2304)
+ InheritedSalesManIndexGet.sec_index.get(3402)
Deleted: SQLObject/trunk/sqlobject/tests/test_index_get.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_index_get.py 2007-03-14 15:53:09 UTC (rev 2408)
+++ SQLObject/trunk/sqlobject/tests/test_index_get.py 2007-03-14 16:18:35 UTC (rev 2409)
@@ -1,47 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-
-class PersonIndexGet(SQLObject):
- firstName = StringCol()
- lastName = StringCol()
- age = IntCol(alternateID=True)
- nameIndex = DatabaseIndex(firstName, lastName, unique=True)
-
-def test_1():
- setupClass(PersonIndexGet, force=True)
-
- PersonIndexGet(firstName='Eric', lastName='Idle', age=62)
- PersonIndexGet(firstName='Terry', lastName='Gilliam', age=65)
- PersonIndexGet(firstName='John', lastName='Cleese', age=66)
-
- PersonIndexGet.get(1)
- PersonIndexGet.nameIndex.get('Terry', 'Gilliam')
- PersonIndexGet.nameIndex.get(firstName='John', lastName='Cleese')
-
- try:
- print PersonIndexGet.nameIndex.get(firstName='Graham', lastName='Chapman')
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry', lastName='Gilliam')
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry', 'Gilliam', 65)
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry')
- except Exception, e:
- pass
- else:
- raise AssertError
Modified: SQLObject/trunk/sqlobject/tests/test_indexes.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_indexes.py 2007-03-14 15:53:09 UTC (rev 2408)
+++ SQLObject/trunk/sqlobject/tests/test_indexes.py 2007-03-14 16:18:35 UTC (rev 2409)
@@ -14,14 +14,11 @@
nameIndex2 = DatabaseIndex(name, number)
nameIndex3 = DatabaseIndex({'column': name,
'length': 3})
-
class SOIndex2(SQLObject):
-
name = StringCol()
-
nameIndex = DatabaseIndex({'expression': 'lower(name)'})
-def test_1():
+def test_indexes_1():
setupClass(SOIndex1)
n = 0
for name in 'blah blech boring yep yort snort'.split():
@@ -39,8 +36,76 @@
else:
assert 0, "Exception expected."
-def test_2():
+def test_indexes_2():
if not supports('expressionIndex'):
return
setupClass(SOIndex2)
SOIndex2(name='')
+
+
+class PersonIndexGet(SQLObject):
+ firstName = StringCol()
+ lastName = StringCol()
+ age = IntCol(alternateID=True)
+ nameIndex = DatabaseIndex(firstName, lastName, unique=True)
+
+def test_index_get_1():
+ setupClass(PersonIndexGet, force=True)
+
+ PersonIndexGet(firstName='Eric', lastName='Idle', age=62)
+ PersonIndexGet(firstName='Terry', lastName='Gilliam', age=65)
+ PersonIndexGet(firstName='John', lastName='Cleese', age=66)
+
+ PersonIndexGet.get(1)
+ PersonIndexGet.nameIndex.get('Terry', 'Gilliam')
+ PersonIndexGet.nameIndex.get(firstName='John', lastName='Cleese')
+
+ try:
+ print PersonIndexGet.nameIndex.get(firstName='Graham', lastName='Chapman')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry', lastName='Gilliam')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry', 'Gilliam', 65)
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+
+class PersonIndexGet2(SQLObject):
+ name = StringCol(alternateID=True)
+ age = IntCol()
+ addresses = MultipleJoin('AddressIndexGet2')
+
+class AddressIndexGet2(SQLObject):
+ person = ForeignKey('PersonIndexGet2', notNone=True)
+ type = StringCol(notNone=True)
+ street = StringCol(notNone=True)
+ pk = DatabaseIndex(person, type, unique=True)
+
+def test_index_get_2():
+ setupClass([PersonIndexGet2, AddressIndexGet2])
+
+ p = PersonIndexGet2(name='Terry Guilliam', age=64)
+ AddressIndexGet2(person=p, type='home', street='Terry Street 234')
+ AddressIndexGet2(person=p, type='work', street='Guilliam Street 234')
+
+ AddressIndexGet2.pk.get(p, 'work')
+ AddressIndexGet2.pk.get(person=p, type='work')
|
|
From: <sub...@co...> - 2007-03-14 15:53:14
|
Author: phd Date: 2007-03-14 09:53:09 -0600 (Wed, 14 Mar 2007) New Revision: 2408 Modified: SQLObject/branches/0.8/docs/News.txt Log: Fixed and simplified DatabaseIndex.get(). Modified: SQLObject/branches/0.8/docs/News.txt =================================================================== --- SQLObject/branches/0.8/docs/News.txt 2007-03-14 15:50:58 UTC (rev 2407) +++ SQLObject/branches/0.8/docs/News.txt 2007-03-14 15:53:09 UTC (rev 2408) @@ -7,6 +7,19 @@ .. _start: +SQLObject 0.8.1 +=============== + +Bug Fixes +--------- + +* ID columns are reverted back from INT UNSIGNED to INT for MySQL to be in + accord with FOREIGN KEYs. + +* Fixed return value from Firebird/MaxdbConnection.createTable(). + +* Fixed and simplified DatabaseIndex.get(). + SQLObject 0.8.0 =============== @@ -115,17 +128,6 @@ * Fixed aggregators and accumulators with inheritance. -SQLObject 0.8.1 -=============== - -Bug Fixes ---------- - -* ID columns are reverted back from INT UNSIGNED to INT for MySQL to be in - accord with FOREIGN KEYs. - -* Fixed return value from Firebird/MaxdbConnection.createTable(). - SQLObject 0.7.4 =============== |
|
From: <sub...@co...> - 2007-03-14 15:51:13
|
Author: phd
Date: 2007-03-14 09:50:58 -0600 (Wed, 14 Mar 2007)
New Revision: 2407
Added:
SQLObject/branches/0.8/sqlobject/inheritance/tests/test_indexes.py
Removed:
SQLObject/branches/0.8/sqlobject/tests/test_index_get.py
Modified:
SQLObject/branches/0.8/sqlobject/index.py
SQLObject/branches/0.8/sqlobject/tests/test_indexes.py
Log:
Applied the patch 1675319: DatabaseIndex.get() fix and simplification.
Merged tests/test_index_get.py into tests/test_indexes.py.
Modified: SQLObject/branches/0.8/sqlobject/index.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/index.py 2007-03-12 21:23:54 UTC (rev 2406)
+++ SQLObject/branches/0.8/sqlobject/index.py 2007-03-14 15:50:58 UTC (rev 2407)
@@ -23,19 +23,18 @@
raise TypeError, "You cannot mix named and unnamed arguments"
columns = [d['column'] for d in self.descriptions
if d.has_key('column')]
- if kw:
- args = []
- for i in xrange(len(columns)):
- args.append(kw[columns[i].name])
- del kw[columns[i].name]
- if kw or len(args) != len(columns):
+ if kw and len(kw) != len(columns) or args and len(args) != len(columns):
raise TypeError, ("get() takes exactly %d argument and an optional "
"named argument 'connection' (%d given)" % (
len(columns), len(args)+len(kw)))
- cols = [c.name for c in columns]
- dbcols = [c.dbName for c in columns]
- return self.soClass._SO_fetchAlternateID(cols, dbcols, args,
- connection=connection, idxName=self.name)
+ if args:
+ kw = {}
+ for i in range(len(args)):
+ if columns[i].foreignName is not None:
+ kw[columns[i].foreignName] = args[i]
+ else:
+ kw[columns[i].name] = args[i]
+ return self.soClass.selectBy(connection=connection, **kw).getOne()
def convertColumns(self, columns):
"""
Added: SQLObject/branches/0.8/sqlobject/inheritance/tests/test_indexes.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/inheritance/tests/test_indexes.py (rev 0)
+++ SQLObject/branches/0.8/sqlobject/inheritance/tests/test_indexes.py 2007-03-14 15:50:58 UTC (rev 2407)
@@ -0,0 +1,40 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+
+class InheritedPersonIndexGet(InheritableSQLObject):
+ first_name = StringCol(notNone=True)
+ last_name = StringCol(notNone=True)
+ age = IntCol()
+ pk = DatabaseIndex(first_name, last_name, unique=True)
+
+class InheritedEmployeeIndexGet(InheritedPersonIndexGet):
+ security_number = IntCol()
+ experience = IntCol()
+ sec_index = DatabaseIndex(security_number, unique=True)
+
+class InheritedSalesManIndexGet(InheritedEmployeeIndexGet):
+ _inheritable = False
+ skill = IntCol()
+
+
+def test_index_get_1():
+ setupClass([InheritedPersonIndexGet, InheritedEmployeeIndexGet, InheritedSalesManIndexGet])
+
+ InheritedSalesManIndexGet(first_name='Michael', last_name='Pallin', age=65, security_number=2304,
+ experience=2, skill=10)
+ InheritedEmployeeIndexGet(first_name='Eric', last_name='Idle', age=63, security_number=3402,
+ experience=9)
+ InheritedPersonIndexGet(first_name='Terry', last_name='Guilliam', age=64)
+
+ InheritedPersonIndexGet.pk.get('Michael', 'Pallin')
+ InheritedEmployeeIndexGet.pk.get('Michael', 'Pallin')
+ InheritedSalesManIndexGet.pk.get('Michael', 'Pallin')
+ InheritedPersonIndexGet.pk.get('Eric', 'Idle')
+ InheritedEmployeeIndexGet.pk.get('Eric', 'Idle')
+ InheritedPersonIndexGet.pk.get(first_name='Terry', last_name='Guilliam')
+ InheritedEmployeeIndexGet.sec_index.get(2304)
+ InheritedEmployeeIndexGet.sec_index.get(3402)
+ InheritedSalesManIndexGet.sec_index.get(2304)
+ InheritedSalesManIndexGet.sec_index.get(3402)
Deleted: SQLObject/branches/0.8/sqlobject/tests/test_index_get.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/tests/test_index_get.py 2007-03-12 21:23:54 UTC (rev 2406)
+++ SQLObject/branches/0.8/sqlobject/tests/test_index_get.py 2007-03-14 15:50:58 UTC (rev 2407)
@@ -1,47 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-
-class PersonIndexGet(SQLObject):
- firstName = StringCol()
- lastName = StringCol()
- age = IntCol(alternateID=True)
- nameIndex = DatabaseIndex(firstName, lastName, unique=True)
-
-def test_1():
- setupClass(PersonIndexGet, force=True)
-
- PersonIndexGet(firstName='Eric', lastName='Idle', age=62)
- PersonIndexGet(firstName='Terry', lastName='Gilliam', age=65)
- PersonIndexGet(firstName='John', lastName='Cleese', age=66)
-
- PersonIndexGet.get(1)
- PersonIndexGet.nameIndex.get('Terry', 'Gilliam')
- PersonIndexGet.nameIndex.get(firstName='John', lastName='Cleese')
-
- try:
- print PersonIndexGet.nameIndex.get(firstName='Graham', lastName='Chapman')
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry', lastName='Gilliam')
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry', 'Gilliam', 65)
- except Exception, e:
- pass
- else:
- raise AssertError
-
- try:
- print PersonIndexGet.nameIndex.get('Terry')
- except Exception, e:
- pass
- else:
- raise AssertError
Modified: SQLObject/branches/0.8/sqlobject/tests/test_indexes.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/tests/test_indexes.py 2007-03-12 21:23:54 UTC (rev 2406)
+++ SQLObject/branches/0.8/sqlobject/tests/test_indexes.py 2007-03-14 15:50:58 UTC (rev 2407)
@@ -14,14 +14,11 @@
nameIndex2 = DatabaseIndex(name, number)
nameIndex3 = DatabaseIndex({'column': name,
'length': 3})
-
class SOIndex2(SQLObject):
-
name = StringCol()
-
nameIndex = DatabaseIndex({'expression': 'lower(name)'})
-def test_1():
+def test_indexes_1():
setupClass(SOIndex1)
n = 0
for name in 'blah blech boring yep yort snort'.split():
@@ -39,8 +36,76 @@
else:
assert 0, "Exception expected."
-def test_2():
+def test_indexes_2():
if not supports('expressionIndex'):
return
setupClass(SOIndex2)
SOIndex2(name='')
+
+
+class PersonIndexGet(SQLObject):
+ firstName = StringCol()
+ lastName = StringCol()
+ age = IntCol(alternateID=True)
+ nameIndex = DatabaseIndex(firstName, lastName, unique=True)
+
+def test_index_get_1():
+ setupClass(PersonIndexGet, force=True)
+
+ PersonIndexGet(firstName='Eric', lastName='Idle', age=62)
+ PersonIndexGet(firstName='Terry', lastName='Gilliam', age=65)
+ PersonIndexGet(firstName='John', lastName='Cleese', age=66)
+
+ PersonIndexGet.get(1)
+ PersonIndexGet.nameIndex.get('Terry', 'Gilliam')
+ PersonIndexGet.nameIndex.get(firstName='John', lastName='Cleese')
+
+ try:
+ print PersonIndexGet.nameIndex.get(firstName='Graham', lastName='Chapman')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry', lastName='Gilliam')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry', 'Gilliam', 65)
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+ try:
+ print PersonIndexGet.nameIndex.get('Terry')
+ except Exception, e:
+ pass
+ else:
+ raise AssertError
+
+
+class PersonIndexGet2(SQLObject):
+ name = StringCol(alternateID=True)
+ age = IntCol()
+ addresses = MultipleJoin('AddressIndexGet2')
+
+class AddressIndexGet2(SQLObject):
+ person = ForeignKey('PersonIndexGet2', notNone=True)
+ type = StringCol(notNone=True)
+ street = StringCol(notNone=True)
+ pk = DatabaseIndex(person, type, unique=True)
+
+def test_index_get_2():
+ setupClass([PersonIndexGet2, AddressIndexGet2])
+
+ p = PersonIndexGet2(name='Terry Guilliam', age=64)
+ AddressIndexGet2(person=p, type='home', street='Terry Street 234')
+ AddressIndexGet2(person=p, type='work', street='Guilliam Street 234')
+
+ AddressIndexGet2.pk.get(p, 'work')
+ AddressIndexGet2.pk.get(person=p, type='work')
|