sqlobject-cvs Mailing List for SQLObject (Page 173)
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...> - 2005-01-07 11:16:40
|
Author: phd
Date: 2005-01-07 11:16:34 +0000 (Fri, 07 Jan 2005)
New Revision: 519
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Changed IntValidator.toPython - it now calls int() to convert non-integer value.
Modified: trunk/SQLObject/sqlobject/col.py
===================================================================
--- trunk/SQLObject/sqlobject/col.py 2005-01-06 00:52:22 UTC (rev 518)
+++ trunk/SQLObject/sqlobject/col.py 2005-01-07 11:16:34 UTC (rev 519)
@@ -386,10 +386,16 @@
def toPython(self, value, state):
if value is None:
return None
- if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
+ if isinstance(value, (int, long, sqlbuilder.SQLExpression)):
+ return value
+ try:
+ try:
+ return int(value)
+ except OverflowError: # for Python 2.2
+ return long(value)
+ except:
raise validators.InvalidField("expected an int in the IntCol '%s', got %s instead" % \
(self.name, type(value)), value, state)
- return value
class SOIntCol(SOCol):
validatorClass = IntValidator # can be overriden in descendants
|
|
From: <sub...@co...> - 2005-01-05 14:45:21
|
Author: phd
Date: 2005-01-05 14:45:15 +0000 (Wed, 05 Jan 2005)
New Revision: 517
Modified:
home/phd/SQLObject/inheritance/sqlobject/col.py
home/phd/SQLObject/inheritance/sqlobject/include/validators.py
home/phd/SQLObject/inheritance/tests/test_sqlobject.py
Log:
Merged patches from revisions 509:516
Modified: home/phd/SQLObject/inheritance/sqlobject/col.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/col.py 2005-01-05 14:40:38 UTC (rev 516)
+++ home/phd/SQLObject/inheritance/sqlobject/col.py 2005-01-05 14:45:15 UTC (rev 517)
@@ -346,31 +346,67 @@
def fromPython(self, value, state):
if value is None:
return None
+ if isinstance(value, str):
+ return value
return value.encode(self.db_encoding)
def toPython(self, value, state):
if value is None:
return None
+ if isinstance(value, unicode):
+ return value
return unicode(value, self.db_encoding)
class SOUnicodeCol(SOStringCol):
+ validatorClass = UnicodeStringValidator # can be overriden in descendants
def __init__(self, **kw):
self.dbEncoding = popKey(kw, 'dbEncoding', 'UTF-8')
SOStringCol.__init__(self, **kw)
- self.validator = validators.All.join(
- UnicodeStringValidator(self.dbEncoding), self.validator)
+ self.validator = validators.All.join(self.createValidator(), self.validator)
+ def createValidator(self):
+ """Create a validator for the column. Can be overriden in descendants."""
+ return self.validatorClass(self.dbEncoding)
+
class UnicodeCol(Col):
baseClass = SOUnicodeCol
+
+class IntValidator(validators.Validator):
+
+ def fromPython(self, value, state):
+ if value is None:
+ return None
+ if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
+ raise validators.InvalidField("expected an int in the IntCol '%s', got %s instead" % \
+ (self.name, type(value)), value, state)
+ return value
+
+ def toPython(self, value, state):
+ if value is None:
+ return None
+ if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
+ raise validators.InvalidField("expected an int in the IntCol '%s', got %s instead" % \
+ (self.name, type(value)), value, state)
+ return value
+
class SOIntCol(SOCol):
+ validatorClass = IntValidator # can be overriden in descendants
# 3-03 @@: support precision, maybe max and min directly
+ def __init__(self, **kw):
+ SOCol.__init__(self, **kw)
+ self.validator = validators.All.join(self.createValidator(), self.validator)
+
def autoConstraints(self):
return [consts.isInt]
+ def createValidator(self):
+ """Create a validator for the column. Can be overriden in descendants."""
+ return self.validatorClass(name=self.name)
+
def _sqlType(self):
return 'INT'
@@ -392,14 +428,19 @@
return sqlbuilder.TRUE
class SOBoolCol(SOCol):
+ validatorClass = BoolValidator # can be overriden in descendants
def __init__(self, **kw):
SOCol.__init__(self, **kw)
- self.validator = validators.All.join(BoolValidator(), self.validator)
+ self.validator = validators.All.join(self.createValidator(), self.validator)
def autoConstraints(self):
return [consts.isBool]
+ def createValidator(self):
+ """Create a validator for the column. Can be overriden in descendants."""
+ return self.validatorClass()
+
def _postgresType(self):
return 'BOOL'
Modified: home/phd/SQLObject/inheritance/sqlobject/include/validators.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/include/validators.py 2005-01-05 14:40:38 UTC (rev 516)
+++ home/phd/SQLObject/inheritance/sqlobject/include/validators.py 2005-01-05 14:45:15 UTC (rev 517)
@@ -224,13 +224,11 @@
self.validators = validators
FancyValidator.__init__(self, ifInvalid=ifInvalid, **kw)
- def _toPython(self, value, state=None):
- return self.attemptConvert(self, value, state,
- toPython)
+ def toPython(self, value, state=None):
+ return self.attemptConvert(value, state, toPython)
- def _fromPython(self, value, state):
- return self.attemptConvert(self, value, state,
- fromPython)
+ def fromPython(self, value, state):
+ return self.attemptConvert(value, state, fromPython)
def matchesProtocol(self, validator, state):
target = validator.protocols
Modified: home/phd/SQLObject/inheritance/tests/test_sqlobject.py
===================================================================
--- home/phd/SQLObject/inheritance/tests/test_sqlobject.py 2005-01-05 14:40:38 UTC (rev 516)
+++ home/phd/SQLObject/inheritance/tests/test_sqlobject.py 2005-01-05 14:45:15 UTC (rev 517)
@@ -908,8 +908,6 @@
'name3', 'x')
t.name3 = 1L
self.assertEqual(t.name3, 1)
- t.name3 = '1'
- self.assertEqual(t.name3, 1)
t.name3 = 0
self.assertEqual(t.name3, 0)
|
|
From: <sub...@co...> - 2005-01-05 14:40:44
|
Author: phd
Date: 2005-01-05 14:40:38 +0000 (Wed, 05 Jan 2005)
New Revision: 516
Modified:
trunk/SQLObject/tests/test_sqlobject.py
Log:
Removed a test - IntCol now doesn't accept a string.
Modified: trunk/SQLObject/tests/test_sqlobject.py
===================================================================
--- trunk/SQLObject/tests/test_sqlobject.py 2005-01-05 14:39:54 UTC (rev 515)
+++ trunk/SQLObject/tests/test_sqlobject.py 2005-01-05 14:40:38 UTC (rev 516)
@@ -908,8 +908,6 @@
'name3', 'x')
t.name3 = 1L
self.assertEqual(t.name3, 1)
- t.name3 = '1'
- self.assertEqual(t.name3, 1)
t.name3 = 0
self.assertEqual(t.name3, 0)
|
|
From: <sub...@co...> - 2005-01-05 14:40:02
|
Author: phd
Date: 2005-01-05 14:39:54 +0000 (Wed, 05 Jan 2005)
New Revision: 515
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Raise InvalidField instead of TypeError.
Modified: trunk/SQLObject/sqlobject/col.py
===================================================================
--- trunk/SQLObject/sqlobject/col.py 2005-01-05 14:38:39 UTC (rev 514)
+++ trunk/SQLObject/sqlobject/col.py 2005-01-05 14:39:54 UTC (rev 515)
@@ -379,16 +379,16 @@
if value is None:
return None
if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
- raise TypeError, "expected an int in the IntCol '%s', got %s instead" % \
- (self.name, type(value))
+ raise validators.InvalidField("expected an int in the IntCol '%s', got %s instead" % \
+ (self.name, type(value)), value, state)
return value
def toPython(self, value, state):
if value is None:
return None
if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
- raise TypeError, "expected an int in the IntCol '%s', got %s instead" % \
- (self.name, type(value))
+ raise validators.InvalidField("expected an int in the IntCol '%s', got %s instead" % \
+ (self.name, type(value)), value, state)
return value
class SOIntCol(SOCol):
|
|
From: <sub...@co...> - 2005-01-05 14:38:45
|
Author: phd
Date: 2005-01-05 14:38:39 +0000 (Wed, 05 Jan 2005)
New Revision: 514
Modified:
trunk/SQLObject/sqlobject/include/validators.py
Log:
Fixed a number of bugs in calls to fromPython/toPython/attemptConvert.
Modified: trunk/SQLObject/sqlobject/include/validators.py
===================================================================
--- trunk/SQLObject/sqlobject/include/validators.py 2005-01-05 13:15:21 UTC (rev 513)
+++ trunk/SQLObject/sqlobject/include/validators.py 2005-01-05 14:38:39 UTC (rev 514)
@@ -224,13 +224,11 @@
self.validators = validators
FancyValidator.__init__(self, ifInvalid=ifInvalid, **kw)
- def _toPython(self, value, state=None):
- return self.attemptConvert(self, value, state,
- toPython)
+ def toPython(self, value, state=None):
+ return self.attemptConvert(value, state, toPython)
- def _fromPython(self, value, state):
- return self.attemptConvert(self, value, state,
- fromPython)
+ def fromPython(self, value, state):
+ return self.attemptConvert(value, state, fromPython)
def matchesProtocol(self, validator, state):
target = validator.protocols
|
|
From: <sub...@co...> - 2005-01-05 13:15:45
|
Author: phd
Date: 2005-01-05 13:15:21 +0000 (Wed, 05 Jan 2005)
New Revision: 513
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Allowed sqlbuilder.SQLExpression and descendants in IntValidator.
Modified: trunk/SQLObject/sqlobject/col.py
===================================================================
--- trunk/SQLObject/sqlobject/col.py 2005-01-05 12:24:45 UTC (rev 512)
+++ trunk/SQLObject/sqlobject/col.py 2005-01-05 13:15:21 UTC (rev 513)
@@ -378,7 +378,7 @@
def fromPython(self, value, state):
if value is None:
return None
- if not isinstance(value, (int, long)):
+ if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
raise TypeError, "expected an int in the IntCol '%s', got %s instead" % \
(self.name, type(value))
return value
@@ -386,7 +386,7 @@
def toPython(self, value, state):
if value is None:
return None
- if not isinstance(value, (int, long)):
+ if not isinstance(value, (int, long, sqlbuilder.SQLExpression)):
raise TypeError, "expected an int in the IntCol '%s', got %s instead" % \
(self.name, type(value))
return value
|
|
From: <sub...@co...> - 2005-01-05 12:24:52
|
Author: phd
Date: 2005-01-05 12:24:45 +0000 (Wed, 05 Jan 2005)
New Revision: 512
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Added IntValidator that tests if an IntCol got only int or long;
raises TypeError if not.
Modified: trunk/SQLObject/sqlobject/col.py
===================================================================
--- trunk/SQLObject/sqlobject/col.py 2005-01-05 12:13:34 UTC (rev 511)
+++ trunk/SQLObject/sqlobject/col.py 2005-01-05 12:24:45 UTC (rev 512)
@@ -363,8 +363,7 @@
def __init__(self, **kw):
self.dbEncoding = popKey(kw, 'dbEncoding', 'UTF-8')
SOStringCol.__init__(self, **kw)
- self.validator = validators.All.join(
- self.createValidator(), self.validator)
+ self.validator = validators.All.join(self.createValidator(), self.validator)
def createValidator(self):
"""Create a validator for the column. Can be overriden in descendants."""
@@ -373,13 +372,41 @@
class UnicodeCol(Col):
baseClass = SOUnicodeCol
+
+class IntValidator(validators.Validator):
+
+ def fromPython(self, value, state):
+ if value is None:
+ return None
+ if not isinstance(value, (int, long)):
+ raise TypeError, "expected an int in the IntCol '%s', got %s instead" % \
+ (self.name, type(value))
+ return value
+
+ def toPython(self, value, state):
+ if value is None:
+ return None
+ if not isinstance(value, (int, long)):
+ raise TypeError, "expected an int in the IntCol '%s', got %s instead" % \
+ (self.name, type(value))
+ return value
+
class SOIntCol(SOCol):
+ validatorClass = IntValidator # can be overriden in descendants
# 3-03 @@: support precision, maybe max and min directly
+ def __init__(self, **kw):
+ SOCol.__init__(self, **kw)
+ self.validator = validators.All.join(self.createValidator(), self.validator)
+
def autoConstraints(self):
return [consts.isInt]
+ def createValidator(self):
+ """Create a validator for the column. Can be overriden in descendants."""
+ return self.validatorClass(name=self.name)
+
def _sqlType(self):
return 'INT'
|
|
From: <sub...@co...> - 2005-01-05 12:13:40
|
Author: phd
Date: 2005-01-05 12:13:34 +0000 (Wed, 05 Jan 2005)
New Revision: 511
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Do not convert str in UnicodeStringValidator.fromPython();
do not convert unicode in UnicodeStringValidator.toPython().
Modified: trunk/SQLObject/sqlobject/col.py
===================================================================
--- trunk/SQLObject/sqlobject/col.py 2005-01-05 12:08:42 UTC (rev 510)
+++ trunk/SQLObject/sqlobject/col.py 2005-01-05 12:13:34 UTC (rev 511)
@@ -346,11 +346,15 @@
def fromPython(self, value, state):
if value is None:
return None
+ if isinstance(value, str):
+ return value
return value.encode(self.db_encoding)
def toPython(self, value, state):
if value is None:
return None
+ if isinstance(value, unicode):
+ return value
return unicode(value, self.db_encoding)
class SOUnicodeCol(SOStringCol):
|
|
From: <sub...@co...> - 2005-01-05 12:08:48
|
Author: phd
Date: 2005-01-05 12:08:42 +0000 (Wed, 05 Jan 2005)
New Revision: 510
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Applied the law of Demeter: a class should not name (instantiate)
another class directly - the other class must be a parameter. Now
UnicodeCol and BoolClo instantiate their validators using self.validatorClass;
to allow even better flexibility the validator is created in the
createValidator() method.
Modified: trunk/SQLObject/sqlobject/col.py
===================================================================
--- trunk/SQLObject/sqlobject/col.py 2005-01-05 11:43:06 UTC (rev 509)
+++ trunk/SQLObject/sqlobject/col.py 2005-01-05 12:08:42 UTC (rev 510)
@@ -354,13 +354,18 @@
return unicode(value, self.db_encoding)
class SOUnicodeCol(SOStringCol):
+ validatorClass = UnicodeStringValidator # can be overriden in descendants
def __init__(self, **kw):
self.dbEncoding = popKey(kw, 'dbEncoding', 'UTF-8')
SOStringCol.__init__(self, **kw)
self.validator = validators.All.join(
- UnicodeStringValidator(self.dbEncoding), self.validator)
+ self.createValidator(), self.validator)
+ def createValidator(self):
+ """Create a validator for the column. Can be overriden in descendants."""
+ return self.validatorClass(self.dbEncoding)
+
class UnicodeCol(Col):
baseClass = SOUnicodeCol
@@ -392,14 +397,19 @@
return sqlbuilder.TRUE
class SOBoolCol(SOCol):
+ validatorClass = BoolValidator # can be overriden in descendants
def __init__(self, **kw):
SOCol.__init__(self, **kw)
- self.validator = validators.All.join(BoolValidator(), self.validator)
+ self.validator = validators.All.join(self.createValidator(), self.validator)
def autoConstraints(self):
return [consts.isBool]
+ def createValidator(self):
+ """Create a validator for the column. Can be overriden in descendants."""
+ return self.validatorClass()
+
def _postgresType(self):
return 'BOOL'
|
|
From: <sub...@co...> - 2005-01-05 11:43:13
|
Author: phd
Date: 2005-01-05 11:43:06 +0000 (Wed, 05 Jan 2005)
New Revision: 509
Modified:
home/phd/SQLObject/inheritance/docs/SQLObject.txt
home/phd/SQLObject/inheritance/docs/build
home/phd/SQLObject/inheritance/examples/personaddress.py
Log:
Merged patches from revisions 502:508
Modified: home/phd/SQLObject/inheritance/docs/SQLObject.txt
===================================================================
--- home/phd/SQLObject/inheritance/docs/SQLObject.txt 2005-01-03 19:29:15 UTC (rev 508)
+++ home/phd/SQLObject/inheritance/docs/SQLObject.txt 2005-01-05 11:43:06 UTC (rev 509)
@@ -275,7 +275,20 @@
with non-database properties (there's no benefit, but it helps hide
the difference between database and non-database attributes).
+Lazy Updates
+------------
+By default SQLObject sends an ``UPDATE`` to the database for every
+attribute you set, or everytime you call ``.set()``. If you want to
+avoid this many updates, add ``_lazyUpdate = True`` to your class
+definition. Then updates will only be written to the database when
+you call ``inst.syncUpdate()`` or ``obj.sync()``: ``.sync()`` also
+refetches the data from the database, which ``.syncUpdate()`` does not
+do.
+
+When enabled instances will have a property ``dirty``, which indicates
+if there are pending updates. Inserts are still done immediately.
+
One-to-Many Relationships
-------------------------
@@ -455,6 +468,18 @@
.. _`SQLBuilder documentation`: SQLBuilder.html
+Select-By Method
+~~~~~~~~~~~~~~~~
+
+An alternative to ``.select`` is ``.selectBy``. It works like:
+
+.. raw:: html
+ :file: ../examples/snippets/person-select-by.html
+
+Each keyword argument is a column, and all the keyword arguments
+are ANDed together. The return value is a `SelectResult`, so you
+can slice it, count it, order it, etc.
+
Customizing the Objects
-----------------------
@@ -1083,7 +1108,7 @@
column -- strings can go in integer columns, dates in integers, etc.
SQLiteConnection doesn't support `automatic class generation`_ and
-SQLite does not support `runtime column changes`_ or transactions_.
+SQLite does not support `runtime column changes`_.
SQLite may have concurrency issues, depending on your usage in a
multi-threaded environment.
Modified: home/phd/SQLObject/inheritance/docs/build
===================================================================
--- home/phd/SQLObject/inheritance/docs/build 2005-01-03 19:29:15 UTC (rev 508)
+++ home/phd/SQLObject/inheritance/docs/build 2005-01-05 11:43:06 UTC (rev 509)
@@ -1,7 +1,7 @@
#!/bin/sh
-pushd ../examples > /dev/null
+cd ../examples
./examplestripper.py
-popd > /dev/null
+cd ../docs
buildhtml.py --report=2 --prune=.svn --prune=europython --silent --no-toc-backlinks
Modified: home/phd/SQLObject/inheritance/examples/personaddress.py
===================================================================
--- home/phd/SQLObject/inheritance/examples/personaddress.py 2005-01-03 19:29:15 UTC (rev 508)
+++ home/phd/SQLObject/inheritance/examples/personaddress.py 2005-01-05 11:43:06 UTC (rev 509)
@@ -56,6 +56,11 @@
# SELECT person.id FROM person WHERE person.first_name = 'John';
## end snippet
+## Snippet "person-select-by"
+peeps = Person.selectBy(firstName="John", lastName="Doe")
+## end snippet
+list(peeps)
+
## Snippet "person-select2"
peeps = Person.select(
AND(Address.q.personID == Person.q.id,
|
|
From: <sub...@co...> - 2004-12-30 17:05:30
|
Author: ianb Date: 2004-12-30 17:05:26 +0000 (Thu, 30 Dec 2004) New Revision: 506 Modified: trunk/SQLObject/docs/SQLObject.txt Log: Removed note that SQLite doesn't support transactions Modified: trunk/SQLObject/docs/SQLObject.txt =================================================================== --- trunk/SQLObject/docs/SQLObject.txt 2004-12-29 17:19:31 UTC (rev 505) +++ trunk/SQLObject/docs/SQLObject.txt 2004-12-30 17:05:26 UTC (rev 506) @@ -1108,7 +1108,7 @@ column -- strings can go in integer columns, dates in integers, etc. SQLiteConnection doesn't support `automatic class generation`_ and -SQLite does not support `runtime column changes`_ or transactions_. +SQLite does not support `runtime column changes`_. SQLite may have concurrency issues, depending on your usage in a multi-threaded environment. |
|
From: <sub...@co...> - 2004-12-29 17:19:33
|
Author: ianb Date: 2004-12-29 17:19:31 +0000 (Wed, 29 Dec 2004) New Revision: 505 Modified: trunk/SQLObject/docs/SQLObject.txt trunk/SQLObject/docs/build Log: * Fixed snippet reference * Made build use cd instead of pushd/popd Modified: trunk/SQLObject/docs/SQLObject.txt =================================================================== --- trunk/SQLObject/docs/SQLObject.txt 2004-12-29 17:02:51 UTC (rev 504) +++ trunk/SQLObject/docs/SQLObject.txt 2004-12-29 17:19:31 UTC (rev 505) @@ -474,7 +474,7 @@ An alternative to ``.select`` is ``.selectBy``. It works like: .. raw:: html - :file: ../examples/snippets/select-by.html + :file: ../examples/snippets/person-select-by.html Each keyword argument is a column, and all the keyword arguments are ANDed together. The return value is a `SelectResult`, so you Modified: trunk/SQLObject/docs/build =================================================================== --- trunk/SQLObject/docs/build 2004-12-29 17:02:51 UTC (rev 504) +++ trunk/SQLObject/docs/build 2004-12-29 17:19:31 UTC (rev 505) @@ -1,7 +1,7 @@ #!/bin/sh -pushd ../examples > /dev/null +cd ../examples ./examplestripper.py -popd > /dev/null +cd ../docs buildhtml.py --report=2 --prune=.svn --prune=europython --silent --no-toc-backlinks |
|
From: <sub...@co...> - 2004-12-29 17:03:27
|
Author: ianb Date: 2004-12-29 17:02:51 +0000 (Wed, 29 Dec 2004) New Revision: 504 Modified: trunk/SQLObject/docs/SQLObject.txt Log: Noted _lazyUpdate Modified: trunk/SQLObject/docs/SQLObject.txt =================================================================== --- trunk/SQLObject/docs/SQLObject.txt 2004-12-29 16:51:52 UTC (rev 503) +++ trunk/SQLObject/docs/SQLObject.txt 2004-12-29 17:02:51 UTC (rev 504) @@ -275,7 +275,20 @@ with non-database properties (there's no benefit, but it helps hide the difference between database and non-database attributes). +Lazy Updates +------------ +By default SQLObject sends an ``UPDATE`` to the database for every +attribute you set, or everytime you call ``.set()``. If you want to +avoid this many updates, add ``_lazyUpdate = True`` to your class +definition. Then updates will only be written to the database when +you call ``inst.syncUpdate()`` or ``obj.sync()``: ``.sync()`` also +refetches the data from the database, which ``.syncUpdate()`` does not +do. + +When enabled instances will have a property ``dirty``, which indicates +if there are pending updates. Inserts are still done immediately. + One-to-Many Relationships ------------------------- |
|
From: <sub...@co...> - 2004-12-29 16:51:59
|
Author: ianb
Date: 2004-12-29 16:51:52 +0000 (Wed, 29 Dec 2004)
New Revision: 503
Modified:
trunk/SQLObject/docs/SQLObject.txt
trunk/SQLObject/examples/personaddress.py
Log:
Added a note about .selectBy
Modified: trunk/SQLObject/docs/SQLObject.txt
===================================================================
--- trunk/SQLObject/docs/SQLObject.txt 2004-12-28 12:12:57 UTC (rev 502)
+++ trunk/SQLObject/docs/SQLObject.txt 2004-12-29 16:51:52 UTC (rev 503)
@@ -455,6 +455,18 @@
.. _`SQLBuilder documentation`: SQLBuilder.html
+Select-By Method
+~~~~~~~~~~~~~~~~
+
+An alternative to ``.select`` is ``.selectBy``. It works like:
+
+.. raw:: html
+ :file: ../examples/snippets/select-by.html
+
+Each keyword argument is a column, and all the keyword arguments
+are ANDed together. The return value is a `SelectResult`, so you
+can slice it, count it, order it, etc.
+
Customizing the Objects
-----------------------
Modified: trunk/SQLObject/examples/personaddress.py
===================================================================
--- trunk/SQLObject/examples/personaddress.py 2004-12-28 12:12:57 UTC (rev 502)
+++ trunk/SQLObject/examples/personaddress.py 2004-12-29 16:51:52 UTC (rev 503)
@@ -56,6 +56,11 @@
# SELECT person.id FROM person WHERE person.first_name = 'John';
## end snippet
+## Snippet "person-select-by"
+peeps = Person.selectBy(firstName="John", lastName="Doe")
+## end snippet
+list(peeps)
+
## Snippet "person-select2"
peeps = Person.select(
AND(Address.q.personID == Person.q.id,
|
|
From: <sub...@co...> - 2004-12-28 12:13:00
|
Author: phd
Date: 2004-12-28 12:12:57 +0000 (Tue, 28 Dec 2004)
New Revision: 502
Modified:
home/phd/SQLObject/inheritance/sqlobject/main.py
Log:
Fixed a bug: put all needed classes into the tableRegistry before searching for parents.
Modified: home/phd/SQLObject/inheritance/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/main.py 2004-12-28 12:03:13 UTC (rev 501)
+++ home/phd/SQLObject/inheritance/sqlobject/main.py 2004-12-28 12:12:57 UTC (rev 502)
@@ -1351,10 +1351,13 @@
#DSM: and will do himself the relationship between classes.
if type(self.clause) is not str:
tableRegistry = {}
- for registryClass in classregistry.registry(sourceClass._registry).allClasses():
+ allClasses = classregistry.registry(sourceClass._registry).allClasses()
+ for registryClass in allClasses:
if registryClass._table in tablesDict:
- #DSM: By default, no parent are needed for the clauses
+ #DSM: By default, no parents are needed for the clauses
tableRegistry[registryClass] = registryClass
+ for registryClass in allClasses:
+ if registryClass._table in tablesDict:
currentClass = registryClass
while currentClass._parentClass:
currentClass = currentClass._parentClass
|
|
From: <sub...@co...> - 2004-12-28 12:03:20
|
Author: phd
Date: 2004-12-28 12:03:13 +0000 (Tue, 28 Dec 2004)
New Revision: 501
Modified:
home/phd/SQLObject/inheritance/tests/test_cache.py
home/phd/SQLObject/inheritance/tests/test_converters.py
Log:
Merged the patch from revision 500: updated the cache and converters tests for SQLObject 0.6.
Modified: home/phd/SQLObject/inheritance/tests/test_cache.py
===================================================================
--- home/phd/SQLObject/inheritance/tests/test_cache.py 2004-12-28 12:01:53 UTC (rev 500)
+++ home/phd/SQLObject/inheritance/tests/test_cache.py 2004-12-28 12:03:13 UTC (rev 501)
@@ -1,5 +1,5 @@
import unittest
-from SQLObject.Cache import CacheSet
+from sqlobject.cache import CacheSet
class Something(object):
pass
@@ -15,7 +15,7 @@
x.finishPut(y.__class__)
j = x.get(1, y.__class__)
self.assertEqual(j, y)
- x.purge(1, y.__class__)
+ x.expire(1, y.__class__)
j = x.get(1, y.__class__)
self.assertEqual(j, None)
x.finishPut(y.__class__)
Modified: home/phd/SQLObject/inheritance/tests/test_converters.py
===================================================================
--- home/phd/SQLObject/inheritance/tests/test_converters.py 2004-12-28 12:01:53 UTC (rev 500)
+++ home/phd/SQLObject/inheritance/tests/test_converters.py 2004-12-28 12:03:13 UTC (rev 501)
@@ -1,16 +1,16 @@
import unittest
-from SQLObject.SQLBuilder import sqlrepr, TRUE, FALSE
-from SQLObject.SQLBuilder import SQLExpression, SQLObjectField, \
+from sqlobject.sqlbuilder import sqlrepr, TRUE, FALSE
+from sqlobject.sqlbuilder import SQLExpression, SQLObjectField, \
Select, Insert, Update, Delete, Replace, \
SQLTrueClauseClass, SQLConstant, SQLPrefix, SQLCall, SQLOp
-from SQLObject.Converters import registerConverter
+from sqlobject.converters import registerConverter
class TestClass:
def __repr__(self):
return '<TestClass>'
-def TestClassConverter(value):
+def TestClassConverter(value, db):
return repr(value)
registerConverter(TestClass, TestClassConverter)
@@ -22,15 +22,15 @@
def __repr__(self):
return '<NewTestClass>'
-def NewTestClassConverter(value):
+def NewTestClassConverter(value, db):
return repr(value)
registerConverter(NewTestClass, NewTestClassConverter)
-def _sqlrepr(self):
+def _sqlrepr(self, db):
return '<%s>' % self.__class__.__name__
-SQLExpression.sqlrepr = _sqlrepr
+SQLExpression.__sqlrepr__ = _sqlrepr
class ConvertersTest(unittest.TestCase):
@@ -42,20 +42,20 @@
self.assertEqual(sqlrepr('A String\nAnother', 'sqlite'), "'A String\nAnother'")
def test_string_tab(self):
- self.assertEqual(sqlRepr('A String\tAnother', 'postgres'), "'A String\\tAnother'")
+ self.assertEqual(sqlrepr('A String\tAnother', 'postgres'), "'A String\\tAnother'")
def test_string_r(self):
- self.assertEqual(sqlRepr('A String\rAnother', 'postgres'), "'A String\\rAnother'")
+ self.assertEqual(sqlrepr('A String\rAnother', 'postgres'), "'A String\\rAnother'")
def test_string_b(self):
- self.assertEqual(sqlRepr('A String\bAnother', 'postgres'), "'A String\\bAnother'")
+ self.assertEqual(sqlrepr('A String\bAnother', 'postgres'), "'A String\\bAnother'")
def test_string_000(self):
- self.assertEqual(sqlRepr('A String\000Another', 'postgres'), "'A String\\0Another'")
+ self.assertEqual(sqlrepr('A String\000Another', 'postgres'), "'A String\\0Another'")
def test_string_(self):
- self.assertEqual(sqlRepr('A String\'Another', 'postgres'), "'A String\\\'Another'")
- self.assertEqual(sqlRepr('A String\'Another', 'firebird'), "'A String''Another'")
+ self.assertEqual(sqlrepr('A String\'Another', 'postgres'), "'A String''Another'")
+ self.assertEqual(sqlrepr('A String\'Another', 'firebird'), "'A String''Another'")
def test_simple_unicode(self):
self.assertEqual(sqlrepr(u'A String', 'postgres'), "'A String'")
@@ -76,10 +76,10 @@
self.assertEqual(sqlrepr(('one','two','three'), 'postgres'), "('one', 'two', 'three')")
def test_bool(self):
- self.assertEqual(sqlRepr(TRUE, 'postgres'), "'t'")
- self.assertEqual(sqlRepr(FALSE, 'postgres'), "'f'")
- self.assertEqual(sqlRepr(TRUE, 'mysql'), "1")
- self.assertEqual(sqlRepr(FALSE, 'mysql'), "0")
+ self.assertEqual(sqlrepr(TRUE, 'postgres'), "'t'")
+ self.assertEqual(sqlrepr(FALSE, 'postgres'), "'f'")
+ self.assertEqual(sqlrepr(TRUE, 'mysql'), "1")
+ self.assertEqual(sqlrepr(FALSE, 'mysql'), "0")
def test_instance(self):
instance = TestClass()
|
|
From: <sub...@co...> - 2004-12-28 12:02:00
|
Author: phd
Date: 2004-12-28 12:01:53 +0000 (Tue, 28 Dec 2004)
New Revision: 500
Modified:
trunk/SQLObject/tests/test_cache.py
trunk/SQLObject/tests/test_converters.py
Log:
Updated the cache and converters tests for SQLObject 0.6.
Modified: trunk/SQLObject/tests/test_cache.py
===================================================================
--- trunk/SQLObject/tests/test_cache.py 2004-12-28 08:59:18 UTC (rev 499)
+++ trunk/SQLObject/tests/test_cache.py 2004-12-28 12:01:53 UTC (rev 500)
@@ -1,5 +1,5 @@
import unittest
-from SQLObject.Cache import CacheSet
+from sqlobject.cache import CacheSet
class Something(object):
pass
@@ -15,7 +15,7 @@
x.finishPut(y.__class__)
j = x.get(1, y.__class__)
self.assertEqual(j, y)
- x.purge(1, y.__class__)
+ x.expire(1, y.__class__)
j = x.get(1, y.__class__)
self.assertEqual(j, None)
x.finishPut(y.__class__)
Modified: trunk/SQLObject/tests/test_converters.py
===================================================================
--- trunk/SQLObject/tests/test_converters.py 2004-12-28 08:59:18 UTC (rev 499)
+++ trunk/SQLObject/tests/test_converters.py 2004-12-28 12:01:53 UTC (rev 500)
@@ -1,16 +1,16 @@
import unittest
-from SQLObject.SQLBuilder import sqlrepr, TRUE, FALSE
-from SQLObject.SQLBuilder import SQLExpression, SQLObjectField, \
+from sqlobject.sqlbuilder import sqlrepr, TRUE, FALSE
+from sqlobject.sqlbuilder import SQLExpression, SQLObjectField, \
Select, Insert, Update, Delete, Replace, \
SQLTrueClauseClass, SQLConstant, SQLPrefix, SQLCall, SQLOp
-from SQLObject.Converters import registerConverter
+from sqlobject.converters import registerConverter
class TestClass:
def __repr__(self):
return '<TestClass>'
-def TestClassConverter(value):
+def TestClassConverter(value, db):
return repr(value)
registerConverter(TestClass, TestClassConverter)
@@ -22,15 +22,15 @@
def __repr__(self):
return '<NewTestClass>'
-def NewTestClassConverter(value):
+def NewTestClassConverter(value, db):
return repr(value)
registerConverter(NewTestClass, NewTestClassConverter)
-def _sqlrepr(self):
+def _sqlrepr(self, db):
return '<%s>' % self.__class__.__name__
-SQLExpression.sqlrepr = _sqlrepr
+SQLExpression.__sqlrepr__ = _sqlrepr
class ConvertersTest(unittest.TestCase):
@@ -42,20 +42,20 @@
self.assertEqual(sqlrepr('A String\nAnother', 'sqlite'), "'A String\nAnother'")
def test_string_tab(self):
- self.assertEqual(sqlRepr('A String\tAnother', 'postgres'), "'A String\\tAnother'")
+ self.assertEqual(sqlrepr('A String\tAnother', 'postgres'), "'A String\\tAnother'")
def test_string_r(self):
- self.assertEqual(sqlRepr('A String\rAnother', 'postgres'), "'A String\\rAnother'")
+ self.assertEqual(sqlrepr('A String\rAnother', 'postgres'), "'A String\\rAnother'")
def test_string_b(self):
- self.assertEqual(sqlRepr('A String\bAnother', 'postgres'), "'A String\\bAnother'")
+ self.assertEqual(sqlrepr('A String\bAnother', 'postgres'), "'A String\\bAnother'")
def test_string_000(self):
- self.assertEqual(sqlRepr('A String\000Another', 'postgres'), "'A String\\0Another'")
+ self.assertEqual(sqlrepr('A String\000Another', 'postgres'), "'A String\\0Another'")
def test_string_(self):
- self.assertEqual(sqlRepr('A String\'Another', 'postgres'), "'A String\\\'Another'")
- self.assertEqual(sqlRepr('A String\'Another', 'firebird'), "'A String''Another'")
+ self.assertEqual(sqlrepr('A String\'Another', 'postgres'), "'A String''Another'")
+ self.assertEqual(sqlrepr('A String\'Another', 'firebird'), "'A String''Another'")
def test_simple_unicode(self):
self.assertEqual(sqlrepr(u'A String', 'postgres'), "'A String'")
@@ -76,10 +76,10 @@
self.assertEqual(sqlrepr(('one','two','three'), 'postgres'), "('one', 'two', 'three')")
def test_bool(self):
- self.assertEqual(sqlRepr(TRUE, 'postgres'), "'t'")
- self.assertEqual(sqlRepr(FALSE, 'postgres'), "'f'")
- self.assertEqual(sqlRepr(TRUE, 'mysql'), "1")
- self.assertEqual(sqlRepr(FALSE, 'mysql'), "0")
+ self.assertEqual(sqlrepr(TRUE, 'postgres'), "'t'")
+ self.assertEqual(sqlrepr(FALSE, 'postgres'), "'f'")
+ self.assertEqual(sqlrepr(TRUE, 'mysql'), "1")
+ self.assertEqual(sqlrepr(FALSE, 'mysql'), "0")
def test_instance(self):
instance = TestClass()
|
|
From: <sub...@co...> - 2004-12-28 08:59:22
|
Author: phd
Date: 2004-12-28 08:59:18 +0000 (Tue, 28 Dec 2004)
New Revision: 499
Modified:
home/phd/SQLObject/inheritance/sqlobject/main.py
Log:
Added missed connection to addColumn.
Modified: home/phd/SQLObject/inheritance/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/main.py 2004-12-28 08:38:23 UTC (rev 498)
+++ home/phd/SQLObject/inheritance/sqlobject/main.py 2004-12-28 08:59:18 UTC (rev 499)
@@ -451,7 +451,7 @@
cls._SO_indexList.append(index)
addIndex = classmethod(addIndex)
- def addColumn(cls, columnDef, changeSchema=False, childUpdate=False):
+ def addColumn(cls, columnDef, changeSchema=False, connection=None, childUpdate=False):
#DSM: Try to add parent properties to the current class
#DSM: Only do this once if possible at object creation and once for
#DSM: each new dynamic column to refresh the current class
|
|
From: <sub...@co...> - 2004-12-28 08:38:28
|
Author: phd
Date: 2004-12-28 08:38:23 +0000 (Tue, 28 Dec 2004)
New Revision: 498
Modified:
home/phd/SQLObject/inheritance/sqlobject/dbconnection.py
Log:
Merged a patch from revision 497: fixed a bug with tables that do not have columns (only MultipleJoins, e.g.)
Modified: home/phd/SQLObject/inheritance/sqlobject/dbconnection.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/dbconnection.py 2004-12-28 08:37:02 UTC (rev 497)
+++ home/phd/SQLObject/inheritance/sqlobject/dbconnection.py 2004-12-28 08:38:23 UTC (rev 498)
@@ -268,11 +268,16 @@
(cls._table, cls._idName,
", ".join(select.tables))
else:
- q += "%s.%s, %s FROM %s WHERE " % \
- (cls._table, cls._idName,
- ", ".join(["%s.%s" % (cls._table, col.dbName)
- for col in cls._SO_columns]),
- ", ".join(select.tables))
+ columns = ", ".join(["%s.%s" % (cls._table, col.dbName)
+ for col in cls._SO_columns])
+ if columns:
+ q += "%s.%s, %s FROM %s WHERE " % \
+ (cls._table, cls._idName, columns,
+ ", ".join(select.tables))
+ else:
+ q += "%s.%s FROM %s WHERE " % \
+ (cls._table, cls._idName,
+ ", ".join(select.tables))
return self._addWhereClause(select, q)
|
|
From: <sub...@co...> - 2004-12-28 08:37:05
|
Author: phd
Date: 2004-12-28 08:37:02 +0000 (Tue, 28 Dec 2004)
New Revision: 497
Modified:
trunk/SQLObject/sqlobject/dbconnection.py
Log:
Fixed a bug with tables that do not have columns (only MultipleJoins, e.g.)
Modified: trunk/SQLObject/sqlobject/dbconnection.py
===================================================================
--- trunk/SQLObject/sqlobject/dbconnection.py 2004-12-28 08:25:11 UTC (rev 496)
+++ trunk/SQLObject/sqlobject/dbconnection.py 2004-12-28 08:37:02 UTC (rev 497)
@@ -268,11 +268,16 @@
(cls._table, cls._idName,
", ".join(select.tables))
else:
- q += "%s.%s, %s FROM %s WHERE " % \
- (cls._table, cls._idName,
- ", ".join(["%s.%s" % (cls._table, col.dbName)
- for col in cls._SO_columns]),
- ", ".join(select.tables))
+ columns = ", ".join(["%s.%s" % (cls._table, col.dbName)
+ for col in cls._SO_columns])
+ if columns:
+ q += "%s.%s, %s FROM %s WHERE " % \
+ (cls._table, cls._idName, columns,
+ ", ".join(select.tables))
+ else:
+ q += "%s.%s FROM %s WHERE " % \
+ (cls._table, cls._idName,
+ ", ".join(select.tables))
return self._addWhereClause(select, q)
|
|
From: <sub...@co...> - 2004-12-28 08:25:16
|
Author: phd
Date: 2004-12-28 08:25:11 +0000 (Tue, 28 Dec 2004)
New Revision: 496
Modified:
home/phd/SQLObject/inheritance/sqlobject/dbconnection.py
Log:
Merged difference from revisions 493:495
Modified: home/phd/SQLObject/inheritance/sqlobject/dbconnection.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/dbconnection.py 2004-12-27 17:24:24 UTC (rev 495)
+++ home/phd/SQLObject/inheritance/sqlobject/dbconnection.py 2004-12-28 08:25:11 UTC (rev 496)
@@ -442,22 +442,22 @@
self.sqlrepr(value))
for key, value
in kw.items()])
- terms = []
- for key, value in kw.items():
- if hasattr(value, '_SO_joinDict'): #handle an object value
- # find the joinColumn
- for join in value._SO_joinDict.values():
- if join.otherClass is soClass:
- dbName = join.joinColumn
- break
- else: #if nothing found
- raise TypeError, "Cannot selectBy(%s=%r)" % (key, value)
- value = value.id
- else:
- dbName = soClass._SO_columnDict[key].dbName
- term = '%s = %s' % (dbName, self.sqlrepr(value))
- terms.append(term)
- return ' AND '.join(terms)
+ terms = []
+ for key, value in kw.items():
+ if hasattr(value, '_SO_joinDict'): #handle an object value
+ # find the joinColumn
+ for join in value._SO_joinDict.values():
+ if join.otherClass is soClass:
+ dbName = join.joinColumn
+ break
+ else: #if nothing found
+ raise TypeError, "Cannot selectBy(%s=%r)" % (key, value)
+ value = value.id
+ else:
+ dbName = soClass._SO_columnDict[key].dbName
+ term = '%s = %s' % (dbName, self.sqlrepr(value))
+ terms.append(term)
+ return ' AND '.join(terms)
def sqlrepr(self, v):
return sqlrepr(v, self.dbName)
|
|
From: <sub...@co...> - 2004-12-27 17:24:27
|
Author: ianb
Date: 2004-12-27 17:24:24 +0000 (Mon, 27 Dec 2004)
New Revision: 495
Modified:
trunk/SQLObject/sqlobject/dbconnection.py
Log:
Got rid of tabs. Bad tabs!
Modified: trunk/SQLObject/sqlobject/dbconnection.py
===================================================================
--- trunk/SQLObject/sqlobject/dbconnection.py 2004-12-24 09:28:53 UTC (rev 494)
+++ trunk/SQLObject/sqlobject/dbconnection.py 2004-12-27 17:24:24 UTC (rev 495)
@@ -442,22 +442,22 @@
self.sqlrepr(value))
for key, value
in kw.items()])
- terms = []
- for key, value in kw.items():
- if hasattr(value, '_SO_joinDict'): #handle an object value
- # find the joinColumn
- for join in value._SO_joinDict.values():
- if join.otherClass is soClass:
- dbName = join.joinColumn
- break
- else: #if nothing found
- raise TypeError, "Cannot selectBy(%s=%r)" % (key, value)
- value = value.id
- else:
- dbName = soClass._SO_columnDict[key].dbName
- term = '%s = %s' % (dbName, self.sqlrepr(value))
- terms.append(term)
- return ' AND '.join(terms)
+ terms = []
+ for key, value in kw.items():
+ if hasattr(value, '_SO_joinDict'): #handle an object value
+ # find the joinColumn
+ for join in value._SO_joinDict.values():
+ if join.otherClass is soClass:
+ dbName = join.joinColumn
+ break
+ else: #if nothing found
+ raise TypeError, "Cannot selectBy(%s=%r)" % (key, value)
+ value = value.id
+ else:
+ dbName = soClass._SO_columnDict[key].dbName
+ term = '%s = %s' % (dbName, self.sqlrepr(value))
+ terms.append(term)
+ return ' AND '.join(terms)
def sqlrepr(self, v):
return sqlrepr(v, self.dbName)
|
|
From: <sub...@co...> - 2004-12-24 09:28:58
|
Author: phd
Date: 2004-12-24 09:28:53 +0000 (Fri, 24 Dec 2004)
New Revision: 494
Modified:
home/phd/SQLObject/inheritance/sqlobject/main.py
Log:
Extract tablesDict from orderBy in addition to clause.
Modified: home/phd/SQLObject/inheritance/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/main.py 2004-12-22 15:54:23 UTC (rev 493)
+++ home/phd/SQLObject/inheritance/sqlobject/main.py 2004-12-24 09:28:53 UTC (rev 494)
@@ -1340,6 +1340,9 @@
self.clause = clause
tablesDict = sqlbuilder.tablesUsedDict(self.clause)
tablesDict[sourceClass._table] = 1
+ orderBy = ops.get('orderBy')
+ if orderBy and not isinstance(orderBy, basestring):
+ tablesDict.update(sqlbuilder.tablesUsedDict(orderBy))
#DSM: if this class has a parent, we need to link it
#DSM: and be sure the parent is in the table list.
#DSM: The following code is before clauseTables
|
|
From: <sub...@co...> - 2004-12-16 14:23:51
|
Author: phd
Date: 2004-12-16 14:23:48 +0000 (Thu, 16 Dec 2004)
New Revision: 492
Modified:
home/phd/SQLObject/inheritance/docs/Inheritance.txt
Log:
Minor fix for SQLObject 0.6 API.
Modified: home/phd/SQLObject/inheritance/docs/Inheritance.txt
===================================================================
--- home/phd/SQLObject/inheritance/docs/Inheritance.txt 2004-12-16 14:23:02 UTC (rev 491)
+++ home/phd/SQLObject/inheritance/docs/Inheritance.txt 2004-12-16 14:23:48 UTC (rev 492)
@@ -55,7 +55,7 @@
p = Person(firstName='John', lastName='Doe')
e = Employee(firstName='Jane', lastName='Doe', position='Chief')
- p2 = Person(1)
+ p2 = Person.get(1)
Will create the following data in the database::
@@ -97,8 +97,8 @@
The SQLObject q magic also work. Using this select are valid::
- Employee.select(Employee.q.firstName == 'Jane' & Employee.q.position == 'Chief') will return Jane Doe
- Employee.select(Person.q.firstName == 'Jane' & Employee.q.position == 'Chief') will return Jane Doe
+ Employee.select(AND(Employee.q.firstName == 'Jane' Employee.q.position == 'Chief')) will return Jane Doe
+ Employee.select(AND(Person.q.firstName == 'Jane', Employee.q.position == 'Chief')) will return Jane Doe
Employee.select(Employee.q.lastName == 'Doe') will only return Jane Doe (as Joe isn't an employee)
Person.select(Person.q.lastName == 'Doe') will return both entries.
|
|
From: <sub...@co...> - 2004-12-16 14:23:09
|
Author: phd
Date: 2004-12-16 14:23:02 +0000 (Thu, 16 Dec 2004)
New Revision: 491
Modified:
home/phd/SQLObject/inheritance/sqlobject/col.py
Log:
Merged patches from trunk revisions 484:490.
Modified: home/phd/SQLObject/inheritance/sqlobject/col.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/col.py 2004-12-15 23:30:17 UTC (rev 490)
+++ home/phd/SQLObject/inheritance/sqlobject/col.py 2004-12-16 14:23:02 UTC (rev 491)
@@ -386,7 +386,7 @@
return sqlbuilder.FALSE
def toPython(self, value, state):
- if not value or not int(value):
+ if not value:
return sqlbuilder.FALSE
else:
return sqlbuilder.TRUE
|