sqlobject-cvs Mailing List for SQLObject (Page 98)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
(9) |
Apr
(74) |
May
(29) |
Jun
(16) |
Jul
(28) |
Aug
(10) |
Sep
(57) |
Oct
(9) |
Nov
(29) |
Dec
(12) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(7) |
Feb
(14) |
Mar
(6) |
Apr
(3) |
May
(12) |
Jun
(34) |
Jul
(9) |
Aug
(29) |
Sep
(22) |
Oct
(2) |
Nov
(15) |
Dec
(52) |
| 2005 |
Jan
(47) |
Feb
(78) |
Mar
(14) |
Apr
(35) |
May
(33) |
Jun
(16) |
Jul
(26) |
Aug
(63) |
Sep
(40) |
Oct
(96) |
Nov
(96) |
Dec
(123) |
| 2006 |
Jan
(159) |
Feb
(144) |
Mar
(64) |
Apr
(31) |
May
(88) |
Jun
(48) |
Jul
(16) |
Aug
(64) |
Sep
(87) |
Oct
(92) |
Nov
(56) |
Dec
(76) |
| 2007 |
Jan
(94) |
Feb
(103) |
Mar
(126) |
Apr
(123) |
May
(85) |
Jun
(11) |
Jul
(130) |
Aug
(47) |
Sep
(65) |
Oct
(70) |
Nov
(12) |
Dec
(11) |
| 2008 |
Jan
(30) |
Feb
(55) |
Mar
(88) |
Apr
(20) |
May
(50) |
Jun
|
Jul
(38) |
Aug
(1) |
Sep
(9) |
Oct
(5) |
Nov
(6) |
Dec
(39) |
| 2009 |
Jan
(8) |
Feb
(16) |
Mar
(3) |
Apr
(33) |
May
(44) |
Jun
(1) |
Jul
(10) |
Aug
(33) |
Sep
(74) |
Oct
(22) |
Nov
|
Dec
(15) |
| 2010 |
Jan
(28) |
Feb
(22) |
Mar
(46) |
Apr
(29) |
May
(1) |
Jun
(1) |
Jul
(27) |
Aug
(8) |
Sep
(5) |
Oct
(33) |
Nov
(24) |
Dec
(41) |
| 2011 |
Jan
(4) |
Feb
(12) |
Mar
(35) |
Apr
(29) |
May
(19) |
Jun
(16) |
Jul
(32) |
Aug
(25) |
Sep
(5) |
Oct
(11) |
Nov
(21) |
Dec
(12) |
| 2012 |
Jan
(3) |
Feb
(4) |
Mar
(20) |
Apr
(4) |
May
(25) |
Jun
(13) |
Jul
|
Aug
|
Sep
(2) |
Oct
(25) |
Nov
(9) |
Dec
(1) |
| 2013 |
Jan
(6) |
Feb
(8) |
Mar
|
Apr
(10) |
May
(31) |
Jun
(7) |
Jul
(18) |
Aug
(33) |
Sep
(4) |
Oct
(16) |
Nov
|
Dec
(27) |
| 2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(11) |
May
(39) |
Jun
(8) |
Jul
(11) |
Aug
(4) |
Sep
|
Oct
(27) |
Nov
|
Dec
(71) |
| 2015 |
Jan
(17) |
Feb
(47) |
Mar
(33) |
Apr
|
May
|
Jun
(9) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
| 2016 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
(12) |
Jun
(7) |
Jul
(9) |
Aug
(31) |
Sep
(8) |
Oct
(3) |
Nov
(15) |
Dec
(1) |
| 2017 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(8) |
May
(10) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(4) |
Dec
(5) |
| 2018 |
Jan
(2) |
Feb
(8) |
Mar
|
Apr
(4) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
(1) |
Feb
(16) |
Mar
(1) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
| 2021 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
(1) |
Dec
(4) |
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
|
| 2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
| 2025 |
Jan
|
Feb
(4) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
|
From: <sub...@co...> - 2007-03-28 16:21:56
|
Author: phd
Date: 2007-03-28 10:21:54 -0600 (Wed, 28 Mar 2007)
New Revision: 2466
Modified:
SQLObject/branches/sqlbuilder-views/sqlobject/dbconnection.py
SQLObject/branches/sqlbuilder-views/sqlobject/inheritance/__init__.py
SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py
SQLObject/branches/sqlbuilder-views/sqlobject/sresults.py
Log:
Removed trailing spaces.
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/dbconnection.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/dbconnection.py 2007-03-28 16:20:42 UTC (rev 2465)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/dbconnection.py 2007-03-28 16:21:54 UTC (rev 2466)
@@ -435,7 +435,7 @@
if isinstance(tableCreateSQLs, tuple):
tableCreateSQLs = list(tableCreateSQLs)
assert isinstance(tableCreateSQLs,list), (
- 'Unable to create a list from %s.sqlmeta.createSQL' %
+ 'Unable to create a list from %s.sqlmeta.createSQL' %
(soClass.__name__))
return tableCreateSQLs or []
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/inheritance/__init__.py 2007-03-28 16:20:42 UTC (rev 2465)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/inheritance/__init__.py 2007-03-28 16:21:54 UTC (rev 2466)
@@ -32,9 +32,9 @@
inheritedTables=None, **ops):
if clause is None or isinstance(clause, str) and clause == 'all':
clause = sqlbuilder.SQLTrueClause
-
+
dbName = (ops.get('connection',None) or sourceClass._connection).dbName
-
+
tablesDict = tablesUsedDict(clause, dbName)
tablesDict[sourceClass.sqlmeta.table] = 1
orderBy = ops.get('orderBy')
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py 2007-03-28 16:20:42 UTC (rev 2465)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py 2007-03-28 16:21:54 UTC (rev 2466)
@@ -79,7 +79,7 @@
safeSQLRE = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_\.]*$')
def sqlIdentifier(obj):
- # some db drivers return unicode column names
+ # some db drivers return unicode column names
return isinstance(obj, types.StringTypes) and bool(safeSQLRE.search(obj.strip()))
@@ -418,7 +418,7 @@
if isinstance(fieldName, SQLExpression):
fieldName = sqlrepr(fieldName, db)
return self.alias + "." + fieldName
-
+
def tablesUsedImmediate(self):
return [self.aliasTable]
@@ -456,7 +456,7 @@
if self.table:
attr = getattr(self.table.q, attr).fieldName
return self.FieldClass(self.tableName, attr, self.alias, self)
-
+
def __sqlrepr__(self, db):
return "%s %s %s" % (sqlrepr(self.tableName, db), self.as_string, self.alias)
@@ -485,7 +485,7 @@
t = SQLConstant(t.sqlmeta.table)
tabs.append(t)
self.tables = tabs
-
+
def __sqlrepr__(self, db):
return " UNION ".join([str(sqlrepr(t, db)) for t in self.tables])
@@ -521,7 +521,7 @@
self.ops['reversed'] = reversed
self.ops['forUpdate'] = forUpdate
self.ops['staticTables'] = staticTables
-
+
def clone(self, **newOps):
ops = self.ops.copy()
ops.update(newOps)
@@ -558,7 +558,7 @@
clause = self.ops['clause']
if isinstance(clause, (str, unicode)):
clause = SQLConstant('(%s)' % clause)
-
+
if clause == SQLTrueClause:
newClause = filter_clause
else:
@@ -566,7 +566,7 @@
return self.newClause(newClause)
def __sqlrepr__(self, db):
-
+
select = "SELECT"
if self.ops['distinct']:
select += " DISTINCT"
@@ -1182,7 +1182,7 @@
def __init__(self, proxy, attr):
self.attr = attr
self.proxy = proxy
-
+
def __sqlrepr__(self, db):
if self.proxy.soClass is None:
return '_DELAYED_' + self.attr
@@ -1193,13 +1193,13 @@
def tablesUsedImmediate(self):
return getattr(self._resolve(), 'tablesUsedImmediate', lambda: [])()
-
+
def components(self):
return getattr(self._resolve(), 'components', lambda: [])()
def _resolve(self):
return getattr(self.proxy, self.attr)
-
+
# For AliasTable etc
def fieldName(self):
class _aliasFieldName(SQLExpression):
@@ -1212,7 +1212,7 @@
class _DelayClass(_Delay):
def _resolve(self):
- return self.proxy.soClass.sqlmeta.table
+ return self.proxy.soClass.sqlmeta.table
class _Delay_proxy(object):
def __init__(self, **kw):
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/sresults.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/sresults.py 2007-03-28 16:20:42 UTC (rev 2465)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/sresults.py 2007-03-28 16:21:54 UTC (rev 2466)
@@ -27,7 +27,7 @@
self.ops['dbOrderBy'] = orderBy
if ops.has_key('connection') and ops['connection'] is None:
del ops['connection']
-
+
tablesDict = sqlbuilder.tablesUsedDict(self.clause, self._getConnection().dbName)
if clauseTables:
for table in clauseTables:
@@ -292,7 +292,7 @@
def _throughTo(self, attr):
otherClass = None
orderBy = sqlbuilder.NoDefault
-
+
ref = self.sourceClass.sqlmeta.columns.get(attr.endswith('ID') and attr or attr+'ID', None)
if ref and ref.foreignKey:
otherClass, clause = self._throughToFK(ref)
@@ -305,27 +305,27 @@
otherClass, clause = self._throughToRelatedJoin(join)
else:
otherClass, clause = self._throughToMultipleJoin(join)
-
+
if not otherClass:
raise AttributeError("throughTo argument (got %s) should be name of foreignKey or SQL*Join in %s" % (attr, self.sourceClass))
-
+
return otherClass.select(clause,
distinct=True,
orderBy=orderBy,
connection=self._getConnection())
-
+
def _throughToFK(self, col):
otherClass = getattr(self.sourceClass, "_SO_class_"+col.foreignKey)
query = sqlbuilder.Alias(self.queryForSelect(), "%s_%s" % (self.sourceClass.__name__, col.name))
return otherClass, otherClass.q.id==getattr(query.q, getattr(self.sourceClass.q, col.name).fieldName)
-
+
def _throughToMultipleJoin(self, join):
otherClass = join.otherClass
query = self.queryForSelect()
query = sqlbuilder.Alias(query, "%s_%s" % (self.sourceClass.__name__, join.joinMethodName))
joinColumn = getattr(otherClass.q, join.soClass.sqlmeta.style.dbColumnToPythonAttr(join.joinColumn))
return otherClass, joinColumn==getattr(query.q, self.sourceClass.q.id.fieldName)
-
+
def _throughToRelatedJoin(self, join):
otherClass = join.otherClass
intTable = sqlbuilder.Table(join.intermediateTable)
@@ -335,5 +335,4 @@
getattr(intTable, join.joinColumn) == getattr(query.q, join.joinColumn))
return otherClass, clause
-
__all__ = ['SelectResults']
|
|
From: <sub...@co...> - 2007-03-28 16:20:45
|
Author: phd
Date: 2007-03-28 10:20:42 -0600 (Wed, 28 Mar 2007)
New Revision: 2465
Modified:
SQLObject/branches/sqlbuilder-sresults/sqlobject/inheritance/__init__.py
SQLObject/branches/sqlbuilder-sresults/sqlobject/joins.py
SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py
SQLObject/branches/sqlbuilder-sresults/sqlobject/sresults.py
Log:
Removed trailing spaces.
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/inheritance/__init__.py 2007-03-28 14:22:33 UTC (rev 2464)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/inheritance/__init__.py 2007-03-28 16:20:42 UTC (rev 2465)
@@ -32,9 +32,9 @@
inheritedTables=None, **ops):
if clause is None or isinstance(clause, str) and clause == 'all':
clause = sqlbuilder.SQLTrueClause
-
+
dbName = (ops.get('connection',None) or sourceClass._connection).dbName
-
+
tablesDict = tablesUsedDict(clause, dbName)
tablesDict[str(sourceClass.sqlmeta.table)] = 1
orderBy = ops.get('orderBy')
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/joins.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/joins.py 2007-03-28 14:22:33 UTC (rev 2464)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/joins.py 2007-03-28 16:20:42 UTC (rev 2465)
@@ -252,7 +252,7 @@
def tablesUsedImmediate(self):
return [self.table, self.interTable]
-
+
def __sqlrepr__(self, db):
return '%s.%s = %s.%s' % (self.interTable, self.joinColumn, self.table, self.idName)
@@ -272,7 +272,7 @@
def performJoin(self, inst):
results = self.otherClass.select(sqlbuilder.AND(
OtherTableToJoin(
- self.otherClass.sqlmeta.table, self.otherClass.sqlmeta.idName,
+ self.otherClass.sqlmeta.table, self.otherClass.sqlmeta.idName,
self.intermediateTable, self.otherColumn
),
JoinToTable(
@@ -382,7 +382,7 @@
& (sqlbuilder.Field(self.intermediateTable, self.joinColumn)
== obj.id))
select = self.otherClass.select(query)
- return _ManyToManySelectWrapper(obj, self, select)
+ return _ManyToManySelectWrapper(obj, self, select)
def event_CreateTableSignal(self, soClass, connection, extra_sql,
post_funcs):
@@ -406,14 +406,14 @@
joinColumn = None
otherColumn = None
createJoinTable = True
-
+
class _ManyToManySelectWrapper(object):
def __init__(self, forObject, join, select):
self.forObject = forObject
self.join = join
self.select = select
-
+
def __getattr__(self, attr):
# @@: This passes through private variable access too... should it?
# Also magic methods, like __str__
@@ -451,7 +451,7 @@
obj = self.join.otherClass(**kw)
self.add(obj)
return obj
-
+
class SOOneToMany(object):
def __init__(self, soClass, name, join, joinColumn, **attrs):
@@ -497,7 +497,7 @@
self.forObject = forObject
self.join = join
self.select = select
-
+
def __getattr__(self, attr):
# @@: This passes through private variable access too... should it?
# Also magic methods, like __str__
@@ -518,4 +518,3 @@
def create(self, **kw):
kw[self.join.joinColumn] = self.forObject.id
return self.join.otherClass(**kw)
-
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py 2007-03-28 14:22:33 UTC (rev 2464)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py 2007-03-28 16:20:42 UTC (rev 2465)
@@ -79,7 +79,7 @@
safeSQLRE = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_\.]*$')
def sqlIdentifier(obj):
- # some db drivers return unicode column names
+ # some db drivers return unicode column names
return isinstance(obj, types.StringTypes) and bool(safeSQLRE.search(obj.strip()))
@@ -422,7 +422,7 @@
if isinstance(fieldName, SQLExpression):
fieldName = sqlrepr(fieldName, db)
return self.alias + "." + fieldName
-
+
def tablesUsedImmediate(self):
return [self.aliasTable]
@@ -460,7 +460,7 @@
if self.table:
attr = getattr(self.table.q, attr).fieldName
return self.FieldClass(self.tableName, attr, self.alias, self)
-
+
def __sqlrepr__(self, db):
return "%s %s %s" % (sqlrepr(self.tableName, db), self.as_string, self.alias)
@@ -489,7 +489,7 @@
t = SQLConstant(t.sqlmeta.table)
tabs.append(t)
self.tables = tabs
-
+
def __sqlrepr__(self, db):
return " UNION ".join([str(sqlrepr(t, db)) for t in self.tables])
@@ -525,7 +525,7 @@
self.ops['reversed'] = reversed
self.ops['forUpdate'] = forUpdate
self.ops['staticTables'] = staticTables
-
+
def clone(self, **newOps):
ops = self.ops.copy()
ops.update(newOps)
@@ -562,7 +562,7 @@
clause = self.ops['clause']
if isinstance(clause, (str, unicode)):
clause = SQLConstant('(%s)' % clause)
-
+
if clause == SQLTrueClause:
newClause = filter_clause
else:
@@ -570,7 +570,7 @@
return self.newClause(newClause)
def __sqlrepr__(self, db):
-
+
select = "SELECT"
if self.ops['distinct']:
select += " DISTINCT"
@@ -1188,7 +1188,7 @@
def __init__(self, proxy, attr):
self.attr = attr
self.proxy = proxy
-
+
def __sqlrepr__(self, db):
if self.proxy.soClass is None:
return '_DELAYED_' + self.attr
@@ -1199,13 +1199,13 @@
def tablesUsedImmediate(self):
return getattr(self._resolve(), 'tablesUsedImmediate', lambda: [])()
-
+
def components(self):
return getattr(self._resolve(), 'components', lambda: [])()
def _resolve(self):
return getattr(self.proxy, self.attr)
-
+
# For AliasTable etc
def fieldName(self):
class _aliasFieldName(SQLExpression):
@@ -1218,7 +1218,7 @@
class _DelayClass(_Delay):
def _resolve(self):
- return self.proxy.soClass.sqlmeta.table
+ return self.proxy.soClass.sqlmeta.table
class _Delay_proxy(object):
def __init__(self, **kw):
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/sresults.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/sresults.py 2007-03-28 14:22:33 UTC (rev 2464)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/sresults.py 2007-03-28 16:20:42 UTC (rev 2465)
@@ -27,7 +27,7 @@
self.ops['dbOrderBy'] = orderBy
if ops.has_key('connection') and ops['connection'] is None:
del ops['connection']
-
+
tablesDict = sqlbuilder.tablesUsedDict(self.clause, self._getConnection().dbName)
if clauseTables:
for table in clauseTables:
@@ -292,7 +292,7 @@
def _throughTo(self, attr):
otherClass = None
orderBy = sqlbuilder.NoDefault
-
+
ref = self.sourceClass.sqlmeta.columns.get(attr.endswith('ID') and attr or attr+'ID', None)
if ref and ref.foreignKey:
otherClass, clause = self._throughToFK(ref)
@@ -305,27 +305,27 @@
otherClass, clause = self._throughToRelatedJoin(join)
else:
otherClass, clause = self._throughToMultipleJoin(join)
-
+
if not otherClass:
raise AttributeError("throughTo argument (got %s) should be name of foreignKey or SQL*Join in %s" % (attr, self.sourceClass))
-
+
return otherClass.select(clause,
distinct=True,
orderBy=orderBy,
connection=self._getConnection())
-
+
def _throughToFK(self, col):
otherClass = getattr(self.sourceClass, "_SO_class_"+col.foreignKey)
query = sqlbuilder.Alias(self.queryForSelect(), "%s_%s" % (self.sourceClass.__name__, col.name))
return otherClass, otherClass.q.id==getattr(query.q, getattr(self.sourceClass.q, col.name).fieldName)
-
+
def _throughToMultipleJoin(self, join):
otherClass = join.otherClass
query = self.queryForSelect()
query = sqlbuilder.Alias(query, "%s_%s" % (self.sourceClass.__name__, join.joinMethodName))
joinColumn = getattr(otherClass.q, join.soClass.sqlmeta.style.dbColumnToPythonAttr(join.joinColumn))
return otherClass, joinColumn==getattr(query.q, self.sourceClass.q.id.fieldName)
-
+
def _throughToRelatedJoin(self, join):
otherClass = join.otherClass
intTable = sqlbuilder.Table(join.intermediateTable)
@@ -335,5 +335,4 @@
getattr(intTable, join.joinColumn) == getattr(query.q, join.joinColumn))
return otherClass, clause
-
__all__ = ['SelectResults']
|
|
From: <sub...@co...> - 2007-03-28 14:22:37
|
Author: luke
Date: 2007-03-28 08:22:33 -0600 (Wed, 28 Mar 2007)
New Revision: 2464
Modified:
SQLObject/branches/sqlbuilder-views/sqlobject/converters.py
SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py
SQLObject/branches/sqlbuilder-views/sqlobject/sresults.py
SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_select_through.py
Log:
Merge cleaned up sqlbuilder-sresults branch changes (r2459:2462)
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/converters.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/converters.py 2007-03-28 14:08:17 UTC (rev 2463)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/converters.py 2007-03-28 14:22:33 UTC (rev 2464)
@@ -227,7 +227,6 @@
registerConverter(Decimal, DecimalConverter)
def sqlrepr(obj, db=None):
- import sqlbuilder
try:
reprFunc = obj.__sqlrepr__
except AttributeError:
@@ -237,20 +236,4 @@
(type(obj), repr(obj))
return converter(obj, db)
else:
- doCache = hasattr(db, 'doSQLReprCache')
- ret = None
- if doCache:
- cache = getattr(obj, '_sqlreprCache', {})
- if not isinstance(cache, dict):
- #Alias etc
- cache = {}
- ret = cache.get(db, None)
- if ret is None:
- ret = reprFunc(db)
- if doCache:
- try:
- cache[db] = ret
- obj._sqlreprCache = cache
- except TypeError:
- pass
- return ret
+ return reprFunc(db)
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py 2007-03-28 14:08:17 UTC (rev 2463)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/sqlbuilder.py 2007-03-28 14:22:33 UTC (rev 2464)
@@ -77,8 +77,6 @@
from converters import sqlrepr, registerConverter, TRUE, FALSE
-default_sqlrepr_db = None
-
safeSQLRE = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_\.]*$')
def sqlIdentifier(obj):
# some db drivers return unicode column names
@@ -188,28 +186,13 @@
def tablesUsed(self, db):
return self.tablesUsedDict(db).keys()
def tablesUsedDict(self, db):
- doCache = hasattr(db, 'doTablesUsedCache')
- tables = None
- if doCache:
- cache = getattr(self, '_tablesUsedCache', {})
- if not isinstance(cache, dict):
- #Alias etc
- cache = {}
- tables = cache.get(db, None)
- if tables is None:
- tables = {}
- for table in self.tablesUsedImmediate():
- if hasattr(table, '__sqlrepr__'):
- table = sqlrepr(table, db)
- tables[table] = 1
- for component in self.components():
- tables.update(tablesUsedDict(component, db))
- if doCache:
- try:
- cache[db] = tables
- self._tablesUsedCache = cache
- except TypeError:
- pass
+ tables = {}
+ for table in self.tablesUsedImmediate():
+ if hasattr(table, '__sqlrepr__'):
+ table = sqlrepr(table, db)
+ tables[table] = 1
+ for component in self.components():
+ tables.update(tablesUsedDict(component, db))
return tables
def tablesUsedImmediate(self):
return []
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/sresults.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/sresults.py 2007-03-28 14:08:17 UTC (rev 2463)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/sresults.py 2007-03-28 14:22:33 UTC (rev 2464)
@@ -281,61 +281,59 @@
return results[0]
def throughTo(self):
+ class _throughTo_getter(object):
+ def __init__(self, inst):
+ self.sresult = inst
+ def __getattr__(self, attr):
+ return self.sresult._throughTo(attr)
return _throughTo_getter(self)
throughTo = property(throughTo)
def _throughTo(self, attr):
+ otherClass = None
+ orderBy = sqlbuilder.NoDefault
+
ref = self.sourceClass.sqlmeta.columns.get(attr.endswith('ID') and attr or attr+'ID', None)
if ref and ref.foreignKey:
- return self._throughToFK(ref)
+ otherClass, clause = self._throughToFK(ref)
else:
join = [x for x in self.sourceClass.sqlmeta.joins if x.joinMethodName==attr]
if join:
join = join[0]
+ orderBy = join.orderBy
if hasattr(join, 'otherColumn'):
- return self._throughToRelatedJoin(join)
- return self._throughToMultipleJoin(join)
+ otherClass, clause = self._throughToRelatedJoin(join)
+ else:
+ otherClass, clause = self._throughToMultipleJoin(join)
- raise AttributeError("throughTo argument (got %s) should be name of foreignKey or SQL*Join in %s" % (attr, self.sourceClass))
+ if not otherClass:
+ raise AttributeError("throughTo argument (got %s) should be name of foreignKey or SQL*Join in %s" % (attr, self.sourceClass))
+ return otherClass.select(clause,
+ distinct=True,
+ orderBy=orderBy,
+ connection=self._getConnection())
+
def _throughToFK(self, col):
otherClass = getattr(self.sourceClass, "_SO_class_"+col.foreignKey)
query = sqlbuilder.Alias(self.queryForSelect(), "%s_%s" % (self.sourceClass.__name__, col.name))
- return otherClass.select(otherClass.q.id==getattr(query.q, getattr(self.sourceClass.q, col.name).fieldName),
- distinct=True,
- connection=self._getConnection())
+ return otherClass, otherClass.q.id==getattr(query.q, getattr(self.sourceClass.q, col.name).fieldName)
def _throughToMultipleJoin(self, join):
otherClass = join.otherClass
query = self.queryForSelect()
query = sqlbuilder.Alias(query, "%s_%s" % (self.sourceClass.__name__, join.joinMethodName))
joinColumn = getattr(otherClass.q, join.soClass.sqlmeta.style.dbColumnToPythonAttr(join.joinColumn))
- return otherClass.select(joinColumn == getattr(query.q, self.sourceClass.q.id.fieldName),
- distinct=True,
- orderBy=join.orderBy,
- connection=self._getConnection())
+ return otherClass, joinColumn==getattr(query.q, self.sourceClass.q.id.fieldName)
def _throughToRelatedJoin(self, join):
otherClass = join.otherClass
intTable = sqlbuilder.Table(join.intermediateTable)
- print join.joinColumn, join.otherColumn
query = self.queryForSelect().newItems([getattr(intTable, join.joinColumn)])
query = sqlbuilder.Alias(query, "%s_%s" % (self.sourceClass.__name__, join.joinMethodName))
- print query
clause = sqlbuilder.AND(otherClass.q.id == getattr(intTable, join.otherColumn),
getattr(intTable, join.joinColumn) == getattr(query.q, join.joinColumn))
- ret = otherClass.select(clause,
- distinct=True,
- orderBy=join.orderBy,
- connection=self._getConnection())
- print ret
- return ret
+ return otherClass, clause
-class _throughTo_getter(object):
- def __init__(self, inst):
- self.sresult = inst
- def __getattr__(self, attr):
- return self.sresult._throughTo(attr)
-
__all__ = ['SelectResults']
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_select_through.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_select_through.py 2007-03-28 14:08:17 UTC (rev 2463)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_select_through.py 2007-03-28 14:22:33 UTC (rev 2464)
@@ -1,6 +1,7 @@
from sqlobject import *
from sqlobject.sqlbuilder import *
from sqlobject.tests.dbtest import *
+import py
''' Tests retrieving objects through a join/fk on a selectResults
'''
@@ -36,6 +37,9 @@
mod.twos = twos
mod.ones = ones
+def testBadRef():
+ py.test.raises(AttributeError, 'threes[0].throughTo.four')
+
def testThroughFK():
assert list(threes[0].ones.throughTo.three) == [threes[0]]
@@ -43,7 +47,6 @@
assert list(threes[0].ones.throughTo.twos) == [twos[0], twos[1]]
def testThroughRelatedJoin():
- print [list(x.threes) for x in threes[0].twos]
assert list(threes[0].twos.throughTo.threes) == [threes[0], threes[1]]
\ No newline at end of file
|
|
From: <sub...@co...> - 2007-03-28 14:08:19
|
Author: luke
Date: 2007-03-28 08:08:17 -0600 (Wed, 28 Mar 2007)
New Revision: 2463
Modified:
SQLObject/branches/sqlbuilder-sresults/sqlobject/converters.py
SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py
Log:
cleanup
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/converters.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/converters.py 2007-03-28 14:02:45 UTC (rev 2462)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/converters.py 2007-03-28 14:08:17 UTC (rev 2463)
@@ -227,7 +227,6 @@
registerConverter(Decimal, DecimalConverter)
def sqlrepr(obj, db=None):
- import sqlbuilder
try:
reprFunc = obj.__sqlrepr__
except AttributeError:
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py 2007-03-28 14:02:45 UTC (rev 2462)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py 2007-03-28 14:08:17 UTC (rev 2463)
@@ -77,8 +77,6 @@
from converters import sqlrepr, registerConverter, TRUE, FALSE
-default_sqlrepr_db = None
-
safeSQLRE = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_\.]*$')
def sqlIdentifier(obj):
# some db drivers return unicode column names
|
|
From: <sub...@co...> - 2007-03-28 14:02:50
|
Author: luke
Date: 2007-03-28 08:02:45 -0600 (Wed, 28 Mar 2007)
New Revision: 2462
Modified:
SQLObject/branches/sqlbuilder-sresults/sqlobject/sresults.py
SQLObject/branches/sqlbuilder-sresults/sqlobject/tests/test_select_through.py
Log:
sresult.throughTo refactoring
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/sresults.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/sresults.py 2007-03-27 22:05:26 UTC (rev 2461)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/sresults.py 2007-03-28 14:02:45 UTC (rev 2462)
@@ -281,61 +281,59 @@
return results[0]
def throughTo(self):
+ class _throughTo_getter(object):
+ def __init__(self, inst):
+ self.sresult = inst
+ def __getattr__(self, attr):
+ return self.sresult._throughTo(attr)
return _throughTo_getter(self)
throughTo = property(throughTo)
def _throughTo(self, attr):
+ otherClass = None
+ orderBy = sqlbuilder.NoDefault
+
ref = self.sourceClass.sqlmeta.columns.get(attr.endswith('ID') and attr or attr+'ID', None)
if ref and ref.foreignKey:
- return self._throughToFK(ref)
+ otherClass, clause = self._throughToFK(ref)
else:
join = [x for x in self.sourceClass.sqlmeta.joins if x.joinMethodName==attr]
if join:
join = join[0]
+ orderBy = join.orderBy
if hasattr(join, 'otherColumn'):
- return self._throughToRelatedJoin(join)
- return self._throughToMultipleJoin(join)
+ otherClass, clause = self._throughToRelatedJoin(join)
+ else:
+ otherClass, clause = self._throughToMultipleJoin(join)
- raise AttributeError("throughTo argument (got %s) should be name of foreignKey or SQL*Join in %s" % (attr, self.sourceClass))
+ if not otherClass:
+ raise AttributeError("throughTo argument (got %s) should be name of foreignKey or SQL*Join in %s" % (attr, self.sourceClass))
+ return otherClass.select(clause,
+ distinct=True,
+ orderBy=orderBy,
+ connection=self._getConnection())
+
def _throughToFK(self, col):
otherClass = getattr(self.sourceClass, "_SO_class_"+col.foreignKey)
query = sqlbuilder.Alias(self.queryForSelect(), "%s_%s" % (self.sourceClass.__name__, col.name))
- return otherClass.select(otherClass.q.id==getattr(query.q, getattr(self.sourceClass.q, col.name).fieldName),
- distinct=True,
- connection=self._getConnection())
+ return otherClass, otherClass.q.id==getattr(query.q, getattr(self.sourceClass.q, col.name).fieldName)
def _throughToMultipleJoin(self, join):
otherClass = join.otherClass
query = self.queryForSelect()
query = sqlbuilder.Alias(query, "%s_%s" % (self.sourceClass.__name__, join.joinMethodName))
joinColumn = getattr(otherClass.q, join.soClass.sqlmeta.style.dbColumnToPythonAttr(join.joinColumn))
- return otherClass.select(joinColumn == getattr(query.q, self.sourceClass.q.id.fieldName),
- distinct=True,
- orderBy=join.orderBy,
- connection=self._getConnection())
+ return otherClass, joinColumn==getattr(query.q, self.sourceClass.q.id.fieldName)
def _throughToRelatedJoin(self, join):
otherClass = join.otherClass
intTable = sqlbuilder.Table(join.intermediateTable)
- print join.joinColumn, join.otherColumn
query = self.queryForSelect().newItems([getattr(intTable, join.joinColumn)])
query = sqlbuilder.Alias(query, "%s_%s" % (self.sourceClass.__name__, join.joinMethodName))
- print query
clause = sqlbuilder.AND(otherClass.q.id == getattr(intTable, join.otherColumn),
getattr(intTable, join.joinColumn) == getattr(query.q, join.joinColumn))
- ret = otherClass.select(clause,
- distinct=True,
- orderBy=join.orderBy,
- connection=self._getConnection())
- print ret
- return ret
+ return otherClass, clause
-class _throughTo_getter(object):
- def __init__(self, inst):
- self.sresult = inst
- def __getattr__(self, attr):
- return self.sresult._throughTo(attr)
-
__all__ = ['SelectResults']
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/tests/test_select_through.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/tests/test_select_through.py 2007-03-27 22:05:26 UTC (rev 2461)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/tests/test_select_through.py 2007-03-28 14:02:45 UTC (rev 2462)
@@ -1,6 +1,7 @@
from sqlobject import *
from sqlobject.sqlbuilder import *
from sqlobject.tests.dbtest import *
+import py
''' Tests retrieving objects through a join/fk on a selectResults
'''
@@ -36,6 +37,9 @@
mod.twos = twos
mod.ones = ones
+def testBadRef():
+ py.test.raises(AttributeError, 'threes[0].throughTo.four')
+
def testThroughFK():
assert list(threes[0].ones.throughTo.three) == [threes[0]]
@@ -43,7 +47,6 @@
assert list(threes[0].ones.throughTo.twos) == [twos[0], twos[1]]
def testThroughRelatedJoin():
- print [list(x.threes) for x in threes[0].twos]
assert list(threes[0].twos.throughTo.threes) == [threes[0], threes[1]]
\ No newline at end of file
|
|
From: <sub...@co...> - 2007-03-27 22:05:29
|
Author: luke
Date: 2007-03-27 16:05:26 -0600 (Tue, 27 Mar 2007)
New Revision: 2461
Modified:
SQLObject/branches/sqlbuilder-sresults/sqlobject/conftest.py
Log:
pkg.require back in
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/conftest.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/conftest.py 2007-03-27 22:04:50 UTC (rev 2460)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/conftest.py 2007-03-27 22:05:26 UTC (rev 2461)
@@ -16,7 +16,7 @@
except ImportError: # Python 2.2
pass
else:
- pass #pkg_resources.require('SQLObject')
+ pkg_resources.require('SQLObject')
connectionShortcuts = {
'mysql': 'mysql://test@localhost/test',
|
|
From: <sub...@co...> - 2007-03-27 22:04:55
|
Author: luke
Date: 2007-03-27 16:04:50 -0600 (Tue, 27 Mar 2007)
New Revision: 2460
Modified:
SQLObject/branches/sqlbuilder-sresults/sqlobject/conftest.py
SQLObject/branches/sqlbuilder-sresults/sqlobject/converters.py
SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py
Log:
Remove hokey sqlrepr-caching
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/conftest.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/conftest.py 2007-03-27 21:49:09 UTC (rev 2459)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/conftest.py 2007-03-27 22:04:50 UTC (rev 2460)
@@ -16,7 +16,7 @@
except ImportError: # Python 2.2
pass
else:
- pkg_resources.require('SQLObject')
+ pass #pkg_resources.require('SQLObject')
connectionShortcuts = {
'mysql': 'mysql://test@localhost/test',
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/converters.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/converters.py 2007-03-27 21:49:09 UTC (rev 2459)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/converters.py 2007-03-27 22:04:50 UTC (rev 2460)
@@ -237,20 +237,4 @@
(type(obj), repr(obj))
return converter(obj, db)
else:
- doCache = hasattr(db, 'doSQLReprCache')
- ret = None
- if doCache:
- cache = getattr(obj, '_sqlreprCache', {})
- if not isinstance(cache, dict):
- #Alias etc
- cache = {}
- ret = cache.get(db, None)
- if ret is None:
- ret = reprFunc(db)
- if doCache:
- try:
- cache[db] = ret
- obj._sqlreprCache = cache
- except TypeError:
- pass
- return ret
+ return reprFunc(db)
Modified: SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py 2007-03-27 21:49:09 UTC (rev 2459)
+++ SQLObject/branches/sqlbuilder-sresults/sqlobject/sqlbuilder.py 2007-03-27 22:04:50 UTC (rev 2460)
@@ -188,28 +188,13 @@
def tablesUsed(self, db):
return self.tablesUsedDict(db).keys()
def tablesUsedDict(self, db):
- doCache = hasattr(db, 'doTablesUsedCache')
- tables = None
- if doCache:
- cache = getattr(self, '_tablesUsedCache', {})
- if not isinstance(cache, dict):
- #Alias etc
- cache = {}
- tables = cache.get(db, None)
- if tables is None:
- tables = {}
- for table in self.tablesUsedImmediate():
- if hasattr(table, '__sqlrepr__'):
- table = sqlrepr(table, db)
- tables[table] = 1
- for component in self.components():
- tables.update(tablesUsedDict(component, db))
- if doCache:
- try:
- cache[db] = tables
- self._tablesUsedCache = cache
- except TypeError:
- pass
+ tables = {}
+ for table in self.tablesUsedImmediate():
+ if hasattr(table, '__sqlrepr__'):
+ table = sqlrepr(table, db)
+ tables[table] = 1
+ for component in self.components():
+ tables.update(tablesUsedDict(component, db))
return tables
def tablesUsedImmediate(self):
return []
|
|
From: <sub...@co...> - 2007-03-27 21:38:34
|
Author: luke Date: 2007-03-27 15:37:41 -0600 (Tue, 27 Mar 2007) New Revision: 2458 Added: SQLObject/branches/sqlbuilder-sresults/ Log: Branch for sqlbuilder changes to selectResults, ImportProxy, sqlrepr-caching, and selectResults.throughTo (will be sqlbuilder-views branch minus views) Copied: SQLObject/branches/sqlbuilder-sresults (from rev 2457, SQLObject/trunk) |
|
From: <sub...@co...> - 2007-03-27 21:21:00
|
Author: luke
Date: 2007-03-27 15:20:59 -0600 (Tue, 27 Mar 2007)
New Revision: 2457
Modified:
SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_aliases.py
SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_select_through.py
Log:
cleanup
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_aliases.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_aliases.py 2007-03-27 20:56:01 UTC (rev 2456)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_aliases.py 2007-03-27 21:20:59 UTC (rev 2457)
@@ -24,6 +24,5 @@
JoinAlias(name="parent", parent="grandparent")
JoinAlias(name="child", parent="parent")
alias = Alias(JoinAlias)
- print tablesUsedDict(alias.q.name, None)
select = JoinAlias.select(JoinAlias.q.parent == alias.q.name)
assert select.count() == 2
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_select_through.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_select_through.py 2007-03-27 20:56:01 UTC (rev 2456)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/tests/test_select_through.py 2007-03-27 21:20:59 UTC (rev 2457)
@@ -2,11 +2,7 @@
from sqlobject.sqlbuilder import *
from sqlobject.tests.dbtest import *
-''' Going to test that complex sqlbuilder constructions are never
- prematurely stringified. A straight-forward approach is to use
- Bools, since postgresql wants special formatting in queries.
- The test is whether a call to sqlrepr(x, 'postgres') includes
- the appropriate bool formatting throughout.
+''' Tests retrieving objects through a join/fk on a selectResults
'''
class SRThrough1(SQLObject):
|
|
From: <sub...@co...> - 2007-03-27 20:56:08
|
Author: luke
Date: 2007-03-27 14:56:01 -0600 (Tue, 27 Mar 2007)
New Revision: 2456
Modified:
SQLObject/branches/sqlbuilder-views/sqlobject/views.py
Log:
Test caught no-connection change
Modified: SQLObject/branches/sqlbuilder-views/sqlobject/views.py
===================================================================
--- SQLObject/branches/sqlbuilder-views/sqlobject/views.py 2007-03-27 15:01:10 UTC (rev 2455)
+++ SQLObject/branches/sqlbuilder-views/sqlobject/views.py 2007-03-27 20:56:01 UTC (rev 2456)
@@ -78,7 +78,7 @@
SQLObject.__classinit__(cls, new_attrs)
# like is_base
if cls.__name__ != 'ViewSQLObject':
- dbName = hasattr(cls,'_connection') and cls._connection.dbName or None
+ dbName = hasattr(cls,'_connection') and (cls._connection and cls._connection.dbName) or None
if getattr(cls.sqlmeta, 'table', None):
cls.sqlmeta.alias = cls.sqlmeta.table
|
|
From: <sub...@co...> - 2007-03-27 15:01:13
|
Author: phd
Date: 2007-03-27 09:01:10 -0600 (Tue, 27 Mar 2007)
New Revision: 2455
Modified:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py
home/phd/SQLObject/paramstyles/sqlobject/sresults.py
Log:
Merged patches from the revisions 2452:2454 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2007-03-27 14:59:52 UTC (rev 2454)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2007-03-27 15:01:10 UTC (rev 2455)
@@ -33,11 +33,11 @@
if clause is None or isinstance(clause, str) and clause == 'all':
clause = sqlbuilder.SQLTrueClause
tablesDict = tablesUsedDict(clause)
- tablesDict[sourceClass.sqlmeta.table] = 1
+ tablesDict[str(sourceClass.sqlmeta.table)] = 1
orderBy = ops.get('orderBy')
if inheritedTables:
for tableName in inheritedTables:
- tablesDict[tableName] = 1
+ tablesDict[str(tableName)] = 1
if orderBy and not isinstance(orderBy, basestring):
tablesDict.update(tablesUsedDict(orderBy))
#DSM: if this class has a parent, we need to link it
@@ -51,7 +51,7 @@
allClasses = classregistry.registry(
sourceClass.sqlmeta.registry).allClasses()
for registryClass in allClasses:
- if registryClass.sqlmeta.table in tablesDict:
+ if str(registryClass.sqlmeta.table) in tablesDict:
#DSM: By default, no parents are needed for the clauses
tableRegistry[registryClass] = registryClass
tableRegistryCopy = tableRegistry.copy()
@@ -78,7 +78,7 @@
parentClass = currentClass.sqlmeta.parentClass
parentClause.append(currentClass.q.id == parentClass.q.id)
currentClass = parentClass
- tablesDict[currentClass.sqlmeta.table] = 1
+ tablesDict[str(currentClass.sqlmeta.table)] = 1
clause = reduce(sqlbuilder.AND, parentClause, clause)
super(InheritableSelectResults, self).__init__(sourceClass,
Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py 2007-03-27 14:59:52 UTC (rev 2454)
+++ home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py 2007-03-27 15:01:10 UTC (rev 2455)
@@ -216,7 +216,7 @@
def tablesUsedDict(self):
tables = {}
for table in self.tablesUsedImmediate():
- tables[table] = 1
+ tables[str(table)] = 1
for component in self.components():
tables.update(tablesUsedDict(component))
return tables
Modified: home/phd/SQLObject/paramstyles/sqlobject/sresults.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/sresults.py 2007-03-27 14:59:52 UTC (rev 2454)
+++ home/phd/SQLObject/paramstyles/sqlobject/sresults.py 2007-03-27 15:01:10 UTC (rev 2455)
@@ -14,10 +14,10 @@
clause = sqlbuilder.SQLTrueClause
self.clause = clause
tablesDict = sqlbuilder.tablesUsedDict(self.clause)
- tablesDict[sourceClass.sqlmeta.table] = 1
+ tablesDict[str(sourceClass.sqlmeta.table)] = 1
if clauseTables:
for table in clauseTables:
- tablesDict[table] = 1
+ tablesDict[str(table)] = 1
self.clauseTables = clauseTables
self.tables = tablesDict.keys()
self.ops = ops
|
|
From: <sub...@co...> - 2007-03-27 15:00:00
|
Author: phd
Date: 2007-03-27 08:59:52 -0600 (Tue, 27 Mar 2007)
New Revision: 2454
Modified:
SQLObject/docs/SQLObject.txt
Log:
Added a new section "Workaround for primary keys made up of multiple columns".
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2007-03-27 14:17:58 UTC (rev 2453)
+++ SQLObject/docs/SQLObject.txt 2007-03-27 14:59:52 UTC (rev 2454)
@@ -1514,6 +1514,59 @@
(case-insensitive). This restriction will probably be removed in the
next release.
+Workaround for primary keys made up of multiple columns
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If the database table/view has ONE NUMERIC Primary Key then sqlmeta - idName
+should be used to map the table column name to SQLObject id column.
+
+If the Primary Key consists only of number columns it is possible to create a
+virtual column "id" this way:
+
+Example for Postgresql:
+
+ select '1'||lpad(PK1,max_length_of_PK1,'0')||lpad(PK2,max_length_of_PK2,'0')||...||lpad(PKn,max_length_of_PKn,'0') as "id",
+ column_PK1, column_PK2, .., column_PKn, column... from table;
+
+Note:
+
+* The arbitrary '1' at the beginning of the string to allow for leading zeros
+ of the first PK.
+
+* The application designer has to determine the maximum length of each Primary
+ Key.
+
+This statement can be saved as a view or the column can be added to the
+database table, where it can be kept up to date with a database trigger.
+
+Obviously the "view" method does generally not allow insert, updates or
+deletes. For Postgresql you may want to consult the chapter "RULES" for
+manipulating underlying tables.
+
+For an alphanumeric Primary Key column a similar method is possible:
+
+Every character of the lpaded PK has to be transfered using ascii(character)
+which returns a 3digit number which can be concatenated as shown above.
+
+Caveats:
+
+* this way the "id" may become a very large integer number which may cause
+ troubles elsewhere.
+
+* no performance loss takes place if the where clauses specifies the PK
+ columns.
+
+Example: CD-Album
+* Album: PK=ean
+* Tracks: PK=ean,disc_nr,track_nr
+
+The database view to show the tracks starts:
+
+ SELECT ean||lpad("disc_nr",2,'0')||lpad("track_nr",2,'0') as id, ...
+ Note: no leading '1' and no padding necessary for ean numbers
+
+Tracks.select(Tracks.q.ean==id) ... where id is the ean of the Album.
+
Changing the Naming Style
-------------------------
|
|
From: SourceForge.net <no...@so...> - 2007-03-27 14:21:14
|
Patches item #1673015, was opened at 2007-03-03 17:26 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1673015&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: Later Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) >Assigned to: Oleg Broytmann (phd) Summary: Use sets instead of dicts for used tables. Initial Comment: Since dicts are used as plain sets there, why not to just use sets? Yeah, I know, because of Python 2.2 compatibility :) Maybe some day... ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-03-27 18:21 Message: Logged In: YES user_id=4799 Originator: NO Will be applied after SQLObject would have switched to Python 2.3. ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-03-03 17:27 Message: Logged In: YES user_id=240225 Originator: YES File Added: tablesdict.str.set-trunk.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1673015&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-03-27 14:18:56
|
Patches item #1673013, was opened at 2007-03-03 17:23 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1673013&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Leandro Lucarella (llucax) >Assigned to: Oleg Broytmann (phd) Summary: Convert used tables dict keys to string. Initial Comment: Convert used tables dict keys to string so you can use SQLBuilder.Table in some places you actually can't. See bug 1642143: http://sourceforge.net/tracker/index.php?func=detail&aid=1642143&group_id=74338&atid=540672 ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-03-27 18:18 Message: Logged In: YES user_id=4799 Originator: NO Applied and committed to the trunk in the revision 2453. ---------------------------------------------------------------------- Comment By: Leandro Lucarella (llucax) Date: 2007-03-03 17:24 Message: Logged In: YES user_id=240225 Originator: YES File Added: tablesdict.str-trunk.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1673013&group_id=74338 |
|
From: <sub...@co...> - 2007-03-27 14:18:04
|
Author: phd
Date: 2007-03-27 08:17:58 -0600 (Tue, 27 Mar 2007)
New Revision: 2453
Modified:
SQLObject/trunk/sqlobject/inheritance/__init__.py
SQLObject/trunk/sqlobject/sqlbuilder.py
SQLObject/trunk/sqlobject/sresults.py
Log:
Applied the patch 1673013: Convert used tables dict keys to string.
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-03-27 02:22:54 UTC (rev 2452)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-03-27 14:17:58 UTC (rev 2453)
@@ -33,11 +33,11 @@
if clause is None or isinstance(clause, str) and clause == 'all':
clause = sqlbuilder.SQLTrueClause
tablesDict = tablesUsedDict(clause)
- tablesDict[sourceClass.sqlmeta.table] = 1
+ tablesDict[str(sourceClass.sqlmeta.table)] = 1
orderBy = ops.get('orderBy')
if inheritedTables:
for tableName in inheritedTables:
- tablesDict[tableName] = 1
+ tablesDict[str(tableName)] = 1
if orderBy and not isinstance(orderBy, basestring):
tablesDict.update(tablesUsedDict(orderBy))
#DSM: if this class has a parent, we need to link it
@@ -51,7 +51,7 @@
allClasses = classregistry.registry(
sourceClass.sqlmeta.registry).allClasses()
for registryClass in allClasses:
- if registryClass.sqlmeta.table in tablesDict:
+ if str(registryClass.sqlmeta.table) in tablesDict:
#DSM: By default, no parents are needed for the clauses
tableRegistry[registryClass] = registryClass
tableRegistryCopy = tableRegistry.copy()
@@ -78,7 +78,7 @@
parentClass = currentClass.sqlmeta.parentClass
parentClause.append(currentClass.q.id == parentClass.q.id)
currentClass = parentClass
- tablesDict[currentClass.sqlmeta.table] = 1
+ tablesDict[str(currentClass.sqlmeta.table)] = 1
clause = reduce(sqlbuilder.AND, parentClause, clause)
super(InheritableSelectResults, self).__init__(sourceClass,
Modified: SQLObject/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2007-03-27 02:22:54 UTC (rev 2452)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2007-03-27 14:17:58 UTC (rev 2453)
@@ -187,7 +187,7 @@
def tablesUsedDict(self):
tables = {}
for table in self.tablesUsedImmediate():
- tables[table] = 1
+ tables[str(table)] = 1
for component in self.components():
tables.update(tablesUsedDict(component))
return tables
Modified: SQLObject/trunk/sqlobject/sresults.py
===================================================================
--- SQLObject/trunk/sqlobject/sresults.py 2007-03-27 02:22:54 UTC (rev 2452)
+++ SQLObject/trunk/sqlobject/sresults.py 2007-03-27 14:17:58 UTC (rev 2453)
@@ -14,10 +14,10 @@
clause = sqlbuilder.SQLTrueClause
self.clause = clause
tablesDict = sqlbuilder.tablesUsedDict(self.clause)
- tablesDict[sourceClass.sqlmeta.table] = 1
+ tablesDict[str(sourceClass.sqlmeta.table)] = 1
if clauseTables:
for table in clauseTables:
- tablesDict[table] = 1
+ tablesDict[str(table)] = 1
self.clauseTables = clauseTables
self.tables = tablesDict.keys()
self.ops = ops
|
|
From: <sub...@co...> - 2007-03-22 16:37:24
|
Author: phd
Date: 2007-03-22 10:37:12 -0600 (Thu, 22 Mar 2007)
New Revision: 2446
Modified:
home/phd/SQLObject/paramstyles/sqlobject/main.py
home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_delete.py
Log:
Merged patches from the revisions 2442:2445 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-03-22 16:24:17 UTC (rev 2445)
+++ home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-03-22 16:37:12 UTC (rev 2446)
@@ -1562,6 +1562,19 @@
delete = classmethod(delete)
+ def deleteMany(cls, where=NoDefault, connection=None):
+ conn = connection or cls._connection
+ conn.query(conn.sqlrepr(sqlbuilder.Delete(cls.sqlmeta.table, where)))
+
+ deleteMany = classmethod(deleteMany)
+
+ def deleteBy(cls, connection=None, **kw):
+ conn = connection or cls._connection
+ conn.query(conn.sqlrepr(sqlbuilder.Delete(cls.sqlmeta.table,
+ conn._SO_columnClause(cls, kw))))
+
+ deleteBy = classmethod(deleteBy)
+
def __repr__(self):
if not hasattr(self, 'id'):
# Object initialization not finished. No attributes can be read.
@@ -1600,6 +1613,7 @@
cls._connection = value
setConnection = classmethod(setConnection)
+
def capitalize(name):
return name[0].capitalize() + name[1:]
Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py 2007-03-22 16:24:17 UTC (rev 2445)
+++ home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py 2007-03-22 16:37:12 UTC (rev 2446)
@@ -718,10 +718,12 @@
raise TypeError, "You must give a where clause or pass in None to indicate no where clause"
self.whereClause = where
def __sqlrepr__(self, db):
- if self.whereClause is None:
+ whereClause = self.whereClause
+ if whereClause is None:
return "DELETE FROM %s" % self.table
- return "DELETE FROM %s WHERE %s" \
- % (self.table, sqlrepr(self.whereClause, db))
+ if isinstance(whereClause, SQLExpression):
+ whereClause = sqlrepr(whereClause, db)
+ return "DELETE FROM %s WHERE %s" % (self.table, whereClause)
def __sqllist__(self):
if self.whereClause is None:
return ["DELETE FROM %s" % self.table]
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_delete.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_delete.py 2007-03-22 16:24:17 UTC (rev 2445)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_delete.py 2007-03-22 16:37:12 UTC (rev 2446)
@@ -13,6 +13,20 @@
assert list(TestSO1.select('all')) == []
########################################
+## Delete many rows at once
+########################################
+
+def testDeleteMany():
+ setupGetters(TestSO1)
+ TestSO1.deleteMany(OR(TestSO1.q.name=="bob", TestSO1.q.name=="fred"))
+ assert len(list(TestSO1.select('all'))) == 2
+
+def testDeleteBy():
+ setupGetters(TestSO1)
+ TestSO1.deleteBy(name="dave")
+ assert len(list(TestSO1.select())) == 3
+
+########################################
## Delete without caching
########################################
|
|
From: <sub...@co...> - 2007-03-22 16:24:30
|
Author: phd Date: 2007-03-22 10:24:17 -0600 (Thu, 22 Mar 2007) New Revision: 2445 Modified: SQLObject/docs/News.txt Log: cls.deleteMany(), cls.deleteBy(). Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-03-22 16:24:00 UTC (rev 2444) +++ SQLObject/docs/News.txt 2007-03-22 16:24:17 UTC (rev 2445) @@ -57,6 +57,8 @@ * cls.tableExists() as a shortcut for conn.tableExists(cls.sqlmeta.table). +* cls.deleteMany(), cls.deleteBy(). + Bug Fixes --------- |
|
From: <sub...@co...> - 2007-03-22 16:24:16
|
Author: phd
Date: 2007-03-22 10:24:00 -0600 (Thu, 22 Mar 2007)
New Revision: 2444
Modified:
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/tests/test_delete.py
Log:
cls.deleteMany(), cls.deleteBy().
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2007-03-22 16:22:46 UTC (rev 2443)
+++ SQLObject/trunk/sqlobject/main.py 2007-03-22 16:24:00 UTC (rev 2444)
@@ -1562,6 +1562,19 @@
delete = classmethod(delete)
+ def deleteMany(cls, where=NoDefault, connection=None):
+ conn = connection or cls._connection
+ conn.query(conn.sqlrepr(sqlbuilder.Delete(cls.sqlmeta.table, where)))
+
+ deleteMany = classmethod(deleteMany)
+
+ def deleteBy(cls, connection=None, **kw):
+ conn = connection or cls._connection
+ conn.query(conn.sqlrepr(sqlbuilder.Delete(cls.sqlmeta.table,
+ conn._SO_columnClause(cls, kw))))
+
+ deleteBy = classmethod(deleteBy)
+
def __repr__(self):
if not hasattr(self, 'id'):
# Object initialization not finished. No attributes can be read.
@@ -1600,6 +1613,7 @@
cls._connection = value
setConnection = classmethod(setConnection)
+
def capitalize(name):
return name[0].capitalize() + name[1:]
Modified: SQLObject/trunk/sqlobject/tests/test_delete.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_delete.py 2007-03-22 16:22:46 UTC (rev 2443)
+++ SQLObject/trunk/sqlobject/tests/test_delete.py 2007-03-22 16:24:00 UTC (rev 2444)
@@ -13,6 +13,20 @@
assert list(TestSO1.select('all')) == []
########################################
+## Delete many rows at once
+########################################
+
+def testDeleteMany():
+ setupGetters(TestSO1)
+ TestSO1.deleteMany(OR(TestSO1.q.name=="bob", TestSO1.q.name=="fred"))
+ assert len(list(TestSO1.select('all'))) == 2
+
+def testDeleteBy():
+ setupGetters(TestSO1)
+ TestSO1.deleteBy(name="dave")
+ assert len(list(TestSO1.select())) == 3
+
+########################################
## Delete without caching
########################################
|
|
From: <sub...@co...> - 2007-03-22 16:22:55
|
Author: phd
Date: 2007-03-22 10:22:46 -0600 (Thu, 22 Mar 2007)
New Revision: 2443
Modified:
SQLObject/trunk/sqlobject/sqlbuilder.py
Log:
Do not run sqlrepr() if the clause is string.
Modified: SQLObject/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2007-03-21 16:47:33 UTC (rev 2442)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2007-03-22 16:22:46 UTC (rev 2443)
@@ -602,10 +602,12 @@
raise TypeError, "You must give a where clause or pass in None to indicate no where clause"
self.whereClause = where
def __sqlrepr__(self, db):
- if self.whereClause is None:
+ whereClause = self.whereClause
+ if whereClause is None:
return "DELETE FROM %s" % self.table
- return "DELETE FROM %s WHERE %s" \
- % (self.table, sqlrepr(self.whereClause, db))
+ if isinstance(whereClause, SQLExpression):
+ whereClause = sqlrepr(whereClause, db)
+ return "DELETE FROM %s WHERE %s" % (self.table, whereClause)
registerConverter(Delete, SQLExprConverter)
|
|
From: <sub...@co...> - 2007-03-20 15:36:30
|
Author: phd
Date: 2007-03-20 09:36:19 -0600 (Tue, 20 Mar 2007)
New Revision: 2441
Modified:
SQLObject/docs/News.txt
SQLObject/docs/sqlobject-architecture.txt
Log:
Minor updates.
Modified: SQLObject/docs/News.txt
===================================================================
--- SQLObject/docs/News.txt 2007-03-20 15:34:54 UTC (rev 2440)
+++ SQLObject/docs/News.txt 2007-03-20 15:36:19 UTC (rev 2441)
@@ -55,8 +55,7 @@
* Support for MySQL storage ENGINEs.
-* SQLObject.tableExists() as a shortcut for
- conn.tableExists(cls.sqlmeta.table).
+* cls.tableExists() as a shortcut for conn.tableExists(cls.sqlmeta.table).
Bug Fixes
---------
Modified: SQLObject/docs/sqlobject-architecture.txt
===================================================================
--- SQLObject/docs/sqlobject-architecture.txt 2007-03-20 15:34:54 UTC (rev 2440)
+++ SQLObject/docs/sqlobject-architecture.txt 2007-03-20 15:36:19 UTC (rev 2441)
@@ -4,8 +4,8 @@
.q is an object that returns special attributes of type
sqlbuilder.SQLExpression. SQLExpression is a special class that overrides
-almost all Python magic methods and upon any operation it, instead of
-evaluating, it constructs another instance of SQLExpression that remembers
+almost all Python magic methods and upon any operation instead of
+evaluating it constructs another instance of SQLExpression that remembers
what operation it has to do. A kind of symbolic algebra. Example:
SQLExpression("foo") > 30
|
|
From: <sub...@co...> - 2007-03-20 15:35:11
|
Author: phd
Date: 2007-03-20 09:34:54 -0600 (Tue, 20 Mar 2007)
New Revision: 2440
Modified:
SQLObject/branches/0.8/docs/sqlobject-architecture.txt
Log:
Minor update (removed double "it").
Modified: SQLObject/branches/0.8/docs/sqlobject-architecture.txt
===================================================================
--- SQLObject/branches/0.8/docs/sqlobject-architecture.txt 2007-03-20 15:27:50 UTC (rev 2439)
+++ SQLObject/branches/0.8/docs/sqlobject-architecture.txt 2007-03-20 15:34:54 UTC (rev 2440)
@@ -4,8 +4,8 @@
.q is an object that returns special attributes of type
sqlbuilder.SQLExpression. SQLExpression is a special class that overrides
-almost all Python magic methods and upon any operation it, instead of
-evaluating, it constructs another instance of SQLExpression that remembers
+almost all Python magic methods and upon any operation instead of
+evaluating it constructs another instance of SQLExpression that remembers
what operation it has to do. A kind of symbolic algebra. Example:
SQLExpression("foo") > 30
|
|
From: <sub...@co...> - 2007-03-20 15:28:18
|
Author: phd
Date: 2007-03-20 09:27:50 -0600 (Tue, 20 Mar 2007)
New Revision: 2439
Modified:
home/phd/SQLObject/paramstyles/sqlobject/main.py
Log:
Merged patches from the revisions 2436:2438 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-03-20 15:25:14 UTC (rev 2438)
+++ home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-03-20 15:27:50 UTC (rev 2439)
@@ -1346,10 +1346,16 @@
selectBy = classmethod(selectBy)
+ def tableExists(cls, connection=None):
+ conn = connection or cls._connection
+ return conn.tableExists(cls.sqlmeta.table)
+
+ tableExists = classmethod(tableExists)
+
def dropTable(cls, ifExists=False, dropJoinTables=True, cascade=False,
connection=None):
conn = connection or cls._connection
- if ifExists and not conn.tableExists(cls.sqlmeta.table):
+ if ifExists and not cls.tableExists(connection=conn):
return
extra_sql = []
post_funcs = []
@@ -1368,7 +1374,7 @@
createIndexes=True, applyConstraints=True,
connection=None):
conn = connection or cls._connection
- if ifNotExists and conn.tableExists(cls.sqlmeta.table):
+ if ifNotExists and cls.tableExists(connection=conn):
return
extra_sql = []
post_funcs = []
|
|
From: <sub...@co...> - 2007-03-20 15:25:34
|
Author: phd Date: 2007-03-20 09:25:14 -0600 (Tue, 20 Mar 2007) New Revision: 2438 Modified: SQLObject/docs/News.txt Log: SQLObject.tableExists() as a shortcut for conn.tableExists(cls.sqlmeta.table). Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-03-20 15:24:41 UTC (rev 2437) +++ SQLObject/docs/News.txt 2007-03-20 15:25:14 UTC (rev 2438) @@ -55,6 +55,9 @@ * Support for MySQL storage ENGINEs. +* SQLObject.tableExists() as a shortcut for + conn.tableExists(cls.sqlmeta.table). + Bug Fixes --------- |
|
From: <sub...@co...> - 2007-03-20 15:24:57
|
Author: phd
Date: 2007-03-20 09:24:41 -0600 (Tue, 20 Mar 2007)
New Revision: 2437
Modified:
SQLObject/trunk/sqlobject/main.py
Log:
SQLObject.tableExists() as a shortcut for conn.tableExists(cls.sqlmeta.table).
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2007-03-19 23:07:33 UTC (rev 2436)
+++ SQLObject/trunk/sqlobject/main.py 2007-03-20 15:24:41 UTC (rev 2437)
@@ -1346,10 +1346,16 @@
selectBy = classmethod(selectBy)
+ def tableExists(cls, connection=None):
+ conn = connection or cls._connection
+ return conn.tableExists(cls.sqlmeta.table)
+
+ tableExists = classmethod(tableExists)
+
def dropTable(cls, ifExists=False, dropJoinTables=True, cascade=False,
connection=None):
conn = connection or cls._connection
- if ifExists and not conn.tableExists(cls.sqlmeta.table):
+ if ifExists and not cls.tableExists(connection=conn):
return
extra_sql = []
post_funcs = []
@@ -1368,7 +1374,7 @@
createIndexes=True, applyConstraints=True,
connection=None):
conn = connection or cls._connection
- if ifNotExists and conn.tableExists(cls.sqlmeta.table):
+ if ifNotExists and cls.tableExists(connection=conn):
return
extra_sql = []
post_funcs = []
|
|
From: <sub...@co...> - 2007-03-19 16:56:04
|
Author: phd Date: 2007-03-19 10:55:32 -0600 (Mon, 19 Mar 2007) New Revision: 2432 Modified: SQLObject/tags/0.8.1/setup.cfg Log: Releasing stable version 0.8.1. Modified: SQLObject/tags/0.8.1/setup.cfg =================================================================== --- SQLObject/tags/0.8.1/setup.cfg 2007-03-19 16:52:52 UTC (rev 2431) +++ SQLObject/tags/0.8.1/setup.cfg 2007-03-19 16:55:32 UTC (rev 2432) @@ -1,10 +1,3 @@ -[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/SQLObject.txt docs/TODO.txt |