sqlobject-cvs Mailing List for SQLObject (Page 122)
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...> - 2006-09-01 13:14:15
|
Author: phd
Date: 2006-09-01 07:14:02 -0600 (Fri, 01 Sep 2006)
New Revision: 1895
Modified:
SQLObject/docs/News.txt
SQLObject/docs/SQLObject.txt
Log:
Updated docs.
Modified: SQLObject/docs/News.txt
===================================================================
--- SQLObject/docs/News.txt 2006-09-01 13:12:58 UTC (rev 1894)
+++ SQLObject/docs/News.txt 2006-09-01 13:14:02 UTC (rev 1895)
@@ -109,6 +109,25 @@
Bug Fixes
---------
+* Fixed a longstanding problem with UnicodeCol - at last you can use unicode
+ strings in .select() and .selectBy() queries. There are some limitations,
+ though:
+
+ - only simple q-magic fields are supported; no expressions;
+ - only == and <> operators are supported;
+
+ The following code works::
+
+ MyTable.select(u'value' == MyTable.q.name)
+ MyTable.select(MyTable.q.name <> u'value')
+ MyTable.select(OR(MyTable.q.col1 == u'value1', MyTable.q.col2 <> u'value2'))
+ MyTable.selectBy(name = u'value')
+ MyTable.selectBy(col1=u'value1', col2=u'value2')
+
+ The following still does not work::
+
+ MyTable.select((MyTable.q.name + MyTable.q.surname) == u'value')
+
* Cull patch (clear cache).
* .destroySelf() inside a transaction.
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2006-09-01 13:12:58 UTC (rev 1894)
+++ SQLObject/docs/SQLObject.txt 2006-09-01 13:14:02 UTC (rev 1895)
@@ -1128,11 +1128,28 @@
A subclass of `StringCol`. Also accepts a dbEncoding keyword
argument, which defaults to ``"UTF-8"``. Values coming in and
out from the database will be encoded and decoded. **Note**:
- parameters in queries will not be automatically encoded, so if
- you do a query matching a UnicodeCol column you must apply the
- encoding yourself.
+ there are some limitations on using UnicodeCol in queries:
+ - only simple q-magic fields are supported; no expressions;
+ - only == and <> operators are supported;
+ The following code works::
+
+ MyTable.select(u'value' == MyTable.q.name)
+ MyTable.select(MyTable.q.name <> u'value')
+ MyTable.select(OR(MyTable.q.col1 == u'value1', MyTable.q.col2 <> u'value2'))
+ MyTable.selectBy(name = u'value')
+ MyTable.selectBy(col1=u'value1', col2=u'value2')
+
+ The following does not work::
+
+ MyTable.select((MyTable.q.name + MyTable.q.surname) == u'value')
+
+ In that case you must apply the encoding yourself::
+
+ MyTable.select((MyTable.q.name + MyTable.q.surname) == u'value'.encode(dbEncoding))
+
+
.. Relationships_:
Relationships Between Classes/Tables
|
|
From: <sub...@co...> - 2006-09-01 13:13:01
|
Author: phd
Date: 2006-09-01 07:12:58 -0600 (Fri, 01 Sep 2006)
New Revision: 1894
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
SQLObject/branches/0.7-bugfix/sqlobject/main.py
SQLObject/branches/0.7-bugfix/sqlobject/sqlbuilder.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_unicode.py
Log:
Fixed a longstanding problem with UnicodeCol - at last you can use unicode
strings in .select() and .selectBy() queries (with some limitations).
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2006-09-01 13:12:23 UTC (rev 1893)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2006-09-01 13:12:58 UTC (rev 1894)
@@ -49,6 +49,25 @@
Bug Fixes
---------
+* Fixed a longstanding problem with UnicodeCol - at last you can use unicode
+ strings in .select() and .selectBy() queries. There are some limitations,
+ though:
+
+ - only simple q-magic fields are supported; no expressions;
+ - only == and <> operators are supported;
+
+ The following code works::
+
+ MyTable.select(u'value' == MyTable.q.name)
+ MyTable.select(MyTable.q.name <> u'value')
+ MyTable.select(OR(MyTable.q.col1 == u'value1', MyTable.q.col2 <> u'value2'))
+ MyTable.selectBy(name = u'value')
+ MyTable.selectBy(col1=u'value1', col2=u'value2')
+
+ The following still does not work::
+
+ MyTable.select((MyTable.q.name + MyTable.q.surname) == u'value')
+
* Cull patch (clear cache).
* .destroySelf() inside a transaction.
Modified: SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-09-01 13:12:23 UTC (rev 1893)
+++ SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-09-01 13:12:58 UTC (rev 1894)
@@ -1127,11 +1127,28 @@
A subclass of `StringCol`. Also accepts a dbEncoding keyword
argument, which defaults to ``"UTF-8"``. Values coming in and
out from the database will be encoded and decoded. **Note**:
- parameters in queries will not be automatically encoded, so if
- you do a query matching a UnicodeCol column you must apply the
- encoding yourself.
+ there are some limitations on using UnicodeCol in queries:
+ - only simple q-magic fields are supported; no expressions;
+ - only == and <> operators are supported;
+ The following code works::
+
+ MyTable.select(u'value' == MyTable.q.name)
+ MyTable.select(MyTable.q.name <> u'value')
+ MyTable.select(OR(MyTable.q.col1 == u'value1', MyTable.q.col2 <> u'value2'))
+ MyTable.selectBy(name = u'value')
+ MyTable.selectBy(col1=u'value1', col2=u'value2')
+
+ The following does not work::
+
+ MyTable.select((MyTable.q.name + MyTable.q.surname) == u'value')
+
+ In that case you must apply the encoding yourself::
+
+ MyTable.select((MyTable.q.name + MyTable.q.surname) == u'value'.encode(dbEncoding))
+
+
.. Relationships_:
Relationships Between Classes/Tables
Modified: SQLObject/branches/0.7-bugfix/sqlobject/main.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/main.py 2006-09-01 13:12:23 UTC (rev 1893)
+++ SQLObject/branches/0.7-bugfix/sqlobject/main.py 2006-09-01 13:12:58 UTC (rev 1894)
@@ -1297,6 +1297,11 @@
select = classmethod(select)
def selectBy(cls, connection=None, **kw):
+ for key, column in cls.sqlmeta.columns.items():
+ if (key in kw) and isinstance(column, col.SOUnicodeCol):
+ value = kw[key]
+ if isinstance(value, unicode):
+ kw[key] = value.encode(column.dbEncoding)
conn = connection or cls._connection
return cls.SelectResultsClass(cls,
conn._SO_columnClause(cls, kw),
Modified: SQLObject/branches/0.7-bugfix/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/sqlbuilder.py 2006-09-01 13:12:23 UTC (rev 1893)
+++ SQLObject/branches/0.7-bugfix/sqlobject/sqlbuilder.py 2006-09-01 13:12:58 UTC (rev 1894)
@@ -323,6 +323,23 @@
registerConverter(SQLObjectField, SQLExprConverter)
+
+class UnicodeField(SQLObjectField):
+ def __init__(self, tableName, fieldName, original, column):
+ SQLObjectField.__init__(self, tableName, fieldName, original)
+ self.column = column
+ def __eq__(self, other):
+ if isinstance(other, unicode):
+ other = other.encode(self.column.dbEncoding)
+ return SQLOp('=', self, other)
+ def __ne__(self, other):
+ if isinstance(other, unicode):
+ other = other.encode(self.column.dbEncoding)
+ return SQLOp('<>', self, other)
+
+registerConverter(UnicodeField, SQLExprConverter)
+
+
class Table(SQLExpression):
FieldClass = Field
@@ -339,6 +356,7 @@
class SQLObjectTable(Table):
FieldClass = SQLObjectField
+ UnicodeFieldClass = UnicodeField
def __init__(self, soClass):
self.soClass = soClass
@@ -355,9 +373,12 @@
elif attr not in self.soClass.sqlmeta.columns:
raise AttributeError("%s instance has no attribute '%s'" % (self.soClass.__name__, attr))
else:
- return self.FieldClass(self.tableName,
- self.soClass.sqlmeta.columns[attr].dbName,
- attr)
+ column = self.soClass.sqlmeta.columns[attr]
+ if hasattr(column, "dbEncoding"):
+ return self.UnicodeFieldClass(self.tableName, column.dbName,
+ attr, column)
+ else:
+ return self.FieldClass(self.tableName, column.dbName, attr)
class TableSpace:
TableClass = Table
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_unicode.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_unicode.py 2006-09-01 13:12:23 UTC (rev 1893)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_unicode.py 2006-09-01 13:12:58 UTC (rev 1894)
@@ -5,7 +5,7 @@
## Unicode columns
########################################
-class Unicode1(SQLObject):
+class TestUnicode(SQLObject):
count = IntCol(alternateID=True)
col1 = UnicodeCol()
col2 = UnicodeCol(dbEncoding='latin-1')
@@ -16,24 +16,54 @@
def enumerate(lst):
return [(i, lst[i]) for i in range(len(lst))]
-def test_create():
- setupClass(Unicode1)
- data = [u'\u00f0', u'test', 'ascii test']
+data = [u'\u00f0', u'test', 'ascii test']
+items = []
+def setup():
+ global items
items = []
+ setupClass(TestUnicode)
for i, n in enumerate(data):
- items.append(Unicode1(count=i, col1=n, col2=n))
+ items.append(TestUnicode(count=i, col1=n, col2=n))
+
+def test_create():
+ setup()
for n, item in zip(data, items):
- item.col1 = item.col2 = n
- for n, item in zip(data, items):
assert item.col1 == item.col2
assert item.col1 == n
- conn = Unicode1._connection
+
+ conn = TestUnicode._connection
rows = conn.queryAll("""
SELECT count, col1, col2
- FROM unicode1
+ FROM test_unicode
ORDER BY count
""")
for count, col1, col2 in rows:
assert data[count].encode('utf-8') == col1
assert data[count].encode('latin1') == col2
+
+def test_select():
+ setup()
+ for value in data:
+ rows = list(TestUnicode.select(TestUnicode.q.col1 == value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.select(TestUnicode.q.col2 == value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.select(AND(
+ TestUnicode.q.col1 == value,
+ TestUnicode.q.col2 == value
+ )))
+ assert len(rows) == 1
+ rows = list(TestUnicode.selectBy(col1=value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.selectBy(col2=value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.selectBy(col1=value, col2=value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.select(OR(
+ TestUnicode.q.col1 == u'\u00f0',
+ TestUnicode.q.col2 == u'test'
+ )))
+ assert len(rows) == 2
+ rows = list(TestUnicode.selectBy(col1=u'\u00f0', col2=u'test'))
+ assert len(rows) == 0
|
|
From: <sub...@co...> - 2006-09-01 13:12:25
|
Author: phd
Date: 2006-09-01 07:12:23 -0600 (Fri, 01 Sep 2006)
New Revision: 1893
Modified:
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/sqlbuilder.py
SQLObject/trunk/sqlobject/tests/test_unicode.py
Log:
Fixed a longstanding problem with UnicodeCol - at last you can use unicode
strings in .select() and .selectBy() queries (with some limitations).
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2006-09-01 12:59:15 UTC (rev 1892)
+++ SQLObject/trunk/sqlobject/main.py 2006-09-01 13:12:23 UTC (rev 1893)
@@ -1328,6 +1328,11 @@
select = classmethod(select)
def selectBy(cls, connection=None, **kw):
+ for key, column in cls.sqlmeta.columns.items():
+ if (key in kw) and isinstance(column, col.SOUnicodeCol):
+ value = kw[key]
+ if isinstance(value, unicode):
+ kw[key] = value.encode(column.dbEncoding)
conn = connection or cls._connection
return cls.SelectResultsClass(cls,
conn._SO_columnClause(cls, kw),
Modified: SQLObject/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2006-09-01 12:59:15 UTC (rev 1892)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2006-09-01 13:12:23 UTC (rev 1893)
@@ -326,6 +326,23 @@
registerConverter(SQLObjectField, SQLExprConverter)
+
+class UnicodeField(SQLObjectField):
+ def __init__(self, tableName, fieldName, original, column):
+ SQLObjectField.__init__(self, tableName, fieldName, original)
+ self.column = column
+ def __eq__(self, other):
+ if isinstance(other, unicode):
+ other = other.encode(self.column.dbEncoding)
+ return SQLOp('=', self, other)
+ def __ne__(self, other):
+ if isinstance(other, unicode):
+ other = other.encode(self.column.dbEncoding)
+ return SQLOp('<>', self, other)
+
+registerConverter(UnicodeField, SQLExprConverter)
+
+
class Table(SQLExpression):
FieldClass = Field
@@ -342,6 +359,7 @@
class SQLObjectTable(Table):
FieldClass = SQLObjectField
+ UnicodeFieldClass = UnicodeField
def __init__(self, soClass):
self.soClass = soClass
@@ -358,9 +376,12 @@
elif attr not in self.soClass.sqlmeta.columns:
raise AttributeError("%s instance has no attribute '%s'" % (self.soClass.__name__, attr))
else:
- return self.FieldClass(self.tableName,
- self.soClass.sqlmeta.columns[attr].dbName,
- attr)
+ column = self.soClass.sqlmeta.columns[attr]
+ if hasattr(column, "dbEncoding"):
+ return self.UnicodeFieldClass(self.tableName, column.dbName,
+ attr, column)
+ else:
+ return self.FieldClass(self.tableName, column.dbName, attr)
class TableSpace:
TableClass = Table
Modified: SQLObject/trunk/sqlobject/tests/test_unicode.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_unicode.py 2006-09-01 12:59:15 UTC (rev 1892)
+++ SQLObject/trunk/sqlobject/tests/test_unicode.py 2006-09-01 13:12:23 UTC (rev 1893)
@@ -5,7 +5,7 @@
## Unicode columns
########################################
-class Unicode1(SQLObject):
+class TestUnicode(SQLObject):
count = IntCol(alternateID=True)
col1 = UnicodeCol()
col2 = UnicodeCol(dbEncoding='latin-1')
@@ -16,24 +16,54 @@
def enumerate(lst):
return [(i, lst[i]) for i in range(len(lst))]
-def test_create():
- setupClass(Unicode1)
- data = [u'\u00f0', u'test', 'ascii test']
+data = [u'\u00f0', u'test', 'ascii test']
+items = []
+def setup():
+ global items
items = []
+ setupClass(TestUnicode)
for i, n in enumerate(data):
- items.append(Unicode1(count=i, col1=n, col2=n))
+ items.append(TestUnicode(count=i, col1=n, col2=n))
+
+def test_create():
+ setup()
for n, item in zip(data, items):
- item.col1 = item.col2 = n
- for n, item in zip(data, items):
assert item.col1 == item.col2
assert item.col1 == n
- conn = Unicode1._connection
+
+ conn = TestUnicode._connection
rows = conn.queryAll("""
SELECT count, col1, col2
- FROM unicode1
+ FROM test_unicode
ORDER BY count
""")
for count, col1, col2 in rows:
assert data[count].encode('utf-8') == col1
assert data[count].encode('latin1') == col2
+
+def test_select():
+ setup()
+ for value in data:
+ rows = list(TestUnicode.select(TestUnicode.q.col1 == value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.select(TestUnicode.q.col2 == value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.select(AND(
+ TestUnicode.q.col1 == value,
+ TestUnicode.q.col2 == value
+ )))
+ assert len(rows) == 1
+ rows = list(TestUnicode.selectBy(col1=value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.selectBy(col2=value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.selectBy(col1=value, col2=value))
+ assert len(rows) == 1
+ rows = list(TestUnicode.select(OR(
+ TestUnicode.q.col1 == u'\u00f0',
+ TestUnicode.q.col2 == u'test'
+ )))
+ assert len(rows) == 2
+ rows = list(TestUnicode.selectBy(col1=u'\u00f0', col2=u'test'))
+ assert len(rows) == 0
|
|
From: <sub...@co...> - 2006-09-01 12:59:18
|
Author: phd
Date: 2006-09-01 06:59:15 -0600 (Fri, 01 Sep 2006)
New Revision: 1892
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/dbconnection.py
Log:
Fixed compatibility: Python 2.3 doesn't have .rsplit().
Modified: SQLObject/branches/0.7-bugfix/sqlobject/dbconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/dbconnection.py 2006-09-01 12:58:42 UTC (rev 1891)
+++ SQLObject/branches/0.7-bugfix/sqlobject/dbconnection.py 2006-09-01 12:59:15 UTC (rev 1892)
@@ -95,7 +95,8 @@
else:
host, rest = rest.split('/', 1)
if host and host.find('@') != -1:
- user, host = host.rsplit('@', 1)
+ user = host[:host.rfind('@')] # Python 2.3 doesn't have .rsplit()
+ host = host[host.rfind('@')+1:] # !!!
if user.find(':') != -1:
user, password = user.split(':', 1)
else:
|
|
From: <sub...@co...> - 2006-09-01 12:58:46
|
Author: phd
Date: 2006-09-01 06:58:42 -0600 (Fri, 01 Sep 2006)
New Revision: 1891
Modified:
SQLObject/trunk/sqlobject/dbconnection.py
Log:
Fixed compatibility: Python 2.3 doesn't have .rsplit().
Modified: SQLObject/trunk/sqlobject/dbconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/dbconnection.py 2006-08-29 17:07:41 UTC (rev 1890)
+++ SQLObject/trunk/sqlobject/dbconnection.py 2006-09-01 12:58:42 UTC (rev 1891)
@@ -95,7 +95,8 @@
else:
host, rest = rest.split('/', 1)
if host and host.find('@') != -1:
- user, host = host.rsplit('@', 1)
+ user = host[:host.rfind('@')] # Python 2.3 doesn't have .rsplit()
+ host = host[host.rfind('@')+1:] # !!!
if user.find(':') != -1:
user, password = user.split(':', 1)
else:
|
|
From: <sub...@co...> - 2006-08-29 14:26:07
|
Author: phd
Date: 2006-08-29 08:26:02 -0600 (Tue, 29 Aug 2006)
New Revision: 1889
Modified:
home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_parse.py
Log:
Merged patches from the revisions 1886:1888 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2006-08-29 14:20:29 UTC (rev 1888)
+++ home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2006-08-29 14:26:02 UTC (rev 1889)
@@ -96,7 +96,7 @@
else:
host, rest = rest.split('/', 1)
if host and host.find('@') != -1:
- user, host = host.split('@', 1)
+ user, host = host.rsplit('@', 1)
if user.find(':') != -1:
user, password = user.split(':', 1)
else:
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_parse.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_parse.py 2006-08-29 14:20:29 UTC (rev 1888)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_parse.py 2006-08-29 14:26:02 UTC (rev 1889)
@@ -48,6 +48,14 @@
assert path == "/full/path/to/socket/database"
assert args == {}
+ user, password, host, port, path, args = _parseURI("postgres://user:at@inpwd@host/database")
+ assert user == "user"
+ assert password == "at@inpwd"
+ assert host == "host"
+ assert port is None
+ assert path == "/database"
+ assert args == {}
+
user, password, host, port, path, args = _parseURI("sqlite:///full/path/to/database")
assert user is None
assert password is None
|
|
From: SourceForge.net <no...@so...> - 2006-08-29 14:23:37
|
Bugs item #1426574, was opened at 2006-02-07 23:43 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1426574&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 Submitted By: Nobody/Anonymous (nobody) >Assigned to: Oleg Broytmann (phd) Summary: Database passwords with '@' don't parse correctly. Initial Comment: As the title says, if your database password contains an '@' character, then the connection string is parsed incorrectly. To remidy this, I've used host.rfind('@') instead of host.find('@'). A patch for this would look something like (I hope the indentation works): dbconnection.py.ORIG dbconnection.py 94,99c94,102 < if host and host.find('@') != -1: < user, host = host.split('@', 1) < if user.find(':') != -1: < user, password = user.split(':', 1) < else: < password = None --- > if host: > at = host.rfind('@') > if at != -1: > user = host[:at] > host = host[at+1:] > if user.find(':') != -1: > user, password = user.split(':', 1) > else: > password = None gk...@gm... ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-08-29 18:23 Message: Logged In: YES user_id=4799 Fixed in the revision 1887 in the trunk, rev. 1888 in the 0.7-branch. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2006-02-07 23:45 Message: Logged In: NO Doesn't look like the indentation worked, but it should be easy to see that rather than using the split function, use the reverse find() to split the string. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1426574&group_id=74338 |
|
From: <sub...@co...> - 2006-08-29 14:20:32
|
Author: phd
Date: 2006-08-29 08:20:29 -0600 (Tue, 29 Aug 2006)
New Revision: 1888
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/dbconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py
Log:
Applied a patch by Ivan Horvath <i.h...@al...> to fix the bug 1426574:
Database passwords with '@' don't parse correctly.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/dbconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/dbconnection.py 2006-08-29 14:20:14 UTC (rev 1887)
+++ SQLObject/branches/0.7-bugfix/sqlobject/dbconnection.py 2006-08-29 14:20:29 UTC (rev 1888)
@@ -95,7 +95,7 @@
else:
host, rest = rest.split('/', 1)
if host and host.find('@') != -1:
- user, host = host.split('@', 1)
+ user, host = host.rsplit('@', 1)
if user.find(':') != -1:
user, password = user.split(':', 1)
else:
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py 2006-08-29 14:20:14 UTC (rev 1887)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py 2006-08-29 14:20:29 UTC (rev 1888)
@@ -48,6 +48,14 @@
assert path == "/full/path/to/socket/database"
assert args == {}
+ user, password, host, port, path, args = _parseURI("postgres://user:at@inpwd@host/database")
+ assert user == "user"
+ assert password == "at@inpwd"
+ assert host == "host"
+ assert port is None
+ assert path == "/database"
+ assert args == {}
+
user, password, host, port, path, args = _parseURI("sqlite:///full/path/to/database")
assert user is None
assert password is None
|
|
From: <sub...@co...> - 2006-08-29 14:20:22
|
Author: phd
Date: 2006-08-29 08:20:14 -0600 (Tue, 29 Aug 2006)
New Revision: 1887
Modified:
SQLObject/trunk/sqlobject/dbconnection.py
SQLObject/trunk/sqlobject/tests/test_parse.py
Log:
Applied a patch by Ivan Horvath <i.h...@al...> to fix the bug 1426574:
Database passwords with '@' don't parse correctly.
Modified: SQLObject/trunk/sqlobject/dbconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/dbconnection.py 2006-08-28 16:28:28 UTC (rev 1886)
+++ SQLObject/trunk/sqlobject/dbconnection.py 2006-08-29 14:20:14 UTC (rev 1887)
@@ -95,7 +95,7 @@
else:
host, rest = rest.split('/', 1)
if host and host.find('@') != -1:
- user, host = host.split('@', 1)
+ user, host = host.rsplit('@', 1)
if user.find(':') != -1:
user, password = user.split(':', 1)
else:
Modified: SQLObject/trunk/sqlobject/tests/test_parse.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_parse.py 2006-08-28 16:28:28 UTC (rev 1886)
+++ SQLObject/trunk/sqlobject/tests/test_parse.py 2006-08-29 14:20:14 UTC (rev 1887)
@@ -48,6 +48,14 @@
assert path == "/full/path/to/socket/database"
assert args == {}
+ user, password, host, port, path, args = _parseURI("postgres://user:at@inpwd@host/database")
+ assert user == "user"
+ assert password == "at@inpwd"
+ assert host == "host"
+ assert port is None
+ assert path == "/database"
+ assert args == {}
+
user, password, host, port, path, args = _parseURI("sqlite:///full/path/to/database")
assert user is None
assert password is None
|
|
From: SourceForge.net <no...@so...> - 2006-08-28 07:57:16
|
Bugs item #1547743, was opened at 2006-08-28 10:57 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1547743&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: MySQL Group: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Submitted By: dado1945 (dado1945) Assigned to: Nobody/Anonymous (nobody) Summary: sqlobject-0.7.1dev_r1884, Mysql and unicode Initial Comment: Please, check if suplied string is not unicode already in mysqlconnection.py. There is extract how it could look like: import types ..... if self.need_unicode: # For MysqlDB 1.2.1 and later, we go # encoding->unicode->charset (in the mysql db) if type(query) != types.UnicodeType: query = unicode(query, self.encoding) return cursor.execute(query) else: return cursor.execute(query) ..... Or use "isinstance(query, unicode)". I don't know what different we will have and which one is better to use however. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1547743&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-08-27 16:20:26
|
Patches item #1539325, was opened at 2006-08-12 14:42 Message generated for change (Comment added) made by abelcodemonk You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1539325&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 Submitted By: Arlo Belshee (abelcodemonk) Assigned to: Oleg Broytmann (phd) Summary: fromDatabase and delColumn for sqlite Initial Comment: This patch implements both fromDatabase and delColumn for sqlite. I added sqlite to the appropriate existing tests; it passes them. fromDatabase is done by parsing the table creation sql from the sqlite_master table. This will work with any sqlite 3, and I think dates back into sqlite 2, but I'm not sure. delColumn is implemented by renaming the table, creating a new table without the one column, then copying all the data over. This is obviously not as efficient as on DBs that support drop column directly, but it works. This implementation of dropColumn does deal correctly with triggers, foreign keys, and indices that reference the table whose column is being dropped. It does not deal correctly with triggers & indices attached directly to the table being altered. Attached items will be lost. Extending the implementation to support re-creating those indices & triggers should be straightforward, but is beyond my needs. You are welcome to do so. Finally, this patch slightly improves the implementation of addColumn for sqlite. It performs a vacuum operation after each column add. See the sqlite documentation for why this is a good idea. ---------------------------------------------------------------------- >Comment By: Arlo Belshee (abelcodemonk) Date: 2006-08-27 09:20 Message: Logged In: YES user_id=1027257 I've slightly update my previous patch. Feel free to use whichever version you'd like - I just want to get these new functions into the main code line as quickly as possible. I need them in order to support migrations in TurboGears. This update does two things: 1. svn:ignore *.pyc in a bunch of directories. 2. Add sqlite to the -transactions list in the supportsMatrix. Why: 1: I find it easier to see what needs to get added to svn if I don't have clutter on the various "modified files" lists. Thus, I make sure to always tell svn how to handle each file: ignore it or commit it. I find it reduces the chances of bad checkins. 2: sqlite fails several tests that require transactions. It really doesn't handle them well. This may be dues to my adding vacuuming to addColumn, or it may be new failures because I added sqlite to the list of DBs that support fromDatabase() and delColumn. In any case, I found this to be the fastest reasonable way to express what SQLite can do. Feel free to modify if you want to go another way. ---------------------------------------------------------------------- Comment By: Arlo Belshee (abelcodemonk) Date: 2006-08-27 09:09 Message: Logged In: YES user_id=1027257 Why vacuum after addColumn: According to SQLite's docs, alter table add column doesn't add the column to the table's main location in the file, but rather creates it at the end of the file and the DB then takes care of pretending that the column adjoins all the other columns. Unfortunately, older versions of SQLite don't do this pretending, so can't read a table that has had a column added. Vacuum re-creates the table as a single table, meaning that all versions can then read it. Delete column, being not supported directly by SQLite, doesn't do anything funny. Since my implementation is just to create a new table without the column being dropped, all the tables remain together without any weird extra space, and a vacuum is not needed. Why I added semicolons: No, they are not needed, if you are using pysqlite. However, they are required in the interactive SQLite interpreter. I added the semicolons so that I could quickly paste generated SQL statements into the interactive console while I was trying to get things working. Since the semicolons have no effect with pysqlite, I just left them in for the next time I wan't to do this. Feel free to take them out if you'd like. On the name of delColumn(): Feel free to name it delColumn. I gave the longer and clear name to the low-level implementation primarily to highlight the performance implications involved. The public-facing objects still expose delColumn; that is translated to a call to recreateTableWithoutColumn() if the sqliteconnection is being used. So, external programs use it as deleteColumn(), but my patch is easier to understand and the performance implications are clearer. Mostly, I was hoping that that would speed patch approval. ;) Feel free to name the function as you will. On transactions: Yeah, you can't vacuum in transactions. However, sqlite's support for transactions is already fairly problematic. I find I can't use transactions with SQLite on any real problems anyway, so I don't worry about it. When I need transactions, then I generally need a more full-featured DBMS than SQLite. If you have a different opinion on this, you could remove the call to vacuum in addColumn(). You are trading off read speed & the ability for older versions of sqlite to read such a modified table. Yer call. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-08-15 06:08 Message: Logged In: YES user_id=4799 Thank you very much! recreateTableWithoutColumn() is an excellent solution! I have some questions about the patch. Why have you added semicolons? I think they are not needed. Why VACUUM after addColumn()? It is more logical to do VACUUM after delColumn(), I suppose. And, BTW, "This command will fail if there is an active transaction." (from the SQLite documentation). Your patch deletes .delColumn(). But I have a number of programs that relies on a presence of the method (even if it's empty). I think you could just call recreateTableWithoutColumn() from delColumn() or raise a warning or an exception. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1539325&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-08-27 16:09:45
|
Patches item #1539325, was opened at 2006-08-12 14:42 Message generated for change (Comment added) made by abelcodemonk You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1539325&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 Submitted By: Arlo Belshee (abelcodemonk) Assigned to: Oleg Broytmann (phd) Summary: fromDatabase and delColumn for sqlite Initial Comment: This patch implements both fromDatabase and delColumn for sqlite. I added sqlite to the appropriate existing tests; it passes them. fromDatabase is done by parsing the table creation sql from the sqlite_master table. This will work with any sqlite 3, and I think dates back into sqlite 2, but I'm not sure. delColumn is implemented by renaming the table, creating a new table without the one column, then copying all the data over. This is obviously not as efficient as on DBs that support drop column directly, but it works. This implementation of dropColumn does deal correctly with triggers, foreign keys, and indices that reference the table whose column is being dropped. It does not deal correctly with triggers & indices attached directly to the table being altered. Attached items will be lost. Extending the implementation to support re-creating those indices & triggers should be straightforward, but is beyond my needs. You are welcome to do so. Finally, this patch slightly improves the implementation of addColumn for sqlite. It performs a vacuum operation after each column add. See the sqlite documentation for why this is a good idea. ---------------------------------------------------------------------- >Comment By: Arlo Belshee (abelcodemonk) Date: 2006-08-27 09:09 Message: Logged In: YES user_id=1027257 Why vacuum after addColumn: According to SQLite's docs, alter table add column doesn't add the column to the table's main location in the file, but rather creates it at the end of the file and the DB then takes care of pretending that the column adjoins all the other columns. Unfortunately, older versions of SQLite don't do this pretending, so can't read a table that has had a column added. Vacuum re-creates the table as a single table, meaning that all versions can then read it. Delete column, being not supported directly by SQLite, doesn't do anything funny. Since my implementation is just to create a new table without the column being dropped, all the tables remain together without any weird extra space, and a vacuum is not needed. Why I added semicolons: No, they are not needed, if you are using pysqlite. However, they are required in the interactive SQLite interpreter. I added the semicolons so that I could quickly paste generated SQL statements into the interactive console while I was trying to get things working. Since the semicolons have no effect with pysqlite, I just left them in for the next time I wan't to do this. Feel free to take them out if you'd like. On the name of delColumn(): Feel free to name it delColumn. I gave the longer and clear name to the low-level implementation primarily to highlight the performance implications involved. The public-facing objects still expose delColumn; that is translated to a call to recreateTableWithoutColumn() if the sqliteconnection is being used. So, external programs use it as deleteColumn(), but my patch is easier to understand and the performance implications are clearer. Mostly, I was hoping that that would speed patch approval. ;) Feel free to name the function as you will. On transactions: Yeah, you can't vacuum in transactions. However, sqlite's support for transactions is already fairly problematic. I find I can't use transactions with SQLite on any real problems anyway, so I don't worry about it. When I need transactions, then I generally need a more full-featured DBMS than SQLite. If you have a different opinion on this, you could remove the call to vacuum in addColumn(). You are trading off read speed & the ability for older versions of sqlite to read such a modified table. Yer call. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-08-15 06:08 Message: Logged In: YES user_id=4799 Thank you very much! recreateTableWithoutColumn() is an excellent solution! I have some questions about the patch. Why have you added semicolons? I think they are not needed. Why VACUUM after addColumn()? It is more logical to do VACUUM after delColumn(), I suppose. And, BTW, "This command will fail if there is an active transaction." (from the SQLite documentation). Your patch deletes .delColumn(). But I have a number of programs that relies on a presence of the method (even if it's empty). I think you could just call recreateTableWithoutColumn() from delColumn() or raise a warning or an exception. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1539325&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-08-26 04:05:08
|
Bugs item #1547004, was opened at 2006-08-26 00:05 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1547004&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: DBM Group: SQLObject from repository Status: Open Resolution: None Priority: 5 Submitted By: elpargo (elpargo) Assigned to: Nobody/Anonymous (nobody) Summary: SQLObject does not reconnect Initial Comment: this is from the 0.7bug fix branch a lot of background has been created on this in Turbogears bug tracker. mainly in http://trac.turbogears.org/turbogears/ticket/872 http://trac.turbogears.org/turbogears/ticket/781 Basically the connection after being idle is drop and SO engine is not aware of this. Many patches have been proposed but none accepted. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1547004&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-08-25 18:25:22
|
Bugs item #1305062, was opened at 2005-09-26 14:07 Message generated for change (Comment added) made by l33tminion You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1305062&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 Submitted By: Andy Dustman (adustman) Assigned to: Nobody/Anonymous (nobody) Summary: 0.7a: RelatedJoin() glue table has no constraints Initial Comment: Consider the example from the online 0.6.1 documentation, with the User and Role objects, where each object does a RelatedJoin() to the other. This results in a glue table that looks like this: CREATE TABLE user_role ( user_id INT NOT NULL, role_id INT NOT NULL ) The schema lacks any FOREIGN KEY constraints, and a PRIMARY KEY. It should probalby look more like this: CREATE TABLE user_role ( user_id INT NOT NULL, CONSTRAINT user_id_exists FOREIGN KEY (user_id) REFERENCES user (id), role_id INT NOT NULL, CONSTRAINT role_id_exists FOREIGN KEY (role_id) REFERENCES role (id), PRIMARY KEY (user_id, role_id) ) ON DELETE CASCADE may be needed as well. Note that I am using patch #1299109 to add FOREIGN KEY support for MySQL. However, looking at join.py, it does not seem to do anything with foreign keys, so I do not think this is a dependency on MySQL; I think this behavior should be reproducable on other databases. The intermediate table schema is created in dbconnection.DBAPI._SO_createJoinTableSQL(), and it calls self.joinSQLType(join) to get the SQL for the column. In all the implementations (except Sybase which is slightly different), it returns 'INT NOT NULL' The table creation order looks like it could be a problem, as the glue/intermediate table seems to be created before the second of the other two tables, which would produce referential integrity problems (i.e.reference to a non-existent table). ---------------------------------------------------------------------- Comment By: L33tminion (l33tminion) Date: 2006-08-25 14:25 Message: Logged In: YES user_id=1583993 At the very least, adding ON DELETE CASCADE, etc., to the join table should be an option. Working around that is _really_ annoying. I second adustman's comments. ---------------------------------------------------------------------- Comment By: nyenyec (nyenyec) Date: 2006-02-15 01:31 Message: Logged In: YES user_id=6142 This is still a problem in sqlobject 0.7.1dev-r1457 ---------------------------------------------------------------------- Comment By: Andy Dustman (adustman) Date: 2005-10-31 17:34 Message: Logged In: YES user_id=71372 BTW, the table creation order comment is really more of a problem for Turbogears. I've done a bit of testing by altering an existing glue table to use ON DELETE CASCADE and it seems to work as expected/desired. Without ON DELETE CASCADE, you have to delete the glue entry tables manually, (typically with obj.removeXXX(other_id)); otherwise your glue table has a bunch of dead entries, though if you have the FOREIGN KEY entry without ON CASCADE DELETE, then you can't remove the parent objects without first deleting the glue records. In other words, having FOREIGN KEY ... REFERENCES ... ON DELETE CASCADE keeps your glue table clean when you remove either object of the RelatedJoin(). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1305062&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-08-24 22:46:01
|
Bugs item #1546294, was opened at 2006-08-24 18:11 Message generated for change (Comment added) made by rick446 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1546294&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 Submitted By: Rick Copeland (rick446) Assigned to: Nobody/Anonymous (nobody) Summary: inheritance and cascade='null' do not work together Initial Comment: (Based on development version 0.8dev_r1883) Start with the following schema: class A(InheritableSQLObject): dummy=IntCol() class B(A): c=ForeignKey('C', cascade='null') class C(SQLObject): dummy=IntCol() C.createTable() A.createTable() B.createTable() c=C(dummy=1) b=B(cID=c.id, dummy=1) c.destroySelf() ***exception*** This can be fixed by updating SQLObject.destroySelf to use SQLBuilder by the following changes: in sqlobject/main.py: (insert at top) from sqlbuilder import OR (replacing line starting with "query.append("%s = (%... query.append(getattr(k.q, col.name)==self.id) (replacing line "' OR '.join(query)") query=OR(*query) ---------------------------------------------------------------------- >Comment By: Rick Copeland (rick446) Date: 2006-08-24 18:46 Message: Logged In: YES user_id=1583356 I have created patch #1546314 to address this bug. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1546294&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-08-24 22:44:32
|
Patches item #1546314, was opened at 2006-08-24 18:44 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1546314&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 Submitted By: Rick Copeland (rick446) Assigned to: Nobody/Anonymous (nobody) Summary: Fix bug 1546294 Initial Comment: Here is the patch that fixes bug 1546294. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1546314&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-08-24 22:11:45
|
Bugs item #1546294, was opened at 2006-08-24 18:11 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1546294&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 Submitted By: Rick Copeland (rick446) Assigned to: Nobody/Anonymous (nobody) Summary: inheritance and cascade='null' do not work together Initial Comment: (Based on development version 0.8dev_r1883) Start with the following schema: class A(InheritableSQLObject): dummy=IntCol() class B(A): c=ForeignKey('C', cascade='null') class C(SQLObject): dummy=IntCol() C.createTable() A.createTable() B.createTable() c=C(dummy=1) b=B(cID=c.id, dummy=1) c.destroySelf() ***exception*** This can be fixed by updating SQLObject.destroySelf to use SQLBuilder by the following changes: in sqlobject/main.py: (insert at top) from sqlbuilder import OR (replacing line starting with "query.append("%s = (%... query.append(getattr(k.q, col.name)==self.id) (replacing line "' OR '.join(query)") query=OR(*query) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1546294&group_id=74338 |
|
From: <sub...@co...> - 2006-08-24 15:41:38
|
Author: phd
Date: 2006-08-24 09:41:31 -0600 (Thu, 24 Aug 2006)
New Revision: 1885
Modified:
home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_aliases.py
Log:
Merged patches from the revisions 1881:1884 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py 2006-08-24 15:38:41 UTC (rev 1884)
+++ home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py 2006-08-24 15:41:31 UTC (rev 1885)
@@ -419,6 +419,8 @@
########################################
class AliasField(Field, SQLListMixin):
+ as_string = '' # set it to "AS" if your database requires it
+
def __init__(self, tableName, fieldName, alias):
Field.__init__(self, tableName, fieldName)
self.alias = alias
@@ -427,7 +429,7 @@
return self.alias + "." + self.fieldName
def tablesUsedImmediate(self):
- return ["%s AS %s" % (self.tableName, self.alias)]
+ return ["%s %s %s" % (self.tableName, self.as_string, self.alias)]
class AliasTable(Table):
FieldClass = AliasField
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_aliases.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_aliases.py 2006-08-24 15:38:41 UTC (rev 1884)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_aliases.py 2006-08-24 15:41:31 UTC (rev 1885)
@@ -15,7 +15,7 @@
alias = Alias(JoinAlias)
select = JoinAlias.select(JoinAlias.q.parent == alias.q.name)
assert str(select) == \
- "SELECT join_alias.id, join_alias.name, join_alias.parent FROM join_alias AS join_alias_alias1, join_alias WHERE ((join_alias.parent) = (join_alias_alias1.name))"
+ "SELECT join_alias.id, join_alias.name, join_alias.parent FROM join_alias join_alias_alias1, join_alias WHERE ((join_alias.parent) = (join_alias_alias1.name))"
def test_2perform_join():
setupClass(JoinAlias)
|
|
From: SourceForge.net <no...@so...> - 2006-08-24 15:38:54
|
Bugs item #1516394, was opened at 2006-07-03 18:56 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1516394&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: Firebird/Interbase Group: SQLObject release (specify) >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Henrik Weber (hweber) >Assigned to: Oleg Broytmann (phd) Summary: SQLbuilder aliases fail for Firebird Initial Comment: Creating a table alias with SQLBuilder will alway create alias clauses of the form: orig_table AS alias_name SQLbuilder does not discriminate between different SQL dialects here. For Firebird this syntax variant fails, because aliases are defined without the AS keyword there: orig_table alias_name The AS keyword will generate a syntax error with Firebird. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-08-24 19:38 Message: Logged In: YES user_id=4799 I found most database (I tested MySQL, PostgreSQL and SQLite) ignore that noisy "AS" so I just removed it from the queries for all backends. Committed in the revision 1883 to the trunk, rev. 1884 to the 0.7-branch. ---------------------------------------------------------------------- Comment By: Henrik Weber (hweber) Date: 2006-07-04 22:37 Message: Logged In: YES user_id=121229 Forgot to mention: this is with SQLobject 0.7.0 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1516394&group_id=74338 |
|
From: <sub...@co...> - 2006-08-24 15:38:49
|
Author: phd
Date: 2006-08-24 09:38:41 -0600 (Thu, 24 Aug 2006)
New Revision: 1884
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/sqlbuilder.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_aliases.py
Log:
Fixed the bug 1516394: SQLbuilder aliases fail for Firebird.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/sqlbuilder.py 2006-08-24 15:37:53 UTC (rev 1883)
+++ SQLObject/branches/0.7-bugfix/sqlobject/sqlbuilder.py 2006-08-24 15:38:41 UTC (rev 1884)
@@ -379,6 +379,8 @@
########################################
class AliasField(Field):
+ as_string = '' # set it to "AS" if your database requires it
+
def __init__(self, tableName, fieldName, alias):
Field.__init__(self, tableName, fieldName)
self.alias = alias
@@ -387,7 +389,7 @@
return self.alias + "." + self.fieldName
def tablesUsedImmediate(self):
- return ["%s AS %s" % (self.tableName, self.alias)]
+ return ["%s %s %s" % (self.tableName, self.as_string, self.alias)]
class AliasTable(Table):
FieldClass = AliasField
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_aliases.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_aliases.py 2006-08-24 15:37:53 UTC (rev 1883)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_aliases.py 2006-08-24 15:38:41 UTC (rev 1884)
@@ -15,7 +15,7 @@
alias = Alias(JoinAlias)
select = JoinAlias.select(JoinAlias.q.parent == alias.q.name)
assert str(select) == \
- "SELECT join_alias.id, join_alias.name, join_alias.parent FROM join_alias AS join_alias_alias1, join_alias WHERE ((join_alias.parent) = (join_alias_alias1.name))"
+ "SELECT join_alias.id, join_alias.name, join_alias.parent FROM join_alias join_alias_alias1, join_alias WHERE ((join_alias.parent) = (join_alias_alias1.name))"
def test_2perform_join():
setupClass(JoinAlias)
|
|
From: <sub...@co...> - 2006-08-24 15:37:58
|
Author: phd
Date: 2006-08-24 09:37:53 -0600 (Thu, 24 Aug 2006)
New Revision: 1883
Modified:
SQLObject/trunk/sqlobject/sqlbuilder.py
SQLObject/trunk/sqlobject/tests/test_aliases.py
Log:
In the course of fixing the bug 1516394: SQLbuilder aliases fail for Firebird
I found most database (I tested MySQL, PostgreSQL and SQLite) ignore
that noisy "AS" so I just removed it from the queries.
Modified: SQLObject/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2006-08-24 14:38:27 UTC (rev 1882)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2006-08-24 15:37:53 UTC (rev 1883)
@@ -382,6 +382,8 @@
########################################
class AliasField(Field):
+ as_string = '' # set it to "AS" if your database requires it
+
def __init__(self, tableName, fieldName, alias):
Field.__init__(self, tableName, fieldName)
self.alias = alias
@@ -390,7 +392,7 @@
return self.alias + "." + self.fieldName
def tablesUsedImmediate(self):
- return ["%s AS %s" % (self.tableName, self.alias)]
+ return ["%s %s %s" % (self.tableName, self.as_string, self.alias)]
class AliasTable(Table):
FieldClass = AliasField
Modified: SQLObject/trunk/sqlobject/tests/test_aliases.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_aliases.py 2006-08-24 14:38:27 UTC (rev 1882)
+++ SQLObject/trunk/sqlobject/tests/test_aliases.py 2006-08-24 15:37:53 UTC (rev 1883)
@@ -15,7 +15,7 @@
alias = Alias(JoinAlias)
select = JoinAlias.select(JoinAlias.q.parent == alias.q.name)
assert str(select) == \
- "SELECT join_alias.id, join_alias.name, join_alias.parent FROM join_alias AS join_alias_alias1, join_alias WHERE ((join_alias.parent) = (join_alias_alias1.name))"
+ "SELECT join_alias.id, join_alias.name, join_alias.parent FROM join_alias join_alias_alias1, join_alias WHERE ((join_alias.parent) = (join_alias_alias1.name))"
def test_2perform_join():
setupClass(JoinAlias)
|
|
From: <sub...@co...> - 2006-08-22 15:04:47
|
Author: phd
Date: 2006-08-22 09:04:33 -0600 (Tue, 22 Aug 2006)
New Revision: 1881
Modified:
home/phd/SQLObject/paramstyles/sqlobject/firebird/firebirdconnection.py
home/phd/SQLObject/paramstyles/sqlobject/index.py
home/phd/SQLObject/paramstyles/sqlobject/main.py
home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py
home/phd/SQLObject/paramstyles/sqlobject/postgres/pgconnection.py
Log:
Merged patches from the revisions 1868:1880 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/firebird/firebirdconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/firebird/firebirdconnection.py 2006-08-22 14:59:53 UTC (rev 1880)
+++ home/phd/SQLObject/paramstyles/sqlobject/firebird/firebirdconnection.py 2006-08-22 15:04:33 UTC (rev 1881)
@@ -90,8 +90,8 @@
for each table this method to work."""
table = soInstance.sqlmeta.table
idName = soInstance.sqlmeta.idName
- sequenceName = getattr(soInstance, '_idSequence',
- 'GEN_%s' % table)
+ sequenceName = soInstance.sqlmeta.idSequence or \
+ 'GEN_%s' % table
c = conn.cursor()
if id is None:
c.execute('SELECT gen_id(%s,1) FROM rdb$database'
Modified: home/phd/SQLObject/paramstyles/sqlobject/index.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/index.py 2006-08-22 14:59:53 UTC (rev 1880)
+++ home/phd/SQLObject/paramstyles/sqlobject/index.py 2006-08-22 15:04:33 UTC (rev 1881)
@@ -156,7 +156,7 @@
self.kw['name'] = value
def _get_name(self):
- return kw['name']
+ return self.kw['name']
def _set_name(self, value):
self.setName(value)
Modified: home/phd/SQLObject/paramstyles/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/main.py 2006-08-22 14:59:53 UTC (rev 1880)
+++ home/phd/SQLObject/paramstyles/sqlobject/main.py 2006-08-22 15:04:33 UTC (rev 1881)
@@ -180,6 +180,7 @@
table = None
idName = None
+ idSequence = None
# This function is used to coerce IDs into the proper format,
# so you should replace it with str, or another function, if you
# aren't using integer IDs
@@ -879,7 +880,7 @@
"""
for attr in ['_table', '_lazyUpdate', '_style', '_idName',
'_defaultOrder', '_cacheValues', '_registry',
- '_idType', '_fromDatabase']:
+ '_idType', '_fromDatabase', '_idSequence']:
if new_attrs.has_key(attr):
new_name = attr[1:]
deprecated("%r is deprecated; please set the %r "
@@ -1414,7 +1415,7 @@
# This join has requested not to be created
continue
sql.append(conn._SO_createJoinTableSQL(join))
- return '\n'.join(sql)
+ return ';\n'.join(sql)
createJoinTablesSQL = classmethod(createJoinTablesSQL)
def createIndexes(cls, ifNotExists=False, connection=None):
@@ -1432,7 +1433,7 @@
if not index:
continue
sql.append(conn.createIndexSQL(cls, index))
- return '\n'.join(sql)
+ return ';\n'.join(sql)
createIndexesSQL = classmethod(createIndexesSQL)
def _getJoinsToCreate(cls):
Modified: home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py 2006-08-22 14:59:53 UTC (rev 1880)
+++ home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py 2006-08-22 15:04:33 UTC (rev 1881)
@@ -33,7 +33,7 @@
"read_default_file", "read_default_group", "charset"):
if key in kw:
self.kw[key] = col.popKey(kw, key)
- for key in ("connect_time", "compress", "named_pipe", "use_unicode",
+ for key in ("connect_timeout", "compress", "named_pipe", "use_unicode",
"client_flag", "local_infile"):
if key in kw:
self.kw[key] = int(col.popKey(kw, key))
Modified: home/phd/SQLObject/paramstyles/sqlobject/postgres/pgconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/postgres/pgconnection.py 2006-08-22 14:59:53 UTC (rev 1880)
+++ home/phd/SQLObject/paramstyles/sqlobject/postgres/pgconnection.py 2006-08-22 15:04:33 UTC (rev 1881)
@@ -119,8 +119,8 @@
def _queryInsertID(self, conn, soInstance, id, names, values):
table = soInstance.sqlmeta.table
idName = soInstance.sqlmeta.idName
- sequenceName = getattr(soInstance, '_idSequence',
- '%s_%s_seq' % (table, idName))
+ sequenceName = soInstance.sqlmeta.idSequence or \
+ '%s_%s_seq' % (table, idName)
c = conn.cursor()
if id is None:
c.execute("SELECT NEXTVAL('%s')" % sequenceName)
|
|
From: SourceForge.net <no...@so...> - 2006-08-22 15:03:48
|
Bugs item #1541095, was opened at 2006-08-16 11:19 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1541095&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: Postgres Group: SQLObject release (specify) >Status: Closed >Resolution: Wont Fix Priority: 5 Submitted By: Michel Albert (exhuma) >Assigned to: Oleg Broytmann (phd) Summary: Capital letters in table/column names Initial Comment: Postgre requires table names, column names and so on to be enclosed in double quotes if they contain capital letters. Otherwise it assumes that they are all lower-case. In order to be more DBMS-agnostic, SQLObject should deal with that. It is possible to do something like: lastName = StringCol(dbName='"lastName"') It would be nicer to be able to do this: lastName = StringCol(dbName='lastName') The current solution is error-prone. Also, when doing this, it get's a bit confusing as you have to leave out the quotes when doing joins: wrong: address = SingleJoin('"Address"') correct: address = SingleJoin('Address') as the joins relate to Python objects, not directly to tables. I have to deal with this, as I am migrating a web- application from PHP to Python, and the database already exists and modifying it is not an option. Best regards, Michel Albert ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-08-22 19:03 Message: Logged In: YES user_id=4799 Use sqlmeta.idSequence to name your sequence. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2006-08-16 20:45 Message: Logged In: NO This issue actually *breaks* postgres!: --- In postgres: ----------------------------------- database=> SELECT NEXTVAL('"Hotel_idHotel_seq"'); nextval --------- 1 (1 row) ---------------------------------------------------- --- Using SQLObject -------------------------------- >>> x = Hotel(name="foo", address=None, owner=None, establishment=None) Traceback (most recent call last): File "<console>", line 1, in ? File "/usr/lib/python2.4/site-packages/SQLObject- 0.7.1dev_r1675-py2.4.egg/sqlobject/declarative.py", line 92, in _wrapper return_value = fn(self, *args, **kwargs) File "/usr/lib/python2.4/site-packages/SQLObject- 0.7.1dev_r1675-py2.4.egg/sqlobject/main.py", line 1197, in __init__ self._create(id, **kw) File "/usr/lib/python2.4/site-packages/SQLObject- 0.7.1dev_r1675-py2.4.egg/sqlobject/main.py", line 1224, in _create self._SO_finishCreate(id) File "/usr/lib/python2.4/site-packages/SQLObject- 0.7.1dev_r1675-py2.4.egg/sqlobject/main.py", line 1248, in _SO_finishCreate id, names, values) File "/usr/lib/python2.4/site-packages/SQLObject- 0.7.1dev_r1675-py2.4.egg/sqlobject/dbconnection.py", line 759, in queryInsertID return self._dbConnection._queryInsertID( File "/usr/lib/python2.4/site-packages/SQLObject- 0.7.1dev_r1675-py2.4.egg/sqlobject/postgres/ pgconnection.py", line 126, in _queryInsertID c.execute("SELECT NEXTVAL('%s')" % sequenceName) ProgrammingError: ERROR: invalid name syntax SELECT NEXTVAL('"Hotel"_"idHotel"_seq') ---------------------------------------------------- ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1541095&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-08-22 15:01:05
|
Bugs item #1539087, was opened at 2006-08-12 10:31 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1539087&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: [N/A] (ymasuda) Assigned to: Nobody/Anonymous (nobody) Summary: Link to Japanese translation has moved Initial Comment: Hello, I have moved Japanese translation of SQLObject main doc from http://www.python.jp/~ymasuda/sqlobject/SQLObject.html which is listed on http://sqlobject.org/links.html, to http://ymasuda.jp/python/ sqlobject/doc_0.7/SQLObject.html . Also I'm going underway to translate all doc entries. These will be available at http://ymasuda.jp/python/sqlobject/doc_0.7/ . If you have any questions or advices, please tell me. Thanks ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-08-22 19:01 Message: Logged In: YES user_id=4799 I have fixed this in the trunk. Don't know when Ian will update links.html. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1539087&group_id=74338 |
|
From: <sub...@co...> - 2006-08-22 15:00:13
|
Author: phd Date: 2006-08-22 08:59:53 -0600 (Tue, 22 Aug 2006) New Revision: 1880 Modified: SQLObject/docs/links.txt Log: Fixed the bug 1539087: Link to Japanese translation has moved. Modified: SQLObject/docs/links.txt =================================================================== --- SQLObject/docs/links.txt 2006-08-22 14:53:23 UTC (rev 1879) +++ SQLObject/docs/links.txt 2006-08-22 14:59:53 UTC (rev 1880) @@ -28,7 +28,7 @@ <http://formencode.org>`_. * `Translation of SQLObject documentation to Japanese - <http://www.python.jp/~ymasuda/sqlobject/SQLObject.html>`_. + <http://ymasuda.jp/python/sqlobject/doc_0.7/>`_. * `How to Use Database Agnostic SQL in SQLObject <http://groovie.org/articles/2005/11/01/how-to-use-database-agnostic-sql-in-sqlobject>`_. |