sqlobject-cvs Mailing List for SQLObject (Page 55)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
(9) |
Apr
(74) |
May
(29) |
Jun
(16) |
Jul
(28) |
Aug
(10) |
Sep
(57) |
Oct
(9) |
Nov
(29) |
Dec
(12) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(7) |
Feb
(14) |
Mar
(6) |
Apr
(3) |
May
(12) |
Jun
(34) |
Jul
(9) |
Aug
(29) |
Sep
(22) |
Oct
(2) |
Nov
(15) |
Dec
(52) |
| 2005 |
Jan
(47) |
Feb
(78) |
Mar
(14) |
Apr
(35) |
May
(33) |
Jun
(16) |
Jul
(26) |
Aug
(63) |
Sep
(40) |
Oct
(96) |
Nov
(96) |
Dec
(123) |
| 2006 |
Jan
(159) |
Feb
(144) |
Mar
(64) |
Apr
(31) |
May
(88) |
Jun
(48) |
Jul
(16) |
Aug
(64) |
Sep
(87) |
Oct
(92) |
Nov
(56) |
Dec
(76) |
| 2007 |
Jan
(94) |
Feb
(103) |
Mar
(126) |
Apr
(123) |
May
(85) |
Jun
(11) |
Jul
(130) |
Aug
(47) |
Sep
(65) |
Oct
(70) |
Nov
(12) |
Dec
(11) |
| 2008 |
Jan
(30) |
Feb
(55) |
Mar
(88) |
Apr
(20) |
May
(50) |
Jun
|
Jul
(38) |
Aug
(1) |
Sep
(9) |
Oct
(5) |
Nov
(6) |
Dec
(39) |
| 2009 |
Jan
(8) |
Feb
(16) |
Mar
(3) |
Apr
(33) |
May
(44) |
Jun
(1) |
Jul
(10) |
Aug
(33) |
Sep
(74) |
Oct
(22) |
Nov
|
Dec
(15) |
| 2010 |
Jan
(28) |
Feb
(22) |
Mar
(46) |
Apr
(29) |
May
(1) |
Jun
(1) |
Jul
(27) |
Aug
(8) |
Sep
(5) |
Oct
(33) |
Nov
(24) |
Dec
(41) |
| 2011 |
Jan
(4) |
Feb
(12) |
Mar
(35) |
Apr
(29) |
May
(19) |
Jun
(16) |
Jul
(32) |
Aug
(25) |
Sep
(5) |
Oct
(11) |
Nov
(21) |
Dec
(12) |
| 2012 |
Jan
(3) |
Feb
(4) |
Mar
(20) |
Apr
(4) |
May
(25) |
Jun
(13) |
Jul
|
Aug
|
Sep
(2) |
Oct
(25) |
Nov
(9) |
Dec
(1) |
| 2013 |
Jan
(6) |
Feb
(8) |
Mar
|
Apr
(10) |
May
(31) |
Jun
(7) |
Jul
(18) |
Aug
(33) |
Sep
(4) |
Oct
(16) |
Nov
|
Dec
(27) |
| 2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(11) |
May
(39) |
Jun
(8) |
Jul
(11) |
Aug
(4) |
Sep
|
Oct
(27) |
Nov
|
Dec
(71) |
| 2015 |
Jan
(17) |
Feb
(47) |
Mar
(33) |
Apr
|
May
|
Jun
(9) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
| 2016 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
(12) |
Jun
(7) |
Jul
(9) |
Aug
(31) |
Sep
(8) |
Oct
(3) |
Nov
(15) |
Dec
(1) |
| 2017 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(8) |
May
(10) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(4) |
Dec
(5) |
| 2018 |
Jan
(2) |
Feb
(8) |
Mar
|
Apr
(4) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
(1) |
Feb
(16) |
Mar
(1) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
| 2021 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
(1) |
Dec
(4) |
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
|
| 2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
| 2025 |
Jan
|
Feb
(4) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
|
From: SourceForge.net <no...@so...> - 2009-09-25 21:25:24
|
Bugs item #2865410, was opened at 2009-09-23 20:45 Message generated for change (Comment added) made by bdoms You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865410&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: SQLObject release (specify) Status: Closed Resolution: Invalid Priority: 5 Private: No Submitted By: Brendan Doms (bdoms) Assigned to: Oleg Broytmann (phd) Summary: createTable Fails When Table is Named "Transaction" Initial Comment: Bare bones, just try this (I'm working off of the easy_install version on Ubuntu, which is currently 0.11.0): from sqlobject import SQLObject, connectionForURI, sqlhub db_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'finance.db') connection = connectionForURI('sqlite:' + db_file) sqlhub.processConnection = connection class Transaction(SQLObject): pass Transaction.createTable() If the table is named anything else (as far as I can find), then it works fine. But as it is, this generates the following error: File "/usr/local/lib/python2.6/dist-packages/SQLObject-0.11.0-py2.6.egg/sqlobject/sqlite/sqliteconnection.py", line 183, in _executeRetry raise OperationalError(ErrorMessage(e)) sqlobject.dberrors.OperationalError: near "transaction": syntax error Not very helpful right? Either this error should be changed to point out the fact that "Transaction" is invalid as a table name, or the preferred solution would be to eliminate the error altogether and allow this table name. Considering that the import list contains no * and nothing called "Transaction" I see no reason why SQLObject's name space should interfere here. ---------------------------------------------------------------------- Comment By: Brendan Doms (bdoms) Date: 2009-09-25 17:25 Message: Ah, nice job getting to the root of the issue. I guess I just assumed that because SQLObject is an abstraction layer it would take the pain away from dealing with databases and so none of SQLite's (or any other database) reserved keywords would be in conflict. My bad. Since that's not the case, I would still recommend making the error message more clear here if possible. Specifically mentioning the reserved keyword thing would have helped me track down the bug faster. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2009-09-25 11:04 Message: If you add '?debug=1' to DB URI you find the following SQLObject debugging output: 1/QueryR : CREATE TABLE transaction ( id INTEGER PRIMARY KEY ) This is where the error came from - from SQLite, not from SQLObject! SQLObject's namespace has nothing to do here. Traceback (most recent call last): [skip] raise OperationalError(ErrorMessage(e)) sqlobject.dberrors.OperationalError: near "transaction": syntax error Let's test it without SQLObject: $ sqlite3 test SQLite version 3.5.9 Enter ".help" for instructions sqlite> CREATE TABLE transaction (id INTEGER PRIMARY KEY); SQL error: near "transaction": syntax error SQLite (like any other DB) doesn't allow keywords to be used as names. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865410&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2009-09-25 15:04:05
|
Bugs item #2865410, was opened at 2009-09-24 04:45 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865410&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: SQLObject release (specify) >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Brendan Doms (bdoms) >Assigned to: Oleg Broytmann (phd) Summary: createTable Fails When Table is Named "Transaction" Initial Comment: Bare bones, just try this (I'm working off of the easy_install version on Ubuntu, which is currently 0.11.0): from sqlobject import SQLObject, connectionForURI, sqlhub db_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'finance.db') connection = connectionForURI('sqlite:' + db_file) sqlhub.processConnection = connection class Transaction(SQLObject): pass Transaction.createTable() If the table is named anything else (as far as I can find), then it works fine. But as it is, this generates the following error: File "/usr/local/lib/python2.6/dist-packages/SQLObject-0.11.0-py2.6.egg/sqlobject/sqlite/sqliteconnection.py", line 183, in _executeRetry raise OperationalError(ErrorMessage(e)) sqlobject.dberrors.OperationalError: near "transaction": syntax error Not very helpful right? Either this error should be changed to point out the fact that "Transaction" is invalid as a table name, or the preferred solution would be to eliminate the error altogether and allow this table name. Considering that the import list contains no * and nothing called "Transaction" I see no reason why SQLObject's name space should interfere here. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2009-09-25 19:04 Message: If you add '?debug=1' to DB URI you find the following SQLObject debugging output: 1/QueryR : CREATE TABLE transaction ( id INTEGER PRIMARY KEY ) This is where the error came from - from SQLite, not from SQLObject! SQLObject's namespace has nothing to do here. Traceback (most recent call last): [skip] raise OperationalError(ErrorMessage(e)) sqlobject.dberrors.OperationalError: near "transaction": syntax error Let's test it without SQLObject: $ sqlite3 test SQLite version 3.5.9 Enter ".help" for instructions sqlite> CREATE TABLE transaction (id INTEGER PRIMARY KEY); SQL error: near "transaction": syntax error SQLite (like any other DB) doesn't allow keywords to be used as names. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865410&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2009-09-25 14:52:15
|
Bugs item #2865000, was opened at 2009-09-23 17:26 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865000&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject release (specify) >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: greg (gregor_horvath) >Assigned to: Oleg Broytmann (phd) Summary: UnicodeEncodeError with ?debug=1 and unciode query Initial Comment: If in the connection string ?debug=1 is enabled and the select query is unicode, then a UnicodeEncodeError is thrown: File "/usr/lib/python2.5/site-packages/sqlobject/sresults.py", line 179, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.5/site-packages/sqlobject/sresults.py", line 187, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 395, in iterSelect select, keepConnection=False) File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 633, in __init__ dbconn.printDebug(rawconn, self.query, 'Select') File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 324, in printDebug self.debugWriter.write(msg) File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 35, in write self.logfile.write(text + '\n') UnicodeEncodeError: 'ascii' codec can't encode character u'\xd6' in position 56: ordinal not in range(128) See in the attachment a test case wich demonstrates the error case and the ok case. Tested on Version 0.10.2 ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2009-09-25 18:52 Message: Fixed in the revisions 3992-3994 (branches 0.10, 0.11 and the trunk). Will be in the next round of releases. Thank you! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865000&group_id=74338 |
|
From: <sub...@co...> - 2009-09-25 14:50:15
|
Author: phd
Date: 2009-09-25 08:50:07 -0600 (Fri, 25 Sep 2009)
New Revision: 3994
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/sqlobject/dbconnection.py
Log:
Merged a bugfix in logging to console fro branch 0.11, rev. 3993.
Modified: SQLObject/trunk/docs/News.txt
===================================================================
--- SQLObject/trunk/docs/News.txt 2009-09-25 14:47:40 UTC (rev 3993)
+++ SQLObject/trunk/docs/News.txt 2009-09-25 14:50:07 UTC (rev 3994)
@@ -48,6 +48,11 @@
* Removed all deprecated attribute and functions.
+SQLObject 0.11.2
+================
+
+* A change ported from `SQLObject 0.10.8`_.
+
SQLObject 0.11.1
================
@@ -103,6 +108,11 @@
* Changed the order of testing of SQLite modules - look for external
PySQLite2 before sqlite3.
+SQLObject 0.10.8
+================
+
+* Fixed a bug in logging to console - convert unicode to str.
+
SQLObject 0.10.7
================
Modified: SQLObject/trunk/sqlobject/dbconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/dbconnection.py 2009-09-25 14:47:40 UTC (rev 3993)
+++ SQLObject/trunk/sqlobject/dbconnection.py 2009-09-25 14:50:07 UTC (rev 3994)
@@ -28,27 +28,33 @@
conn.close()
class ConsoleWriter:
- def __init__(self, loglevel):
+ def __init__(self, connection, loglevel):
# loglevel: None or empty string for stdout; or 'stderr'
self.loglevel = loglevel or "stdout"
+ self.dbEncoding = getattr(connection, "dbEncoding", "ascii")
def write(self, text):
logfile = getattr(sys, self.loglevel)
+ if isinstance(text, unicode):
+ try:
+ text = text.encode(self.dbEncoding)
+ except UnicodeEncodeError:
+ text = repr(text)[2:-1]
logfile.write(text + '\n')
class LogWriter:
- def __init__(self, logger, loglevel):
+ def __init__(self, connection, logger, loglevel):
self.logger = logger
self.loglevel = loglevel
self.logmethod = getattr(logger, loglevel)
def write(self, text):
self.logmethod(text)
-def makeDebugWriter(loggerName, loglevel):
+def makeDebugWriter(connection, loggerName, loglevel):
if not loggerName:
- return ConsoleWriter(loglevel)
+ return ConsoleWriter(connection, loglevel)
import logging
logger = logging.getLogger(loggerName)
- return LogWriter(logger, loglevel)
+ return LogWriter(connection, logger, loglevel)
class Boolean(object):
"""A bool class that also understands some special string keywords (yes/no, true/false, on/off, 1/0)"""
@@ -70,7 +76,7 @@
self.debug = Boolean(debug)
self.debugOutput = Boolean(debugOutput)
self.debugThreading = Boolean(debugThreading)
- self.debugWriter = makeDebugWriter(logger, loglevel)
+ self.debugWriter = makeDebugWriter(self, logger, loglevel)
self.doCache = Boolean(cache)
self.cache = CacheSet(cache=self.doCache)
self.style = style
|
|
From: <sub...@co...> - 2009-09-25 14:47:50
|
Author: phd
Date: 2009-09-25 08:47:40 -0600 (Fri, 25 Sep 2009)
New Revision: 3993
Modified:
SQLObject/branches/0.11/docs/News.txt
SQLObject/branches/0.11/sqlobject/dbconnection.py
Log:
Merged a bugfix in logging to console fro branch 0.10, rev. 3992.
Modified: SQLObject/branches/0.11/docs/News.txt
===================================================================
--- SQLObject/branches/0.11/docs/News.txt 2009-09-25 14:37:54 UTC (rev 3992)
+++ SQLObject/branches/0.11/docs/News.txt 2009-09-25 14:47:40 UTC (rev 3993)
@@ -7,6 +7,11 @@
.. _start:
+SQLObject 0.11.2
+================
+
+* A change ported from `SQLObject 0.10.8`_.
+
SQLObject 0.11.1
================
@@ -62,6 +67,11 @@
* Changed the order of testing of SQLite modules - look for external
PySQLite2 before sqlite3.
+SQLObject 0.10.8
+================
+
+* Fixed a bug in logging to console - convert unicode to str.
+
SQLObject 0.10.7
================
Modified: SQLObject/branches/0.11/sqlobject/dbconnection.py
===================================================================
--- SQLObject/branches/0.11/sqlobject/dbconnection.py 2009-09-25 14:37:54 UTC (rev 3992)
+++ SQLObject/branches/0.11/sqlobject/dbconnection.py 2009-09-25 14:47:40 UTC (rev 3993)
@@ -28,27 +28,33 @@
conn.close()
class ConsoleWriter:
- def __init__(self, loglevel):
+ def __init__(self, connection, loglevel):
# loglevel: None or empty string for stdout; or 'stderr'
self.loglevel = loglevel or "stdout"
+ self.dbEncoding = getattr(connection, "dbEncoding", "ascii")
def write(self, text):
logfile = getattr(sys, self.loglevel)
+ if isinstance(text, unicode):
+ try:
+ text = text.encode(self.dbEncoding)
+ except UnicodeEncodeError:
+ text = repr(text)[2:-1]
logfile.write(text + '\n')
class LogWriter:
- def __init__(self, logger, loglevel):
+ def __init__(self, connection, logger, loglevel):
self.logger = logger
self.loglevel = loglevel
self.logmethod = getattr(logger, loglevel)
def write(self, text):
self.logmethod(text)
-def makeDebugWriter(loggerName, loglevel):
+def makeDebugWriter(connection, loggerName, loglevel):
if not loggerName:
- return ConsoleWriter(loglevel)
+ return ConsoleWriter(connection, loglevel)
import logging
logger = logging.getLogger(loggerName)
- return LogWriter(logger, loglevel)
+ return LogWriter(connection, logger, loglevel)
class Boolean(object):
"""A bool class that also understands some special string keywords (yes/no, true/false, on/off, 1/0)"""
@@ -70,7 +76,7 @@
self.debug = Boolean(debug)
self.debugOutput = Boolean(debugOutput)
self.debugThreading = Boolean(debugThreading)
- self.debugWriter = makeDebugWriter(logger, loglevel)
+ self.debugWriter = makeDebugWriter(self, logger, loglevel)
self.doCache = Boolean(cache)
self.cache = CacheSet(cache=self.doCache)
self.style = style
|
|
From: <sub...@co...> - 2009-09-25 14:38:04
|
Author: phd
Date: 2009-09-25 08:37:54 -0600 (Fri, 25 Sep 2009)
New Revision: 3992
Modified:
SQLObject/branches/0.10/docs/News.txt
SQLObject/branches/0.10/sqlobject/dbconnection.py
Log:
Fixed a bug in logging to console - convert unicode to str (bug 2865410).
Modified: SQLObject/branches/0.10/docs/News.txt
===================================================================
--- SQLObject/branches/0.10/docs/News.txt 2009-09-20 19:17:26 UTC (rev 3991)
+++ SQLObject/branches/0.10/docs/News.txt 2009-09-25 14:37:54 UTC (rev 3992)
@@ -7,6 +7,11 @@
.. _start:
+SQLObject 0.10.8
+================
+
+* Fixed a bug in logging to console - convert unicode to str.
+
SQLObject 0.10.7
================
Modified: SQLObject/branches/0.10/sqlobject/dbconnection.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/dbconnection.py 2009-09-20 19:17:26 UTC (rev 3991)
+++ SQLObject/branches/0.10/sqlobject/dbconnection.py 2009-09-25 14:37:54 UTC (rev 3992)
@@ -28,26 +28,32 @@
conn.close()
class ConsoleWriter:
- def __init__(self, loglevel):
+ def __init__(self, connection, loglevel):
self.loglevel = loglevel
self.logfile = getattr(sys, loglevel or "stdout")
+ self.dbEncoding = getattr(connection, "dbEncoding", "ascii")
def write(self, text):
+ if isinstance(text, unicode):
+ try:
+ text = text.encode(self.dbEncoding)
+ except UnicodeEncodeError:
+ text = repr(text)[2:-1]
self.logfile.write(text + '\n')
class LogWriter:
- def __init__(self, logger, loglevel):
+ def __init__(self, connection, logger, loglevel):
self.logger = logger
self.loglevel = loglevel
self.logmethod = getattr(logger, loglevel)
def write(self, text):
self.logmethod(text)
-def makeDebugWriter(loggerName, loglevel):
+def makeDebugWriter(connection, loggerName, loglevel):
if not loggerName:
- return ConsoleWriter(loglevel)
+ return ConsoleWriter(connection, loglevel)
import logging
logger = logging.getLogger(loggerName)
- return LogWriter(logger, loglevel)
+ return LogWriter(connection, logger, loglevel)
class Boolean(object):
"""A bool class that also understands some special string keywords (yes/no, true/false, on/off, 1/0)"""
@@ -69,7 +75,7 @@
self.debug = Boolean(debug)
self.debugOutput = Boolean(debugOutput)
self.debugThreading = Boolean(debugThreading)
- self.debugWriter = makeDebugWriter(logger, loglevel)
+ self.debugWriter = makeDebugWriter(self, logger, loglevel)
self.doCache = Boolean(cache)
self.cache = CacheSet(cache=self.doCache)
self.style = style
|
|
From: SourceForge.net <no...@so...> - 2009-09-25 14:02:16
|
Patches item #2866300, was opened at 2009-09-25 08:08 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2866300&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Geoff Kassel (gkassel) >Assigned to: Oleg Broytmann (phd) Summary: ConnectionHub.__get__ TypeError and patch Initial Comment: Hi, Found a TypeError raised from ConnectionHub.__get__ that seems to happen when overriding the SQLObject.__init__ method. Here's the associated trace: Traceback (most recent call last): File "<console>", line 1, in <module> File "/lvm/var/www/localhost/webapp/product/product/model/dbfile.py", line 220, in __init__ SQLObject.__init__(self, contentType = contentType, _data = data) File "//usr/lib/python2.5/site-packages/sqlobject/main.py", line 1223, in __init__ self._create(id, **kw) File "//usr/lib/python2.5/site-packages/sqlobject/main.py", line 1271, in _create self._SO_finishCreate(id) File "//usr/lib/python2.5/site-packages/sqlobject/main.py", line 1294, in _SO_finishCreate id = self._connection.queryInsertID(self, File "//usr/lib/python2.5/site-packages/turbogears/database.py", line 273, in __get__ return self.hub.__get__(obj, type) File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 826, in __get__ if obj and obj.__dict__.has_key('_connection'): TypeError: an integer is required The object 'obj' in question is an uninitialized SQLObject (an object of a database-backed file class named DBFile), and the error is raised from the 'if obj' condition. I've fixed this with the attached patch. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2009-09-25 18:02 Message: I cannot get how 'obj' can be None there. Can you provide a short test program that demonstrates the problem? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2866300&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2009-09-25 04:08:27
|
Patches item #2866300, was opened at 2009-09-25 14:08 Message generated for change (Tracker Item Submitted) made by gkassel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2866300&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Geoff Kassel (gkassel) Assigned to: Nobody/Anonymous (nobody) Summary: ConnectionHub.__get__ TypeError and patch Initial Comment: Hi, Found a TypeError raised from ConnectionHub.__get__ that seems to happen when overriding the SQLObject.__init__ method. Here's the associated trace: Traceback (most recent call last): File "<console>", line 1, in <module> File "/lvm/var/www/localhost/webapp/product/product/model/dbfile.py", line 220, in __init__ SQLObject.__init__(self, contentType = contentType, _data = data) File "//usr/lib/python2.5/site-packages/sqlobject/main.py", line 1223, in __init__ self._create(id, **kw) File "//usr/lib/python2.5/site-packages/sqlobject/main.py", line 1271, in _create self._SO_finishCreate(id) File "//usr/lib/python2.5/site-packages/sqlobject/main.py", line 1294, in _SO_finishCreate id = self._connection.queryInsertID(self, File "//usr/lib/python2.5/site-packages/turbogears/database.py", line 273, in __get__ return self.hub.__get__(obj, type) File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 826, in __get__ if obj and obj.__dict__.has_key('_connection'): TypeError: an integer is required The object 'obj' in question is an uninitialized SQLObject (an object of a database-backed file class named DBFile), and the error is raised from the 'if obj' condition. I've fixed this with the attached patch. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2866300&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2009-09-24 00:45:37
|
Bugs item #2865410, was opened at 2009-09-23 20:45 Message generated for change (Tracker Item Submitted) made by bdoms You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865410&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: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Private: No Submitted By: Brendan Doms (bdoms) Assigned to: Nobody/Anonymous (nobody) Summary: createTable Fails When Table is Named "Transaction" Initial Comment: Bare bones, just try this (I'm working off of the easy_install version on Ubuntu, which is currently 0.11.0): from sqlobject import SQLObject, connectionForURI, sqlhub db_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'finance.db') connection = connectionForURI('sqlite:' + db_file) sqlhub.processConnection = connection class Transaction(SQLObject): pass Transaction.createTable() If the table is named anything else (as far as I can find), then it works fine. But as it is, this generates the following error: File "/usr/local/lib/python2.6/dist-packages/SQLObject-0.11.0-py2.6.egg/sqlobject/sqlite/sqliteconnection.py", line 183, in _executeRetry raise OperationalError(ErrorMessage(e)) sqlobject.dberrors.OperationalError: near "transaction": syntax error Not very helpful right? Either this error should be changed to point out the fact that "Transaction" is invalid as a table name, or the preferred solution would be to eliminate the error altogether and allow this table name. Considering that the import list contains no * and nothing called "Transaction" I see no reason why SQLObject's name space should interfere here. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865410&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2009-09-23 13:26:47
|
Bugs item #2865000, was opened at 2009-09-23 15:26 Message generated for change (Tracker Item Submitted) made by gregor_horvath You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865000&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Private: No Submitted By: greg (gregor_horvath) Assigned to: Nobody/Anonymous (nobody) Summary: UnicodeEncodeError with ?debug=1 and unciode query Initial Comment: If in the connection string ?debug=1 is enabled and the select query is unicode, then a UnicodeEncodeError is thrown: File "/usr/lib/python2.5/site-packages/sqlobject/sresults.py", line 179, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.5/site-packages/sqlobject/sresults.py", line 187, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 395, in iterSelect select, keepConnection=False) File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 633, in __init__ dbconn.printDebug(rawconn, self.query, 'Select') File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 324, in printDebug self.debugWriter.write(msg) File "/usr/lib/python2.5/site-packages/sqlobject/dbconnection.py", line 35, in write self.logfile.write(text + '\n') UnicodeEncodeError: 'ascii' codec can't encode character u'\xd6' in position 56: ordinal not in range(128) See in the attachment a test case wich demonstrates the error case and the ok case. Tested on Version 0.10.2 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2865000&group_id=74338 |
|
From: <sub...@co...> - 2009-09-20 19:17:36
|
Author: phd
Date: 2009-09-20 13:17:26 -0600 (Sun, 20 Sep 2009)
New Revision: 3991
Modified:
SQLObject/tags/0.11.1/setup.cfg
SQLObject/tags/0.11.1/setup.py
SQLObject/tags/0.11.1/sqlobject/__init__.py
SQLObject/tags/0.11.1/sqlobject/main.py
Log:
Stable version 0.11.1.
Modified: SQLObject/tags/0.11.1/setup.cfg
===================================================================
--- SQLObject/tags/0.11.1/setup.cfg 2009-09-20 19:16:16 UTC (rev 3990)
+++ SQLObject/tags/0.11.1/setup.cfg 2009-09-20 19:17:26 UTC (rev 3991)
@@ -2,13 +2,6 @@
command_packages = buildutils.pudge_command,
buildutils.publish_command
-[easy_install]
-#find_links = http://svn.pythonpaste.org/package_index.html
-
-[egg_info]
-tag_build = dev
-tag_svn_revision = true
-
[pudge]
theme = pythonpaste.org
docs = docs/index.txt docs/Authors.txt docs/DeveloperGuide.txt docs/FAQ.txt
Modified: SQLObject/tags/0.11.1/setup.py
===================================================================
--- SQLObject/tags/0.11.1/setup.py 2009-09-20 19:16:16 UTC (rev 3990)
+++ SQLObject/tags/0.11.1/setup.py 2009-09-20 19:17:26 UTC (rev 3991)
@@ -21,7 +21,7 @@
"""
setup(name="SQLObject",
- version="0.11",
+ version="0.11.1",
description="Object-Relational Manager, aka database wrapper",
long_description="""\
SQLObject is a popular *Object Relational Manager* for providing an
@@ -49,7 +49,7 @@
author="Ian Bicking",
author_email="ia...@co...",
url="http://sqlobject.org/devel/",
- download_url="http://cheeseshop.python.org/pypi/SQLObject/",
+ download_url="http://cheeseshop.python.org/pypi/SQLObject/0.11.1",
license="LGPL",
packages=["sqlobject"] + ['sqlobject.%s' % package for package in subpackages],
scripts=["scripts/sqlobject-admin"],
Modified: SQLObject/tags/0.11.1/sqlobject/__init__.py
===================================================================
--- SQLObject/tags/0.11.1/sqlobject/__init__.py 2009-09-20 19:16:16 UTC (rev 3990)
+++ SQLObject/tags/0.11.1/sqlobject/__init__.py 2009-09-20 19:17:26 UTC (rev 3991)
@@ -1,5 +1,5 @@
"""
-SQLObject 0.11
+SQLObject 0.11.1
"""
from main import *
Modified: SQLObject/tags/0.11.1/sqlobject/main.py
===================================================================
--- SQLObject/tags/0.11.1/sqlobject/main.py 2009-09-20 19:16:16 UTC (rev 3990)
+++ SQLObject/tags/0.11.1/sqlobject/main.py 2009-09-20 19:17:26 UTC (rev 3991)
@@ -1,6 +1,6 @@
"""
-SQLObject 0.11
---------------
+SQLObject 0.11.1
+----------------
:author: Ian Bicking <ia...@co...>
|
|
From: <sub...@co...> - 2009-09-20 19:16:27
|
Author: phd
Date: 2009-09-20 13:16:16 -0600 (Sun, 20 Sep 2009)
New Revision: 3990
Modified:
SQLObject/branches/0.11/setup.py
Log:
Added download_url.
Modified: SQLObject/branches/0.11/setup.py
===================================================================
--- SQLObject/branches/0.11/setup.py 2009-09-20 19:14:55 UTC (rev 3989)
+++ SQLObject/branches/0.11/setup.py 2009-09-20 19:16:16 UTC (rev 3990)
@@ -49,7 +49,7 @@
author="Ian Bicking",
author_email="ia...@co...",
url="http://sqlobject.org/devel/",
- download_url="http://cheeseshop.python.org/pypi/SQLObject/",
+ download_url="http://cheeseshop.python.org/pypi/SQLObject/0.11",
license="LGPL",
packages=["sqlobject"] + ['sqlobject.%s' % package for package in subpackages],
scripts=["scripts/sqlobject-admin"],
|
|
From: <sub...@co...> - 2009-09-20 19:15:06
|
Author: phd Date: 2009-09-20 13:14:55 -0600 (Sun, 20 Sep 2009) New Revision: 3989 Added: SQLObject/tags/0.11.1/ Log: Tagging 0.11.1 Copied: SQLObject/tags/0.11.1 (from rev 3988, SQLObject/branches/0.11) |
|
From: <sub...@co...> - 2009-09-20 19:04:46
|
Author: phd
Date: 2009-09-20 13:04:34 -0600 (Sun, 20 Sep 2009)
New Revision: 3988
Modified:
SQLObject/tags/0.10.7/setup.cfg
SQLObject/tags/0.10.7/setup.py
SQLObject/tags/0.10.7/sqlobject/__init__.py
SQLObject/tags/0.10.7/sqlobject/main.py
Log:
Stable version 0.10.7.
Modified: SQLObject/tags/0.10.7/setup.cfg
===================================================================
--- SQLObject/tags/0.10.7/setup.cfg 2009-09-20 19:02:15 UTC (rev 3987)
+++ SQLObject/tags/0.10.7/setup.cfg 2009-09-20 19:04:34 UTC (rev 3988)
@@ -2,13 +2,6 @@
command_packages = buildutils.pudge_command,
buildutils.publish_command
-[easy_install]
-#find_links = http://svn.pythonpaste.org/package_index.html
-
-[egg_info]
-tag_build = dev
-tag_svn_revision = true
-
[pudge]
theme = pythonpaste.org
docs = docs/index.txt docs/Authors.txt docs/DeveloperGuide.txt docs/FAQ.txt
Modified: SQLObject/tags/0.10.7/setup.py
===================================================================
--- SQLObject/tags/0.10.7/setup.py 2009-09-20 19:02:15 UTC (rev 3987)
+++ SQLObject/tags/0.10.7/setup.py 2009-09-20 19:04:34 UTC (rev 3988)
@@ -21,7 +21,7 @@
"""
setup(name="SQLObject",
- version="0.10",
+ version="0.10.7",
description="Object-Relational Manager, aka database wrapper",
long_description="""\
SQLObject is a popular *Object Relational Manager* for providing an
@@ -49,7 +49,7 @@
author="Ian Bicking",
author_email="ia...@co...",
url="http://sqlobject.org/",
- download_url="http://cheeseshop.python.org/pypi/SQLObject/0.10",
+ download_url="http://cheeseshop.python.org/pypi/SQLObject/0.10.7",
license="LGPL",
packages=["sqlobject"] + ['sqlobject.%s' % package for package in subpackages],
scripts=["scripts/sqlobject-admin"],
Modified: SQLObject/tags/0.10.7/sqlobject/__init__.py
===================================================================
--- SQLObject/tags/0.10.7/sqlobject/__init__.py 2009-09-20 19:02:15 UTC (rev 3987)
+++ SQLObject/tags/0.10.7/sqlobject/__init__.py 2009-09-20 19:04:34 UTC (rev 3988)
@@ -1,5 +1,5 @@
"""
-SQLObject 0.10
+SQLObject 0.10.7
"""
from main import *
Modified: SQLObject/tags/0.10.7/sqlobject/main.py
===================================================================
--- SQLObject/tags/0.10.7/sqlobject/main.py 2009-09-20 19:02:15 UTC (rev 3987)
+++ SQLObject/tags/0.10.7/sqlobject/main.py 2009-09-20 19:04:34 UTC (rev 3988)
@@ -1,6 +1,6 @@
"""
-SQLObject 0.10
---------------
+SQLObject 0.10.7
+----------------
:author: Ian Bicking <ia...@co...>
|
|
From: <sub...@co...> - 2009-09-20 19:02:28
|
Author: phd Date: 2009-09-20 13:02:15 -0600 (Sun, 20 Sep 2009) New Revision: 3987 Added: SQLObject/tags/0.10.7/ Log: Tagging 0.10.7 Copied: SQLObject/tags/0.10.7 (from rev 3986, SQLObject/branches/0.10) |
|
From: <sub...@co...> - 2009-09-20 19:01:20
|
Author: phd Date: 2009-09-20 13:01:10 -0600 (Sun, 20 Sep 2009) New Revision: 3986 Modified: SQLObject/trunk/docs/News.txt Log: SQLObject 0.11.1 and SQLObject 0.10.7 were released 20 Sep 2009. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2009-09-20 18:59:37 UTC (rev 3985) +++ SQLObject/trunk/docs/News.txt 2009-09-20 19:01:10 UTC (rev 3986) @@ -51,6 +51,8 @@ SQLObject 0.11.1 ================ +Released 20 Sep 2009 + * A number of changes ported from `SQLObject 0.10.7`_. SQLObject 0.11.0 @@ -104,6 +106,8 @@ SQLObject 0.10.7 ================ +Released 20 Sep 2009 + * Fixed a bug: Sybase tables with identity column fire two identity_inserts. * Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a |
|
From: <sub...@co...> - 2009-09-20 18:59:50
|
Author: phd Date: 2009-09-20 12:59:37 -0600 (Sun, 20 Sep 2009) New Revision: 3985 Modified: SQLObject/branches/0.11/docs/News.txt Log: SQLObject 0.11.1 and SQLObject 0.10.7 released 20 Sep 2009. Modified: SQLObject/branches/0.11/docs/News.txt =================================================================== --- SQLObject/branches/0.11/docs/News.txt 2009-09-20 18:57:54 UTC (rev 3984) +++ SQLObject/branches/0.11/docs/News.txt 2009-09-20 18:59:37 UTC (rev 3985) @@ -10,6 +10,8 @@ SQLObject 0.11.1 ================ +Released 20 Sep 2009 + * A number of changes ported from `SQLObject 0.10.7`_. SQLObject 0.11.0 @@ -63,6 +65,8 @@ SQLObject 0.10.7 ================ +Released 20 Sep 2009 + * Fixed a bug: Sybase tables with identity column fire two identity_inserts. * Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a |
|
From: <sub...@co...> - 2009-09-20 18:58:05
|
Author: phd Date: 2009-09-20 12:57:54 -0600 (Sun, 20 Sep 2009) New Revision: 3984 Modified: SQLObject/branches/0.10/docs/News.txt Log: SQLObject 0.10.7 released 20 Sep 2009. Modified: SQLObject/branches/0.10/docs/News.txt =================================================================== --- SQLObject/branches/0.10/docs/News.txt 2009-09-20 16:34:07 UTC (rev 3983) +++ SQLObject/branches/0.10/docs/News.txt 2009-09-20 18:57:54 UTC (rev 3984) @@ -10,6 +10,8 @@ SQLObject 0.10.7 ================ +Released 20 Sep 2009 + * Fixed a bug: Sybase tables with identity column fire two identity_inserts. * Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a |
|
From: SourceForge.net <no...@so...> - 2009-09-20 16:38:50
|
Bugs item #2853734, was opened at 2009-09-07 21:38 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2853734&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. >Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Mario Gala (mariogala) Assigned to: Oleg Broytmann (phd) Summary: Underscore not escaped for LIKE Initial Comment: The _LikeQuoted class (in sqlbuilder.py) is not escaping the underscore character '_' (whereas the percent character '%' is escaped correctly). Indeed in MySQL the underscore character in a LIKE pattern represents a wildcard to match exactly one character (http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html), so it should be probably escaped there (at least for MySQL, not sure about other databases). ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2009-09-20 20:38 Message: Fixed in the revisions 3981-3983 (branches 0.10, 0.11 and the trunk). Will be in the next round of releases. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2853734&group_id=74338 |
|
From: <sub...@co...> - 2009-09-20 16:34:17
|
Author: phd
Date: 2009-09-20 10:34:07 -0600 (Sun, 20 Sep 2009)
New Revision: 3983
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/sqlobject/sqlbuilder.py
SQLObject/trunk/sqlobject/tests/test_select.py
Log:
Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a
backslash) all special characters (backslashes, underscores and percent signs).
Modified: SQLObject/trunk/docs/News.txt
===================================================================
--- SQLObject/trunk/docs/News.txt 2009-09-20 16:27:23 UTC (rev 3982)
+++ SQLObject/trunk/docs/News.txt 2009-09-20 16:34:07 UTC (rev 3983)
@@ -106,6 +106,10 @@
* Fixed a bug: Sybase tables with identity column fire two identity_inserts.
+* Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a
+ backslash) all special characters (backslashes, underscores and percent
+ signs).
+
SQLObject 0.10.6
================
Modified: SQLObject/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2009-09-20 16:27:23 UTC (rev 3982)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2009-09-20 16:34:07 UTC (rev 3983)
@@ -840,13 +840,13 @@
return NOT(_IN(item, list))
def STARTSWITH(expr, pattern):
- return SQLOp("LIKE", expr, _LikeQuoted(pattern) + '%')
+ return LIKE(expr, _LikeQuoted(pattern) + '%', escape='\\')
def ENDSWITH(expr, pattern):
- return SQLOp("LIKE", expr, '%' + _LikeQuoted(pattern))
+ return LIKE(expr, '%' + _LikeQuoted(pattern), escape='\\')
def CONTAINSSTRING(expr, pattern):
- return SQLOp("LIKE", expr, '%' + _LikeQuoted(pattern) + '%')
+ return LIKE(expr, '%' + _LikeQuoted(pattern) + '%', escape='\\')
def ISNULL(expr):
return SQLOp("IS", expr, None)
@@ -888,7 +888,7 @@
values = []
if self.prefix:
values.append("'%s'" % self.prefix)
- s = _quote_percent(sqlrepr(s, db), db)
+ s = _quote_like_special(sqlrepr(s, db), db)
values.append(s)
if self.postfix:
values.append("'%s'" % self.postfix)
@@ -897,16 +897,17 @@
else:
return " || ".join(values)
elif isinstance(s, basestring):
- s = _quote_percent(sqlrepr(s, db)[1:-1], db)
+ s = _quote_like_special(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
else:
raise TypeError, "expected str, unicode or SQLExpression, got %s" % type(s)
-def _quote_percent(s, db):
- if db in ('postgres', 'mysql'):
- s = s.replace('%', '\\%')
+def _quote_like_special(s, db):
+ if db == 'postgres':
+ escape = r'\\'
else:
- s = s.replace('%', '%%')
+ escape = '\\'
+ s = s.replace('\\', r'\\').replace('%', escape+'%').replace('_', escape+'_')
return s
########################################
@@ -1135,11 +1136,17 @@
class LIKE(SQLExpression):
op = "LIKE"
- def __init__(self, expr, string):
+ def __init__(self, expr, string, escape=None):
self.expr = expr
self.string = string
+ self.escape = escape
def __sqlrepr__(self, db):
- return "(%s %s (%s))" % (sqlrepr(self.expr, db), self.op, sqlrepr(self.string, db))
+ escape = self.escape
+ like = "%s %s (%s)" % (sqlrepr(self.expr, db), self.op, sqlrepr(self.string, db))
+ if escape is None:
+ return "(%s)" % like
+ else:
+ return "(%s ESCAPE %s)" % (like, sqlrepr(escape, db))
def components(self):
return [self.expr, self.string]
def execute(self, executor):
@@ -1157,15 +1164,16 @@
class RLIKE(LIKE):
op = "RLIKE"
+ op_db = {
+ 'firebird': 'RLIKE',
+ 'maxdb': 'RLIKE',
+ 'mysql': 'RLIKE',
+ 'postgres': '~',
+ 'sqlite': 'REGEXP'
+ }
+
def _get_op(self, db):
- if db in ('mysql', 'maxdb', 'firebird'):
- return "RLIKE"
- elif db == 'sqlite':
- return "REGEXP"
- elif db == 'postgres':
- return "~"
- else:
- return "LIKE"
+ return self.op_db.get(db, 'LIKE')
def __sqlrepr__(self, db):
return "(%s %s (%s))" % (
sqlrepr(self.expr, db), self._get_op(db), sqlrepr(self.string, db)
Modified: SQLObject/trunk/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_select.py 2009-09-20 16:27:23 UTC (rev 3982)
+++ SQLObject/trunk/sqlobject/tests/test_select.py 2009-09-20 16:34:07 UTC (rev 3983)
@@ -69,14 +69,23 @@
assert len(list(IterTest.select(limit=2))) == 2
raises(AssertionError, IterTest.select(limit=2).count)
-def test_06_like():
+def test_06_contains():
setupIter()
assert len(list(IterTest.select(IterTest.q.name.startswith('a')))) == 1
- assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains(func.lower('A'))))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains("a'b")))) == 0
+ assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
+def test_07_contains_special():
+ setupClass(IterTest)
+ a = IterTest(name='\\test')
+ b = IterTest(name='100%')
+ c = IterTest(name='test_')
+ assert list(IterTest.select(IterTest.q.name.startswith('\\'))) == [a]
+ assert list(IterTest.select(IterTest.q.name.contains('%'))) == [b]
+ assert list(IterTest.select(IterTest.q.name.endswith('_'))) == [c]
+
def test_select_getOne():
setupClass(IterTest)
a = IterTest(name='a')
|
|
From: <sub...@co...> - 2009-09-20 16:27:33
|
Author: phd
Date: 2009-09-20 10:27:23 -0600 (Sun, 20 Sep 2009)
New Revision: 3982
Modified:
SQLObject/branches/0.11/docs/News.txt
SQLObject/branches/0.11/sqlobject/sqlbuilder.py
SQLObject/branches/0.11/sqlobject/tests/test_select.py
Log:
Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a
backslash) all special characters (backslashes, underscores and percent signs).
Modified: SQLObject/branches/0.11/docs/News.txt
===================================================================
--- SQLObject/branches/0.11/docs/News.txt 2009-09-20 16:25:09 UTC (rev 3981)
+++ SQLObject/branches/0.11/docs/News.txt 2009-09-20 16:27:23 UTC (rev 3982)
@@ -65,6 +65,10 @@
* Fixed a bug: Sybase tables with identity column fire two identity_inserts.
+* Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a
+ backslash) all special characters (backslashes, underscores and percent
+ signs).
+
SQLObject 0.10.6
================
Modified: SQLObject/branches/0.11/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.11/sqlobject/sqlbuilder.py 2009-09-20 16:25:09 UTC (rev 3981)
+++ SQLObject/branches/0.11/sqlobject/sqlbuilder.py 2009-09-20 16:27:23 UTC (rev 3982)
@@ -853,13 +853,13 @@
return NOT(_IN(item, list))
def STARTSWITH(expr, pattern):
- return SQLOp("LIKE", expr, _LikeQuoted(pattern) + '%')
+ return LIKE(expr, _LikeQuoted(pattern) + '%', escape='\\')
def ENDSWITH(expr, pattern):
- return SQLOp("LIKE", expr, '%' + _LikeQuoted(pattern))
+ return LIKE(expr, '%' + _LikeQuoted(pattern), escape='\\')
def CONTAINSSTRING(expr, pattern):
- return SQLOp("LIKE", expr, '%' + _LikeQuoted(pattern) + '%')
+ return LIKE(expr, '%' + _LikeQuoted(pattern) + '%', escape='\\')
def ISNULL(expr):
return SQLOp("IS", expr, None)
@@ -901,7 +901,7 @@
values = []
if self.prefix:
values.append("'%s'" % self.prefix)
- s = _quote_percent(sqlrepr(s, db), db)
+ s = _quote_like_special(sqlrepr(s, db), db)
values.append(s)
if self.postfix:
values.append("'%s'" % self.postfix)
@@ -910,16 +910,17 @@
else:
return " || ".join(values)
elif isinstance(s, basestring):
- s = _quote_percent(sqlrepr(s, db)[1:-1], db)
+ s = _quote_like_special(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
else:
raise TypeError, "expected str, unicode or SQLExpression, got %s" % type(s)
-def _quote_percent(s, db):
- if db in ('postgres', 'mysql'):
- s = s.replace('%', '\\%')
+def _quote_like_special(s, db):
+ if db == 'postgres':
+ escape = r'\\'
else:
- s = s.replace('%', '%%')
+ escape = '\\'
+ s = s.replace('\\', r'\\').replace('%', escape+'%').replace('_', escape+'_')
return s
########################################
@@ -1148,11 +1149,17 @@
class LIKE(SQLExpression):
op = "LIKE"
- def __init__(self, expr, string):
+ def __init__(self, expr, string, escape=None):
self.expr = expr
self.string = string
+ self.escape = escape
def __sqlrepr__(self, db):
- return "(%s %s (%s))" % (sqlrepr(self.expr, db), self.op, sqlrepr(self.string, db))
+ escape = self.escape
+ like = "%s %s (%s)" % (sqlrepr(self.expr, db), self.op, sqlrepr(self.string, db))
+ if escape is None:
+ return "(%s)" % like
+ else:
+ return "(%s ESCAPE %s)" % (like, sqlrepr(escape, db))
def components(self):
return [self.expr, self.string]
def execute(self, executor):
@@ -1170,15 +1177,16 @@
class RLIKE(LIKE):
op = "RLIKE"
+ op_db = {
+ 'firebird': 'RLIKE',
+ 'maxdb': 'RLIKE',
+ 'mysql': 'RLIKE',
+ 'postgres': '~',
+ 'sqlite': 'REGEXP'
+ }
+
def _get_op(self, db):
- if db in ('mysql', 'maxdb', 'firebird'):
- return "RLIKE"
- elif db == 'sqlite':
- return "REGEXP"
- elif db == 'postgres':
- return "~"
- else:
- return "LIKE"
+ return self.op_db.get(db, 'LIKE')
def __sqlrepr__(self, db):
return "(%s %s (%s))" % (
sqlrepr(self.expr, db), self._get_op(db), sqlrepr(self.string, db)
Modified: SQLObject/branches/0.11/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.11/sqlobject/tests/test_select.py 2009-09-20 16:25:09 UTC (rev 3981)
+++ SQLObject/branches/0.11/sqlobject/tests/test_select.py 2009-09-20 16:27:23 UTC (rev 3982)
@@ -69,14 +69,23 @@
assert len(list(IterTest.select(limit=2))) == 2
raises(AssertionError, IterTest.select(limit=2).count)
-def test_06_like():
+def test_06_contains():
setupIter()
assert len(list(IterTest.select(IterTest.q.name.startswith('a')))) == 1
- assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains(func.lower('A'))))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains("a'b")))) == 0
+ assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
+def test_07_contains_special():
+ setupClass(IterTest)
+ a = IterTest(name='\\test')
+ b = IterTest(name='100%')
+ c = IterTest(name='test_')
+ assert list(IterTest.select(IterTest.q.name.startswith('\\'))) == [a]
+ assert list(IterTest.select(IterTest.q.name.contains('%'))) == [b]
+ assert list(IterTest.select(IterTest.q.name.endswith('_'))) == [c]
+
def test_select_getOne():
setupClass(IterTest)
a = IterTest(name='a')
|
|
From: <sub...@co...> - 2009-09-20 16:25:21
|
Author: phd
Date: 2009-09-20 10:25:09 -0600 (Sun, 20 Sep 2009)
New Revision: 3981
Modified:
SQLObject/branches/0.10/docs/News.txt
SQLObject/branches/0.10/sqlobject/sqlbuilder.py
SQLObject/branches/0.10/sqlobject/tests/test_select.py
Log:
Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a
backslash) all special characters (backslashes, underscores and percent signs).
Modified: SQLObject/branches/0.10/docs/News.txt
===================================================================
--- SQLObject/branches/0.10/docs/News.txt 2009-09-20 15:53:02 UTC (rev 3980)
+++ SQLObject/branches/0.10/docs/News.txt 2009-09-20 16:25:09 UTC (rev 3981)
@@ -12,6 +12,10 @@
* Fixed a bug: Sybase tables with identity column fire two identity_inserts.
+* Fixed a bug: q.startswith(), q.contains() and q.endswith() escape (with a
+ backslash) all special characters (backslashes, underscores and percent
+ signs).
+
SQLObject 0.10.6
================
Modified: SQLObject/branches/0.10/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/sqlbuilder.py 2009-09-20 15:53:02 UTC (rev 3980)
+++ SQLObject/branches/0.10/sqlobject/sqlbuilder.py 2009-09-20 16:25:09 UTC (rev 3981)
@@ -883,7 +883,7 @@
values = []
if self.prefix:
values.append("'%s'" % self.prefix)
- s = _quote_percent(sqlrepr(s, db), db)
+ s = _quote_like_special(sqlrepr(s, db), db)
values.append(s)
if self.postfix:
values.append("'%s'" % self.postfix)
@@ -892,16 +892,17 @@
else:
return " || ".join(values)
elif isinstance(s, basestring):
- s = _quote_percent(sqlrepr(s, db)[1:-1], db)
+ s = _quote_like_special(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
else:
raise TypeError, "expected str, unicode or SQLExpression, got %s" % type(s)
-def _quote_percent(s, db):
- if db in ('postgres', 'mysql'):
- s = s.replace('%', '\\%')
+def _quote_like_special(s, db):
+ if db == 'postgres':
+ escape = r'\\'
else:
- s = s.replace('%', '%%')
+ escape = '\\'
+ s = s.replace('\\', r'\\').replace('%', escape+'%').replace('_', escape+'_')
return s
########################################
@@ -1140,7 +1141,7 @@
if escape is None:
return "(%s)" % like
else:
- return "(%s ESCAPE '%s')" % (like, escape)
+ return "(%s ESCAPE %s)" % (like, sqlrepr(escape, db))
def components(self):
return [self.expr, self.string]
def execute(self, executor):
Modified: SQLObject/branches/0.10/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/tests/test_select.py 2009-09-20 15:53:02 UTC (rev 3980)
+++ SQLObject/branches/0.10/sqlobject/tests/test_select.py 2009-09-20 16:25:09 UTC (rev 3981)
@@ -69,14 +69,23 @@
assert len(list(IterTest.select(limit=2))) == 2
raises(AssertionError, IterTest.select(limit=2).count)
-def test_06_like():
+def test_06_contains():
setupIter()
assert len(list(IterTest.select(IterTest.q.name.startswith('a')))) == 1
- assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains(func.lower('A'))))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains("a'b")))) == 0
+ assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
+def test_07_contains_special():
+ setupClass(IterTest)
+ a = IterTest(name='\\test')
+ b = IterTest(name='100%')
+ c = IterTest(name='test_')
+ assert list(IterTest.select(IterTest.q.name.startswith('\\'))) == [a]
+ assert list(IterTest.select(IterTest.q.name.contains('%'))) == [b]
+ assert list(IterTest.select(IterTest.q.name.endswith('_'))) == [c]
+
def test_select_getOne():
setupClass(IterTest)
a = IterTest(name='a')
|
|
From: <sub...@co...> - 2009-09-20 15:53:14
|
Author: phd
Date: 2009-09-20 09:53:02 -0600 (Sun, 20 Sep 2009)
New Revision: 3980
Modified:
SQLObject/branches/0.10/sqlobject/sqlbuilder.py
Log:
Use LIKE() instead of SQLOp('LIKE'); pass backslash as the escape.
Modified: SQLObject/branches/0.10/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/sqlbuilder.py 2009-09-20 15:50:22 UTC (rev 3979)
+++ SQLObject/branches/0.10/sqlobject/sqlbuilder.py 2009-09-20 15:53:02 UTC (rev 3980)
@@ -835,13 +835,13 @@
return NOT(_IN(item, list))
def STARTSWITH(expr, pattern):
- return SQLOp("LIKE", expr, _LikeQuoted(pattern) + '%')
+ return LIKE(expr, _LikeQuoted(pattern) + '%', escape='\\')
def ENDSWITH(expr, pattern):
- return SQLOp("LIKE", expr, '%' + _LikeQuoted(pattern))
+ return LIKE(expr, '%' + _LikeQuoted(pattern), escape='\\')
def CONTAINSSTRING(expr, pattern):
- return SQLOp("LIKE", expr, '%' + _LikeQuoted(pattern) + '%')
+ return LIKE(expr, '%' + _LikeQuoted(pattern) + '%', escape='\\')
def ISNULL(expr):
return SQLOp("IS", expr, None)
|
|
From: <sub...@co...> - 2009-09-20 15:50:35
|
Author: phd
Date: 2009-09-20 09:50:22 -0600 (Sun, 20 Sep 2009)
New Revision: 3979
Modified:
SQLObject/branches/0.10/sqlobject/sqlbuilder.py
Log:
LIKE ... ESCAPE ...
Modified: SQLObject/branches/0.10/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/sqlbuilder.py 2009-09-20 15:42:20 UTC (rev 3978)
+++ SQLObject/branches/0.10/sqlobject/sqlbuilder.py 2009-09-20 15:50:22 UTC (rev 3979)
@@ -1130,11 +1130,17 @@
class LIKE(SQLExpression):
op = "LIKE"
- def __init__(self, expr, string):
+ def __init__(self, expr, string, escape=None):
self.expr = expr
self.string = string
+ self.escape = escape
def __sqlrepr__(self, db):
- return "(%s %s (%s))" % (sqlrepr(self.expr, db), self.op, sqlrepr(self.string, db))
+ escape = self.escape
+ like = "%s %s (%s)" % (sqlrepr(self.expr, db), self.op, sqlrepr(self.string, db))
+ if escape is None:
+ return "(%s)" % like
+ else:
+ return "(%s ESCAPE '%s')" % (like, escape)
def components(self):
return [self.expr, self.string]
def execute(self, executor):
|
|
From: <sub...@co...> - 2009-09-20 15:42:36
|
Author: phd
Date: 2009-09-20 09:42:20 -0600 (Sun, 20 Sep 2009)
New Revision: 3978
Modified:
SQLObject/branches/0.10/sqlobject/sqlbuilder.py
Log:
Refactored RLIKE.
Modified: SQLObject/branches/0.10/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/sqlbuilder.py 2009-09-14 16:07:38 UTC (rev 3977)
+++ SQLObject/branches/0.10/sqlobject/sqlbuilder.py 2009-09-20 15:42:20 UTC (rev 3978)
@@ -1152,15 +1152,16 @@
class RLIKE(LIKE):
op = "RLIKE"
+ op_db = {
+ 'firebird': 'RLIKE',
+ 'maxdb': 'RLIKE',
+ 'mysql': 'RLIKE',
+ 'postgres': '~',
+ 'sqlite': 'REGEXP'
+ }
+
def _get_op(self, db):
- if db in ('mysql', 'maxdb', 'firebird'):
- return "RLIKE"
- elif db == 'sqlite':
- return "REGEXP"
- elif db == 'postgres':
- return "~"
- else:
- return "LIKE"
+ return self.op_db.get(db, 'LIKE')
def __sqlrepr__(self, db):
return "(%s %s (%s))" % (
sqlrepr(self.expr, db), self._get_op(db), sqlrepr(self.string, db)
|