sqlobject-cvs Mailing List for SQLObject (Page 81)
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-09-20 15:28:51
|
Author: phd
Date: 2007-09-20 09:28:44 -0600 (Thu, 20 Sep 2007)
New Revision: 2968
Modified:
SQLObject/trunk/sqlobject/col.py
SQLObject/trunk/sqlobject/constraints.py
SQLObject/trunk/sqlobject/converters.py
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/sqlbuilder.py
SQLObject/trunk/sqlobject/sresults.py
SQLObject/trunk/sqlobject/tests/test_converters.py
Log:
Use isinstance() instead of type().
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2007-09-20 14:40:33 UTC (rev 2967)
+++ SQLObject/trunk/sqlobject/col.py 2007-09-20 15:28:44 UTC (rev 2968)
@@ -19,6 +19,7 @@
"""
import re, time
+from array import array
try:
import cPickle as pickle
except ImportError:
@@ -30,7 +31,6 @@
from formencode import compound
from formencode import validators
from classregistry import findClass
-from converters import array_type, buffer_type
from util.backports import count
NoDefault = sqlbuilder.NoDefault
@@ -150,7 +150,7 @@
"The only string value allowed for cascade is 'null' (you gave: %r)" % cascade)
self.cascade = cascade
- if type(constraints) not in (type([]), type(())):
+ if not isinstance(constraints, (list, tuple)):
constraints = [constraints]
self.constraints = self.autoConstraints() + constraints
@@ -537,7 +537,7 @@
return None
if isinstance(value, unicode):
return value
- if isinstance(value, array_type): # MySQL
+ if isinstance(value, array): # MySQL
return unicode(value.tostring(), self.db_encoding)
return unicode(value, self.db_encoding)
@@ -651,17 +651,17 @@
if value is None:
return None
elif not value:
- return sqlbuilder.FALSE
+ return False
else:
- return sqlbuilder.TRUE
+ return True
def from_python(self, value, state):
if value is None:
return None
elif value:
- return sqlbuilder.TRUE
+ return True
else:
- return sqlbuilder.FALSE
+ return False
class SOBoolCol(SOCol):
def autoConstraints(self):
@@ -1361,11 +1361,11 @@
if connection.dbName == "sqlite":
value = connection.module.decode(value)
return value
- if isinstance(value, (buffer_type, state.soObject._connection._binaryType)):
+ if isinstance(value, (buffer, state.soObject._connection._binaryType)):
cachedValue = self._cachedValue
if cachedValue and cachedValue[1] == value:
return cachedValue[0]
- if isinstance(value, array_type): # MySQL
+ if isinstance(value, array): # MySQL
return value.tostring()
return str(value) # buffer => string
raise validators.Invalid("expected a string in the BLOBCol '%s', got %s %r instead" % \
Modified: SQLObject/trunk/sqlobject/constraints.py
===================================================================
--- SQLObject/trunk/sqlobject/constraints.py 2007-09-20 14:40:33 UTC (rev 2967)
+++ SQLObject/trunk/sqlobject/constraints.py 2007-09-20 15:28:44 UTC (rev 2968)
@@ -27,15 +27,15 @@
raise BadValue("is defined NOT NULL", obj, col, value)
def isInt(obj, col, value):
- if type(value) not in (type(1), type(1L)):
+ if not isinstance(value, (int, long)):
raise BadValue("only allows integers", obj, col, value)
def isFloat(obj, col, value):
- if type(value) not in (type(1), type(1L), type(1.1)):
+ if not isinstance(value, (int, long, float)):
raise BadValue("only allows floating point numbers", obj, col, value)
def isBool(obj, col, value):
- if type(value) not in (type(True),):
+ if not isinstance(value, bool):
raise BadValue("only allows booleans", obj, col, value)
class InList:
Modified: SQLObject/trunk/sqlobject/converters.py
===================================================================
--- SQLObject/trunk/sqlobject/converters.py 2007-09-20 14:40:33 UTC (rev 2967)
+++ SQLObject/trunk/sqlobject/converters.py 2007-09-20 15:28:44 UTC (rev 2968)
@@ -1,4 +1,4 @@
-import array
+from array import array
try:
import mx.DateTime.ISO
@@ -23,25 +23,8 @@
except ImportError:
NumericType = None
-if type(1==1) == type(1):
- class BOOL(object):
- def __init__(self, value):
- self.value = not not value
- def __nonzero__(self):
- return self.value
- def __repr__(self):
- if self:
- return 'TRUE'
- else:
- return 'FALSE'
- TRUE = BOOL(1)
- FALSE = BOOL(0)
-else:
- TRUE = 1==1
- FALSE = 0==1
+from types import ClassType, InstanceType, NoneType
-from types import InstanceType, ClassType, TypeType
-
try:
from decimal import Decimal
except ImportError:
@@ -85,7 +68,7 @@
self.basic[typ] = func
def lookupConverter(self, value, default=None):
- if type(value) == InstanceType:
+ if type(value) is InstanceType:
# lookup on klasses dict
return self.klass.get(value.__class__, default)
return self.basic.get(type(value), default)
@@ -94,16 +77,13 @@
registerConverter = converters.registerConverter
lookupConverter = converters.lookupConverter
-array_type = type(array.array('c', '')) # In Python 2.2 array.array and buffer
-buffer_type = type(buffer('')) # are functions, not classes
-
def StringLikeConverter(value, db):
- if isinstance(value, array_type):
+ if isinstance(value, array):
try:
value = value.tounicode()
except ValueError:
value = value.tostring()
- elif isinstance(value, buffer_type):
+ elif isinstance(value, buffer):
value = str(value)
if db in ('mysql', 'postgres'):
@@ -117,18 +97,18 @@
registerConverter(str, StringLikeConverter)
registerConverter(unicode, StringLikeConverter)
-registerConverter(array_type, StringLikeConverter)
-registerConverter(buffer_type, StringLikeConverter)
+registerConverter(array, StringLikeConverter)
+registerConverter(buffer, StringLikeConverter)
def IntConverter(value, db):
return repr(int(value))
-registerConverter(type(1), IntConverter)
+registerConverter(int, IntConverter)
def LongConverter(value, db):
return str(value)
-registerConverter(type(0L), LongConverter)
+registerConverter(long, LongConverter)
if NumericType:
registerConverter(NumericType, IntConverter)
@@ -145,16 +125,12 @@
else:
return '0'
-if type(TRUE) == InstanceType:
- # Python 2.2 compatibility:
- registerConverter(BOOL, BoolConverter)
-else:
- registerConverter(type(TRUE), BoolConverter)
+registerConverter(bool, BoolConverter)
def FloatConverter(value, db):
return repr(value)
-registerConverter(type(1.0), FloatConverter)
+registerConverter(float, FloatConverter)
if DateTimeType:
def DateTimeConverter(value, db):
@@ -170,14 +146,14 @@
def NoneConverter(value, db):
return "NULL"
-registerConverter(type(None), NoneConverter)
+registerConverter(NoneType, NoneConverter)
def SequenceConverter(value, db):
return "(%s)" % ", ".join([sqlrepr(v, db) for v in value])
-registerConverter(type(()), SequenceConverter)
-registerConverter(type([]), SequenceConverter)
-registerConverter(type({}), SequenceConverter)
+registerConverter(tuple, SequenceConverter)
+registerConverter(list, SequenceConverter)
+registerConverter(dict, SequenceConverter)
try:
set, frozenset
except NameError:
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2007-09-20 14:40:33 UTC (rev 2967)
+++ SQLObject/trunk/sqlobject/main.py 2007-09-20 15:28:44 UTC (rev 2968)
@@ -841,8 +841,7 @@
if (not new_attrs.has_key('sqlmeta')
and not is_base):
# We have to create our own subclass, usually.
- # type(className, bases_tuple, attr_dict) creates a new
- # subclass:
+ # type(className, bases_tuple, attr_dict) creates a new subclass.
cls.sqlmeta = type('sqlmeta', (cls.sqlmeta,), {})
if not issubclass(cls.sqlmeta, sqlmeta):
# We allow no superclass and an object superclass, instead
@@ -1659,9 +1658,9 @@
def getID(obj):
if isinstance(obj, SQLObject):
return obj.id
- elif type(obj) is type(1):
+ elif isinstance(obj, int):
return obj
- elif type(obj) is type(1L):
+ elif isinstance(obj, long):
return int(obj)
elif isinstance(obj, str):
try:
@@ -1672,9 +1671,9 @@
return None
def getObject(obj, klass):
- if type(obj) is type(1):
+ if isinstance(obj, int):
return klass(obj)
- elif type(obj) is type(1L):
+ elif isinstance(obj, long):
return klass(int(obj))
elif isinstance(obj, str):
return klass(int(obj))
Modified: SQLObject/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2007-09-20 14:40:33 UTC (rev 2967)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2007-09-20 15:28:44 UTC (rev 2968)
@@ -75,7 +75,7 @@
import types
import classregistry
-from converters import sqlrepr, registerConverter, TRUE, FALSE
+from converters import sqlrepr, registerConverter
safeSQLRE = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_\.]*$')
def sqlIdentifier(obj):
@@ -528,7 +528,7 @@
start=0, end=None, reversed=False, forUpdate=False,
clause=NoDefault, staticTables=NoDefault, distinctOn=NoDefault):
self.ops = {}
- if not isinstance(items, (type([]), type(()), types.GeneratorType)):
+ if not isinstance(items, (list, tuple, types.GeneratorType)):
items = [items]
if clause is NoDefault and where is not NoDefault:
clause = where
@@ -694,7 +694,7 @@
insert = "INSERT INTO %s" % self.table
allowNonDict = True
template = self.template
- if template is NoDefault and type(self.valueList[0]) is type({}):
+ if (template is NoDefault) and isinstance(self.valueList[0], dict):
template = self.valueList[0].keys()
allowNonDict = False
if template is not NoDefault:
@@ -703,7 +703,7 @@
listToJoin = []
listToJoin_app = listToJoin.append
for value in self.valueList:
- if type(value) is type({}):
+ if isinstance(value, dict):
if template is NoDefault:
raise TypeError, "You can't mix non-dictionaries with dictionaries in an INSERT if you don't provide a template (%s)" % repr(value)
value = dictToList(template, value)
Modified: SQLObject/trunk/sqlobject/sresults.py
===================================================================
--- SQLObject/trunk/sqlobject/sresults.py 2007-09-20 14:40:33 UTC (rev 2967)
+++ SQLObject/trunk/sqlobject/sresults.py 2007-09-20 15:28:44 UTC (rev 2968)
@@ -128,7 +128,7 @@
return self.newClause(sqlbuilder.AND(clause, filter_clause))
def __getitem__(self, value):
- if type(value) is type(slice(1)):
+ if isinstance(value, slice):
assert not value.step, "Slices do not support steps"
if not value.start and not value.stop:
# No need to copy, I'm immutable
Modified: SQLObject/trunk/sqlobject/tests/test_converters.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_converters.py 2007-09-20 14:40:33 UTC (rev 2967)
+++ SQLObject/trunk/sqlobject/tests/test_converters.py 2007-09-20 15:28:44 UTC (rev 2968)
@@ -1,4 +1,4 @@
-from sqlobject.sqlbuilder import sqlrepr, TRUE, FALSE
+from sqlobject.sqlbuilder import sqlrepr
from sqlobject.sqlbuilder import SQLExpression, SQLObjectField, \
Select, Insert, Update, Delete, Replace, \
SQLTrueClauseClass, SQLConstant, SQLPrefix, SQLCall, SQLOp
@@ -77,10 +77,10 @@
assert sqlrepr(('one','two','three'), 'postgres') == "('one', 'two', 'three')"
def test_bool():
- assert sqlrepr(TRUE, 'postgres') == "'t'"
- assert sqlrepr(FALSE, 'postgres') == "'f'"
- assert sqlrepr(TRUE, 'mysql') == "1"
- assert sqlrepr(FALSE, 'mysql') == "0"
+ assert sqlrepr(True, 'postgres') == "'t'"
+ assert sqlrepr(False, 'postgres') == "'f'"
+ assert sqlrepr(True, 'mysql') == "1"
+ assert sqlrepr(False, 'mysql') == "0"
def test_datetime():
from datetime import datetime, date, time
|
|
From: <sub...@co...> - 2007-09-20 14:40:47
|
Author: phd
Date: 2007-09-20 08:40:33 -0600 (Thu, 20 Sep 2007)
New Revision: 2967
Modified:
SQLObject/trunk/sqlobject/col.py
SQLObject/trunk/sqlobject/constraints.py
SQLObject/trunk/sqlobject/converters.py
SQLObject/trunk/sqlobject/dbconnection.py
SQLObject/trunk/sqlobject/inheritance/__init__.py
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/manager/command.py
SQLObject/trunk/sqlobject/sqlbuilder.py
SQLObject/trunk/sqlobject/sresults.py
SQLObject/trunk/sqlobject/util/csvexport.py
Log:
Use isinstance(..., basestring) instead of isinstance(..., (str, unicode));
stop emulating basestring, stop using types.StringTypes and type("").
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/col.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -1297,7 +1297,7 @@
return None
if isinstance(value, float):
value = str(value)
- if isinstance(value, (str, unicode)):
+ if isinstance(value, basestring):
connection = state.soObject._connection
if hasattr(connection, "decimalSeparator"):
value = value.replace(connection.decimalSeparator, ".")
Modified: SQLObject/trunk/sqlobject/constraints.py
===================================================================
--- SQLObject/trunk/sqlobject/constraints.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/constraints.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -19,7 +19,7 @@
ValueError.__init__(self, fullDesc, *args)
def isString(obj, col, value):
- if type(value) is not type(""):
+ if not isinstance(value, str):
raise BadValue("only allows strings", obj, col, value)
def notNull(obj, col, value):
Modified: SQLObject/trunk/sqlobject/converters.py
===================================================================
--- SQLObject/trunk/sqlobject/converters.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/converters.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -115,8 +115,8 @@
assert 0, "Database %s unknown" % db
return "'%s'" % value
-registerConverter(type(""), StringLikeConverter)
-registerConverter(type(u""), StringLikeConverter)
+registerConverter(str, StringLikeConverter)
+registerConverter(unicode, StringLikeConverter)
registerConverter(array_type, StringLikeConverter)
registerConverter(buffer_type, StringLikeConverter)
Modified: SQLObject/trunk/sqlobject/dbconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/dbconnection.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/dbconnection.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -521,7 +521,7 @@
def _SO_selectOneAlt(self, so, columnNames, condition):
if columnNames:
- columns = [isinstance(x, (str, unicode)) and sqlbuilder.SQLConstant(x) or x for x in columnNames]
+ columns = [isinstance(x, basestring) and sqlbuilder.SQLConstant(x) or x for x in columnNames]
else:
columns = None
return self.queryOne(self.sqlrepr(sqlbuilder.Select(columns,
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -6,13 +6,6 @@
import iteration
-try:
- basestring
-except NameError: # Python 2.2
- import types
- basestring = (types.StringType, types.UnicodeType)
-
-
def tablesUsedDict(obj, db):
if hasattr(obj, "tablesUsedDict"):
return obj.tablesUsedDict(db)
@@ -49,7 +42,7 @@
#DSM: because if the user uses clauseTables
#DSM: (and normal string SELECT), he must know what he wants
#DSM: and will do himself the relationship between classes.
- if type(clause) is not str:
+ if not isinstance(clause, str):
tableRegistry = {}
allClasses = classregistry.registry(
sourceClass.sqlmeta.registry).allClasses()
@@ -222,7 +215,7 @@
for column in currentClass.sqlmeta.columnDefinitions.values():
if column.name == 'childName':
continue
- if type(column) == ForeignKey:
+ if isinstance(column, ForeignKey):
continue
setattr(cls.q, column.name,
getattr(currentClass.q, column.name))
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/main.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -1618,7 +1618,7 @@
return items
def setConnection(cls, value):
- if isinstance(value, (str, unicode)):
+ if isinstance(value, basestring):
value = dbconnection.connectionForURI(value)
cls._connection = value
setConnection = classmethod(setConnection)
@@ -1663,7 +1663,7 @@
return obj
elif type(obj) is type(1L):
return int(obj)
- elif type(obj) is type(""):
+ elif isinstance(obj, str):
try:
return int(obj)
except ValueError:
@@ -1676,7 +1676,7 @@
return klass(obj)
elif type(obj) is type(1L):
return klass(int(obj))
- elif type(obj) is type(""):
+ elif isinstance(obj, str):
return klass(int(obj))
elif obj is None:
return None
Modified: SQLObject/trunk/sqlobject/manager/command.py
===================================================================
--- SQLObject/trunk/sqlobject/manager/command.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/manager/command.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -1256,7 +1256,7 @@
return upgraders[-1]
def update_sys_path(paths, verbose):
- if isinstance(paths, (str, unicode)):
+ if isinstance(paths, basestring):
paths = [paths]
for path in paths:
path = os.path.abspath(path)
Modified: SQLObject/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -80,7 +80,7 @@
safeSQLRE = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_\.]*$')
def sqlIdentifier(obj):
# some db drivers return unicode column names
- return isinstance(obj, types.StringTypes) and bool(safeSQLRE.search(obj.strip()))
+ return isinstance(obj, basestring) and bool(safeSQLRE.search(obj.strip()))
def execute(expr, executor):
@@ -584,7 +584,7 @@
# None doesn't filter anything, it's just a no-op:
return self
clause = self.ops['clause']
- if isinstance(clause, (str, unicode)):
+ if isinstance(clause, basestring):
clause = SQLConstant('(%s)' % clause)
if clause == SQLTrueClause:
@@ -849,7 +849,7 @@
class ColumnAS(SQLOp):
''' Just like SQLOp('AS', expr, name) except without the parentheses '''
def __init__(self, expr, name):
- if isinstance(name, (str, unicode)):
+ if isinstance(name, basestring):
name = SQLConstant(name)
SQLOp.__init__(self, 'AS', expr, name)
def __sqlrepr__(self, db):
@@ -888,7 +888,7 @@
return "CONCAT(%s)" % ", ".join(values)
else:
return " || ".join(values)
- elif isinstance(s, (str, unicode)):
+ elif isinstance(s, basestring):
s = _quote_percent(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
else:
Modified: SQLObject/trunk/sqlobject/sresults.py
===================================================================
--- SQLObject/trunk/sqlobject/sresults.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/sresults.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -3,8 +3,6 @@
import main
import joins
-StringType = type('')
-
class SelectResults(object):
IterationClass = dbconnection.Iteration
@@ -76,7 +74,7 @@
desc = True
else:
desc = False
- if isinstance(orderBy, (str, unicode)):
+ if isinstance(orderBy, basestring):
if orderBy in self.sourceClass.sqlmeta.columns:
val = getattr(self.sourceClass.q, self.sourceClass.sqlmeta.columns[orderBy].name)
if desc:
@@ -125,7 +123,7 @@
# None doesn't filter anything, it's just a no-op:
return self
clause = self.clause
- if isinstance(clause, (str, unicode)):
+ if isinstance(clause, basestring):
clause = sqlbuilder.SQLConstant('(%s)' % self.clause)
return self.newClause(sqlbuilder.AND(clause, filter_clause))
@@ -236,7 +234,7 @@
"""
expressions = []
for func_name, attribute in attributes:
- if type(attribute) == StringType:
+ if isinstance(attribute, str):
expression = '%s(%s)' % (func_name, attribute)
else:
expression = getattr(sqlbuilder.func, func_name)(attribute)
Modified: SQLObject/trunk/sqlobject/util/csvexport.py
===================================================================
--- SQLObject/trunk/sqlobject/util/csvexport.py 2007-09-19 20:52:35 UTC (rev 2966)
+++ SQLObject/trunk/sqlobject/util/csvexport.py 2007-09-20 14:40:33 UTC (rev 2967)
@@ -153,7 +153,7 @@
close_zip_when_finished = True
return_when_finished = False
if file:
- if isinstance(file, (str, unicode)):
+ if isinstance(file, basestring):
close_when_finished = True
file = open(file, 'wb')
elif zip:
|
|
From: <sub...@co...> - 2007-09-17 15:59:49
|
Author: phd Date: 2007-09-17 09:59:45 -0600 (Mon, 17 Sep 2007) New Revision: 2945 Modified: SQLObject/docs/News.txt Log: I always forget the trailing 's' in the third person present singular. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-09-17 15:59:30 UTC (rev 2944) +++ SQLObject/docs/News.txt 2007-09-17 15:59:45 UTC (rev 2945) @@ -304,7 +304,7 @@ --------- * Remove 'limit' from SelectResults after setting start/end so .clone() - never see limit again. + never sees limit again. * Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the expression to escape single quotes if the expression is a string. |
|
From: <sub...@co...> - 2007-09-17 15:59:39
|
Author: phd Date: 2007-09-17 09:59:30 -0600 (Mon, 17 Sep 2007) New Revision: 2944 Modified: SQLObject/branches/0.9/docs/News.txt Log: I always forget the trailing 's' in the third person present singular. Modified: SQLObject/branches/0.9/docs/News.txt =================================================================== --- SQLObject/branches/0.9/docs/News.txt 2007-09-17 15:59:20 UTC (rev 2943) +++ SQLObject/branches/0.9/docs/News.txt 2007-09-17 15:59:30 UTC (rev 2944) @@ -267,7 +267,7 @@ --------- * Remove 'limit' from SelectResults after setting start/end so .clone() - never see limit again. + never sees limit again. * Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the expression to escape single quotes if the expression is a string. |
|
From: <sub...@co...> - 2007-09-17 15:59:28
|
Author: phd Date: 2007-09-17 09:59:20 -0600 (Mon, 17 Sep 2007) New Revision: 2943 Modified: SQLObject/branches/0.8/docs/News.txt Log: I always forget the trailing 's' in the third person present singular. Modified: SQLObject/branches/0.8/docs/News.txt =================================================================== --- SQLObject/branches/0.8/docs/News.txt 2007-09-17 15:59:05 UTC (rev 2942) +++ SQLObject/branches/0.8/docs/News.txt 2007-09-17 15:59:20 UTC (rev 2943) @@ -190,7 +190,7 @@ --------- * Remove 'limit' from SelectResults after setting start/end so .clone() - never see limit again. + never sees limit again. * Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the expression to escape single quotes if the expression is a string. |
|
From: <sub...@co...> - 2007-09-17 15:59:16
|
Author: phd Date: 2007-09-17 09:59:05 -0600 (Mon, 17 Sep 2007) New Revision: 2942 Modified: SQLObject/branches/0.7/docs/News.txt Log: I always forget the trailing 's' in the third person present singular. Modified: SQLObject/branches/0.7/docs/News.txt =================================================================== --- SQLObject/branches/0.7/docs/News.txt 2007-09-17 15:23:51 UTC (rev 2941) +++ SQLObject/branches/0.7/docs/News.txt 2007-09-17 15:59:05 UTC (rev 2942) @@ -14,7 +14,7 @@ --------- * Remove 'limit' from SelectResults after setting start/end so .clone() - never see limit again. + never sees limit again. * Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the expression to escape single quotes if the expression is a string. |
|
From: <hu...@pa...> - 2007-09-16 04:00:46
|
Go http://24.15.206.213/ |
|
From: SourceForge.net <no...@so...> - 2007-09-15 15:16:02
|
Bugs item #1768433, was opened at 2007-08-06 14:01 Message generated for change (Comment added) made by novalis_dt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: SQLObject release (specify) Status: Closed Resolution: None Priority: 5 Private: No Submitted By: azav (azav) Assigned to: David Turner (novalis_dt) Summary: Versioning broken in 0.9.1 Initial Comment: The versions table uses the same constraints as the original table, so having for instance a unique column in a table will raise a DuplicateEntryError when a second version with the same name is created. ---------------------------------------------------------------------- >Comment By: David Turner (novalis_dt) Date: 2007-09-15 15:15 Message: Logged In: YES user_id=83137 Originator: NO If you write this patch, please make it optional per-versioned-table. ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-15 15:08 Message: Logged In: YES user_id=83137 Originator: NO I actually think the correct solution is more complex still. Consider a situation where there are employees and jobs, where employee has a foreign key to job. Both are versioned. If we want to look at the historical salary record of an employee, we need to know not just what job they had at time T, but also what the salary of that job was at time T. So ideally, when we version an employee, we ought to link their job to the appropriate version of the job. That would require a bit of work to implement -- although I cannot see any theoretical reason that it is not possible, at least when limited to cases where the user has added the appropriate MultipleJoins. The only problem is if there are cases where this is not the correct behavior. I don't think of any, but I don't know for sure. Look up "ON DELETE". Delete can restrict (as you note) -- but it can also cascade, deleting the older versions that reference the deleted row, or set null. If I'm in a situation where I care about history, I have a deleted column in each table, and never use actual deletes. Ideally, SQLObject would provide support for this. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-15 12:29 Message: Logged In: NO Ahh.. now i see why my first solution only solves half the problem. azav is right in his example with foreign keys... So forth a versioned row holds a foreign key to another table, that constraint is still present. When using a database engine enforcing foreign key constraints a foreign key of an old row cannot be deleted as it might still be referenced with a no delete policy. For this reason rows may be stuck in a table due to old versions of rows from other tables still reference them. A simple solution would be to convert foreign key columns to simple int columns, thereby having no constraints. This way older versions of a table holds no foreign key constraints on other tables. However this may prevent versioned tables from being restored to previous versions so forth the referenced field has been deleted, as this could break a notNone constraint. As i see it the possibilities is to store all foreign key data in the version table too (impractical and possibly impossible), or accept this flaw in the system... Any good ideas? If you can suggest a solution ill gladly post an implementation example. ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 20:59 Message: Logged In: YES user_id=83137 Originator: NO I fixed this in SVN (unless the foreign key thing turns out to be a problem) ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 18:16 Message: Logged In: YES user_id=83137 Originator: NO I think the old versions ought to have the same foreign key constraints. Why does this cause problems? ---------------------------------------------------------------------- Comment By: azav (azav) Date: 2007-09-10 08:43 Message: Logged In: YES user_id=1861531 Originator: YES This only fixes part of the problem. For instance, version tables will still be created with the foreign key constraints of the original table. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-07 20:37 Message: Logged In: NO I stumbled across the same problem. As constraints are directly copied to version tables, each version of a row needs to hold new values in all unique columns. This may not be acceptable to all applications. In order to fix this a minor change can be made to the file /sqlobject/versioning/__init__.py. You merely need to add a few lines. Heres the result from a diff between the original and my changed version: 48c48,51 < columns[column] = defi.__class__(**defi._kw) --- > kwds = dict(defi._kw) > for kw in ["alternateID", "unique"]: > if kw in kwds: del kwds[kw] > columns[column] = defi.__class__(**kwds) I dont know if this is the way the sqlobject authors would do it, but it seems to work. Hopefully it will result in a faster patch :-) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-09-15 15:08:42
|
Bugs item #1768433, was opened at 2007-08-06 14:01 Message generated for change (Comment added) made by novalis_dt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: SQLObject release (specify) Status: Closed Resolution: None Priority: 5 Private: No Submitted By: azav (azav) Assigned to: David Turner (novalis_dt) Summary: Versioning broken in 0.9.1 Initial Comment: The versions table uses the same constraints as the original table, so having for instance a unique column in a table will raise a DuplicateEntryError when a second version with the same name is created. ---------------------------------------------------------------------- >Comment By: David Turner (novalis_dt) Date: 2007-09-15 15:08 Message: Logged In: YES user_id=83137 Originator: NO I actually think the correct solution is more complex still. Consider a situation where there are employees and jobs, where employee has a foreign key to job. Both are versioned. If we want to look at the historical salary record of an employee, we need to know not just what job they had at time T, but also what the salary of that job was at time T. So ideally, when we version an employee, we ought to link their job to the appropriate version of the job. That would require a bit of work to implement -- although I cannot see any theoretical reason that it is not possible, at least when limited to cases where the user has added the appropriate MultipleJoins. The only problem is if there are cases where this is not the correct behavior. I don't think of any, but I don't know for sure. Look up "ON DELETE". Delete can restrict (as you note) -- but it can also cascade, deleting the older versions that reference the deleted row, or set null. If I'm in a situation where I care about history, I have a deleted column in each table, and never use actual deletes. Ideally, SQLObject would provide support for this. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-15 12:29 Message: Logged In: NO Ahh.. now i see why my first solution only solves half the problem. azav is right in his example with foreign keys... So forth a versioned row holds a foreign key to another table, that constraint is still present. When using a database engine enforcing foreign key constraints a foreign key of an old row cannot be deleted as it might still be referenced with a no delete policy. For this reason rows may be stuck in a table due to old versions of rows from other tables still reference them. A simple solution would be to convert foreign key columns to simple int columns, thereby having no constraints. This way older versions of a table holds no foreign key constraints on other tables. However this may prevent versioned tables from being restored to previous versions so forth the referenced field has been deleted, as this could break a notNone constraint. As i see it the possibilities is to store all foreign key data in the version table too (impractical and possibly impossible), or accept this flaw in the system... Any good ideas? If you can suggest a solution ill gladly post an implementation example. ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 20:59 Message: Logged In: YES user_id=83137 Originator: NO I fixed this in SVN (unless the foreign key thing turns out to be a problem) ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 18:16 Message: Logged In: YES user_id=83137 Originator: NO I think the old versions ought to have the same foreign key constraints. Why does this cause problems? ---------------------------------------------------------------------- Comment By: azav (azav) Date: 2007-09-10 08:43 Message: Logged In: YES user_id=1861531 Originator: YES This only fixes part of the problem. For instance, version tables will still be created with the foreign key constraints of the original table. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-07 20:37 Message: Logged In: NO I stumbled across the same problem. As constraints are directly copied to version tables, each version of a row needs to hold new values in all unique columns. This may not be acceptable to all applications. In order to fix this a minor change can be made to the file /sqlobject/versioning/__init__.py. You merely need to add a few lines. Heres the result from a diff between the original and my changed version: 48c48,51 < columns[column] = defi.__class__(**defi._kw) --- > kwds = dict(defi._kw) > for kw in ["alternateID", "unique"]: > if kw in kwds: del kwds[kw] > columns[column] = defi.__class__(**kwds) I dont know if this is the way the sqlobject authors would do it, but it seems to work. Hopefully it will result in a faster patch :-) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-09-15 12:30:04
|
Bugs item #1768433, was opened at 2007-08-06 07:01 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: SQLObject release (specify) Status: Closed Resolution: None Priority: 5 Private: No Submitted By: azav (azav) Assigned to: David Turner (novalis_dt) Summary: Versioning broken in 0.9.1 Initial Comment: The versions table uses the same constraints as the original table, so having for instance a unique column in a table will raise a DuplicateEntryError when a second version with the same name is created. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-15 05:29 Message: Logged In: NO Ahh.. now i see why my first solution only solves half the problem. azav is right in his example with foreign keys... So forth a versioned row holds a foreign key to another table, that constraint is still present. When using a database engine enforcing foreign key constraints a foreign key of an old row cannot be deleted as it might still be referenced with a no delete policy. For this reason rows may be stuck in a table due to old versions of rows from other tables still reference them. A simple solution would be to convert foreign key columns to simple int columns, thereby having no constraints. This way older versions of a table holds no foreign key constraints on other tables. However this may prevent versioned tables from being restored to previous versions so forth the referenced field has been deleted, as this could break a notNone constraint. As i see it the possibilities is to store all foreign key data in the version table too (impractical and possibly impossible), or accept this flaw in the system... Any good ideas? If you can suggest a solution ill gladly post an implementation example. ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 13:59 Message: Logged In: YES user_id=83137 Originator: NO I fixed this in SVN (unless the foreign key thing turns out to be a problem) ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 11:16 Message: Logged In: YES user_id=83137 Originator: NO I think the old versions ought to have the same foreign key constraints. Why does this cause problems? ---------------------------------------------------------------------- Comment By: azav (azav) Date: 2007-09-10 01:43 Message: Logged In: YES user_id=1861531 Originator: YES This only fixes part of the problem. For instance, version tables will still be created with the foreign key constraints of the original table. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-07 13:37 Message: Logged In: NO I stumbled across the same problem. As constraints are directly copied to version tables, each version of a row needs to hold new values in all unique columns. This may not be acceptable to all applications. In order to fix this a minor change can be made to the file /sqlobject/versioning/__init__.py. You merely need to add a few lines. Heres the result from a diff between the original and my changed version: 48c48,51 < columns[column] = defi.__class__(**defi._kw) --- > kwds = dict(defi._kw) > for kw in ["alternateID", "unique"]: > if kw in kwds: del kwds[kw] > columns[column] = defi.__class__(**kwds) I dont know if this is the way the sqlobject authors would do it, but it seems to work. Hopefully it will result in a faster patch :-) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 |
|
From: <sub...@co...> - 2007-09-14 14:44:18
|
Author: phd Date: 2007-09-14 08:44:13 -0600 (Fri, 14 Sep 2007) New Revision: 2916 Modified: SQLObject/docs/News.txt Log: Fixed a bug in Versioning - do not copy "alternateID" and "unique" attributes from the versioned table. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-09-14 14:43:59 UTC (rev 2915) +++ SQLObject/docs/News.txt 2007-09-14 14:44:13 UTC (rev 2916) @@ -53,6 +53,9 @@ SQLObject 0.9.2 =============== +* Fixed a bug in Versioning - do not copy "alternateID" and "unique" + attributes from the versioned table. + * A number of changes ported from `SQLObject 0.7.9`_. SQLObject 0.9.1 |
|
From: <sub...@co...> - 2007-09-14 14:44:11
|
Author: phd
Date: 2007-09-14 08:43:59 -0600 (Fri, 14 Sep 2007)
New Revision: 2915
Modified:
SQLObject/branches/0.9/docs/News.txt
SQLObject/branches/0.9/sqlobject/versioning/__init__.py
SQLObject/branches/0.9/sqlobject/versioning/test/test_version.py
Log:
Fixed a bug in Versioning - do not copy "alternateID" and "unique" attributes from the versioned table.
Modified: SQLObject/branches/0.9/docs/News.txt
===================================================================
--- SQLObject/branches/0.9/docs/News.txt 2007-09-14 14:36:51 UTC (rev 2914)
+++ SQLObject/branches/0.9/docs/News.txt 2007-09-14 14:43:59 UTC (rev 2915)
@@ -10,6 +10,9 @@
SQLObject 0.9.2
===============
+* Fixed a bug in Versioning - do not copy "alternateID" and "unique"
+ attributes from the versioned table.
+
* A number of changes ported from `SQLObject 0.7.9`_.
SQLObject 0.9.1
Modified: SQLObject/branches/0.9/sqlobject/versioning/__init__.py
===================================================================
--- SQLObject/branches/0.9/sqlobject/versioning/__init__.py 2007-09-14 14:36:51 UTC (rev 2914)
+++ SQLObject/branches/0.9/sqlobject/versioning/__init__.py 2007-09-14 14:43:59 UTC (rev 2915)
@@ -45,8 +45,13 @@
for column, defi in cls.sqlmeta.columnDefinitions.items():
if column.endswith("ID") and isinstance(defi, ForeignKey):
column = column[:-2]
- columns[column] = defi.__class__(**defi._kw)
+ #remove incompatible constraints
+ kwds = dict(defi._kw)
+ for kw in ["alternateID", "unique"]:
+ if kw in kwds: del kwds[kw]
+ columns[column] = defi.__class__(**kwds)
+
#ascend heirarchy
if cls.sqlmeta.parentClass:
getColumns(columns, cls.sqlmeta.parentClass)
Modified: SQLObject/branches/0.9/sqlobject/versioning/test/test_version.py
===================================================================
--- SQLObject/branches/0.9/sqlobject/versioning/test/test_version.py 2007-09-14 14:36:51 UTC (rev 2914)
+++ SQLObject/branches/0.9/sqlobject/versioning/test/test_version.py 2007-09-14 14:43:59 UTC (rev 2915)
@@ -45,10 +45,14 @@
class Extra(SQLObject):
name = StringCol()
versions = Versioning(extraCols={'extra' : StringCol(default=_set_extra())})
+class HasAltId(SQLObject):
+ name = StringCol()
+ altid = IntCol(alternateID=True)
+ versions = Versioning()
def setup():
- classes = [MyClass, Base, Child, Government, Monarchy, VChild, Extra]
+ classes = [MyClass, Base, Child, Government, Monarchy, VChild, Extra, HasAltId]
if hasattr(HasForeign, "_connection"):
classes.insert(0, HasForeign)
else:
@@ -159,3 +163,9 @@
extra.name = 'new'
assert extra.versions[0].extra == 'read all about it'
assert sorted(extra.versions[0].getChangedFields()) == ['Name']
+
+def test_altid():
+ setup()
+ extra = HasAltId(name="fleem", altid=5)
+ extra.name = "morx"
+
|
|
From: <sub...@co...> - 2007-09-14 14:36:56
|
Author: phd Date: 2007-09-14 08:36:51 -0600 (Fri, 14 Sep 2007) New Revision: 2914 Modified: SQLObject/docs/News.txt Log: Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the expression to escape single quotes if the expression is a string. Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-09-14 14:36:40 UTC (rev 2913) +++ SQLObject/docs/News.txt 2007-09-14 14:36:51 UTC (rev 2914) @@ -303,6 +303,9 @@ * Remove 'limit' from SelectResults after setting start/end so .clone() never see limit again. +* Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the + expression to escape single quotes if the expression is a string. + Other Changes ------------- |
|
From: <sub...@co...> - 2007-09-14 14:36:44
|
Author: phd
Date: 2007-09-14 08:36:40 -0600 (Fri, 14 Sep 2007)
New Revision: 2913
Modified:
SQLObject/trunk/sqlobject/sqlbuilder.py
SQLObject/trunk/sqlobject/tests/test_select.py
Log:
Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
expression to escape single quotes if the expression is a string.
Modified: SQLObject/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2007-09-14 14:36:28 UTC (rev 2912)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2007-09-14 14:36:40 UTC (rev 2913)
@@ -888,9 +888,11 @@
return "CONCAT(%s)" % ", ".join(values)
else:
return " || ".join(values)
- else: # assuming s is a string
- s = _quote_percent(s, db)
+ elif isinstance(s, (str, unicode)):
+ s = _quote_percent(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
+ else:
+ raise TypeError, "expected str, unicode or SQLExpression, got %s" % type(s)
def _quote_percent(s, db):
if db in ('postgres', 'mysql'):
Modified: SQLObject/trunk/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_select.py 2007-09-14 14:36:28 UTC (rev 2912)
+++ SQLObject/trunk/sqlobject/tests/test_select.py 2007-09-14 14:36:40 UTC (rev 2913)
@@ -85,6 +85,7 @@
assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains(func.lower('A'))))) == 1
+ assert len(list(IterTest.select(IterTest.q.name.contains("a'b")))) == 0
def test_select_getOne():
setupClass(IterTest)
|
|
From: <sub...@co...> - 2007-09-14 14:36:40
|
Author: phd
Date: 2007-09-14 08:36:28 -0600 (Fri, 14 Sep 2007)
New Revision: 2912
Modified:
SQLObject/branches/0.9/docs/News.txt
SQLObject/branches/0.9/sqlobject/sqlbuilder.py
SQLObject/branches/0.9/sqlobject/tests/test_select.py
Log:
Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
expression to escape single quotes if the expression is a string.
Modified: SQLObject/branches/0.9/docs/News.txt
===================================================================
--- SQLObject/branches/0.9/docs/News.txt 2007-09-14 14:36:16 UTC (rev 2911)
+++ SQLObject/branches/0.9/docs/News.txt 2007-09-14 14:36:28 UTC (rev 2912)
@@ -266,6 +266,9 @@
* Remove 'limit' from SelectResults after setting start/end so .clone()
never see limit again.
+* Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
+ expression to escape single quotes if the expression is a string.
+
Other Changes
-------------
Modified: SQLObject/branches/0.9/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.9/sqlobject/sqlbuilder.py 2007-09-14 14:36:16 UTC (rev 2911)
+++ SQLObject/branches/0.9/sqlobject/sqlbuilder.py 2007-09-14 14:36:28 UTC (rev 2912)
@@ -723,9 +723,11 @@
return "CONCAT(%s)" % ", ".join(values)
else:
return " || ".join(values)
- else: # assuming s is a string
- s = _quote_percent(s, db)
+ elif isinstance(s, (str, unicode)):
+ s = _quote_percent(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
+ else:
+ raise TypeError, "expected str, unicode or SQLExpression, got %s" % type(s)
def _quote_percent(s, db):
if db in ('postgres', 'mysql'):
Modified: SQLObject/branches/0.9/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.9/sqlobject/tests/test_select.py 2007-09-14 14:36:16 UTC (rev 2911)
+++ SQLObject/branches/0.9/sqlobject/tests/test_select.py 2007-09-14 14:36:28 UTC (rev 2912)
@@ -85,6 +85,7 @@
assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains(func.lower('A'))))) == 1
+ assert len(list(IterTest.select(IterTest.q.name.contains("a'b")))) == 0
def test_select_getOne():
setupClass(IterTest)
|
|
From: <sub...@co...> - 2007-09-14 14:36:24
|
Author: phd
Date: 2007-09-14 08:36:16 -0600 (Fri, 14 Sep 2007)
New Revision: 2911
Modified:
SQLObject/branches/0.8/docs/News.txt
SQLObject/branches/0.8/sqlobject/sqlbuilder.py
SQLObject/branches/0.8/sqlobject/tests/test_select.py
Log:
Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
expression to escape single quotes if the expression is a string.
Modified: SQLObject/branches/0.8/docs/News.txt
===================================================================
--- SQLObject/branches/0.8/docs/News.txt 2007-09-14 14:36:00 UTC (rev 2910)
+++ SQLObject/branches/0.8/docs/News.txt 2007-09-14 14:36:16 UTC (rev 2911)
@@ -192,6 +192,9 @@
* Remove 'limit' from SelectResults after setting start/end so .clone()
never see limit again.
+* Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
+ expression to escape single quotes if the expression is a string.
+
Other Changes
-------------
Modified: SQLObject/branches/0.8/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/sqlbuilder.py 2007-09-14 14:36:00 UTC (rev 2910)
+++ SQLObject/branches/0.8/sqlobject/sqlbuilder.py 2007-09-14 14:36:16 UTC (rev 2911)
@@ -721,9 +721,11 @@
return "CONCAT(%s)" % ", ".join(values)
else:
return " || ".join(values)
- else: # assuming s is a string
- s = _quote_percent(s, db)
+ elif isinstance(s, (str, unicode)):
+ s = _quote_percent(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
+ else:
+ raise TypeError, "expected str, unicode or SQLExpression, got %s" % type(s)
def _quote_percent(s, db):
if db in ('postgres', 'mysql'):
Modified: SQLObject/branches/0.8/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/tests/test_select.py 2007-09-14 14:36:00 UTC (rev 2910)
+++ SQLObject/branches/0.8/sqlobject/tests/test_select.py 2007-09-14 14:36:16 UTC (rev 2911)
@@ -85,6 +85,7 @@
assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains(func.lower('A'))))) == 1
+ assert len(list(IterTest.select(IterTest.q.name.contains("a'b")))) == 0
def test_select_getOne():
setupClass(IterTest)
|
|
From: <sub...@co...> - 2007-09-14 14:36:11
|
Author: phd
Date: 2007-09-14 08:36:00 -0600 (Fri, 14 Sep 2007)
New Revision: 2910
Modified:
SQLObject/branches/0.7/docs/News.txt
SQLObject/branches/0.7/sqlobject/sqlbuilder.py
SQLObject/branches/0.7/sqlobject/tests/test_select.py
Log:
Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
expression to escape single quotes if the expression is a string.
Modified: SQLObject/branches/0.7/docs/News.txt
===================================================================
--- SQLObject/branches/0.7/docs/News.txt 2007-09-10 20:58:57 UTC (rev 2909)
+++ SQLObject/branches/0.7/docs/News.txt 2007-09-14 14:36:00 UTC (rev 2910)
@@ -16,6 +16,9 @@
* Remove 'limit' from SelectResults after setting start/end so .clone()
never see limit again.
+* Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
+ expression to escape single quotes if the expression is a string.
+
Other Changes
-------------
Modified: SQLObject/branches/0.7/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.7/sqlobject/sqlbuilder.py 2007-09-10 20:58:57 UTC (rev 2909)
+++ SQLObject/branches/0.7/sqlobject/sqlbuilder.py 2007-09-14 14:36:00 UTC (rev 2910)
@@ -714,9 +714,11 @@
return "CONCAT(%s)" % ", ".join(values)
else:
return " || ".join(values)
- else: # assuming s is a string
- s = _quote_percent(s, db)
+ elif isinstance(s, (str, unicode)):
+ s = _quote_percent(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
+ else:
+ raise TypeError, "expected str, unicode or SQLExpression, got %s" % type(s)
def _quote_percent(s, db):
if db in ('postgres', 'mysql'):
Modified: SQLObject/branches/0.7/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.7/sqlobject/tests/test_select.py 2007-09-10 20:58:57 UTC (rev 2909)
+++ SQLObject/branches/0.7/sqlobject/tests/test_select.py 2007-09-14 14:36:00 UTC (rev 2910)
@@ -83,6 +83,7 @@
assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains(func.lower('A'))))) == 1
+ assert len(list(IterTest.select(IterTest.q.name.contains("a'b")))) == 0
def test_selectBy():
setupClass(IterTest)
|
|
From: Sqlobject-c. <gui...@ho...> - 2007-09-13 01:38:16
|
Want your watch to be as good as those of the guys from Hollywood? Take a look at our huge collection of high-quality replica timepieces! Top-notch watches at rock-bottom prices – that’s worth seeing! http://Rufus.placepharmacyarea.com |
|
From: SourceForge.net <no...@so...> - 2007-09-11 13:46:17
|
Bugs item #1768433, was opened at 2007-08-06 14:01 Message generated for change (Settings changed) made by novalis_dt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: SQLObject release (specify) >Status: Closed Resolution: None Priority: 5 Private: No Submitted By: azav (azav) Assigned to: David Turner (novalis_dt) Summary: Versioning broken in 0.9.1 Initial Comment: The versions table uses the same constraints as the original table, so having for instance a unique column in a table will raise a DuplicateEntryError when a second version with the same name is created. ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 20:59 Message: Logged In: YES user_id=83137 Originator: NO I fixed this in SVN (unless the foreign key thing turns out to be a problem) ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 18:16 Message: Logged In: YES user_id=83137 Originator: NO I think the old versions ought to have the same foreign key constraints. Why does this cause problems? ---------------------------------------------------------------------- Comment By: azav (azav) Date: 2007-09-10 08:43 Message: Logged In: YES user_id=1861531 Originator: YES This only fixes part of the problem. For instance, version tables will still be created with the foreign key constraints of the original table. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-07 20:37 Message: Logged In: NO I stumbled across the same problem. As constraints are directly copied to version tables, each version of a row needs to hold new values in all unique columns. This may not be acceptable to all applications. In order to fix this a minor change can be made to the file /sqlobject/versioning/__init__.py. You merely need to add a few lines. Heres the result from a diff between the original and my changed version: 48c48,51 < columns[column] = defi.__class__(**defi._kw) --- > kwds = dict(defi._kw) > for kw in ["alternateID", "unique"]: > if kw in kwds: del kwds[kw] > columns[column] = defi.__class__(**kwds) I dont know if this is the way the sqlobject authors would do it, but it seems to work. Hopefully it will result in a faster patch :-) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-09-11 10:55:19
|
Bugs item #1702246, was opened at 2007-04-17 18:17 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1702246&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: David Turner (novalis_dt) >Assigned to: David Turner (novalis_dt) Summary: Version tables not dropped when parent tables dropped Initial Comment: When a table is deleted, its version table should also be deleted. I'll probably fix this, but not right now. I just wanted to submit a bug so that people would know it was a known issue. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1702246&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-09-11 10:55:09
|
Bugs item #1768433, was opened at 2007-08-06 18:01 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Private: No Submitted By: azav (azav) >Assigned to: David Turner (novalis_dt) Summary: Versioning broken in 0.9.1 Initial Comment: The versions table uses the same constraints as the original table, so having for instance a unique column in a table will raise a DuplicateEntryError when a second version with the same name is created. ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-11 00:59 Message: Logged In: YES user_id=83137 Originator: NO I fixed this in SVN (unless the foreign key thing turns out to be a problem) ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 22:16 Message: Logged In: YES user_id=83137 Originator: NO I think the old versions ought to have the same foreign key constraints. Why does this cause problems? ---------------------------------------------------------------------- Comment By: azav (azav) Date: 2007-09-10 12:43 Message: Logged In: YES user_id=1861531 Originator: YES This only fixes part of the problem. For instance, version tables will still be created with the foreign key constraints of the original table. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-08 00:37 Message: Logged In: NO I stumbled across the same problem. As constraints are directly copied to version tables, each version of a row needs to hold new values in all unique columns. This may not be acceptable to all applications. In order to fix this a minor change can be made to the file /sqlobject/versioning/__init__.py. You merely need to add a few lines. Heres the result from a diff between the original and my changed version: 48c48,51 < columns[column] = defi.__class__(**defi._kw) --- > kwds = dict(defi._kw) > for kw in ["alternateID", "unique"]: > if kw in kwds: del kwds[kw] > columns[column] = defi.__class__(**kwds) I dont know if this is the way the sqlobject authors would do it, but it seems to work. Hopefully it will result in a faster patch :-) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 |
|
From: Marsha R. <bra...@Ya...> - 2007-09-11 10:00:59
|
If you have your own business and wish IMMEDIATE ready money to spend = ANY way you like or wish Extra money to give your company a boost or = wish A low interest loan - NO STRINGS ATTACHED, here is our deal we can = offer you THIS NIGHT (hurry, this offer will expire THIS NIGHT): $47,000+ loan Hurry, when the deal is gone, it is gone. Simply Call Us Free on=20 877-503-8916 |
|
From: SourceForge.net <no...@so...> - 2007-09-10 20:59:30
|
Bugs item #1768433, was opened at 2007-08-06 14:01 Message generated for change (Comment added) made by novalis_dt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Private: No Submitted By: azav (azav) Assigned to: Nobody/Anonymous (nobody) Summary: Versioning broken in 0.9.1 Initial Comment: The versions table uses the same constraints as the original table, so having for instance a unique column in a table will raise a DuplicateEntryError when a second version with the same name is created. ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 20:59 Message: Logged In: YES user_id=83137 Originator: NO I fixed this in SVN (unless the foreign key thing turns out to be a problem) ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 18:16 Message: Logged In: YES user_id=83137 Originator: NO I think the old versions ought to have the same foreign key constraints. Why does this cause problems? ---------------------------------------------------------------------- Comment By: azav (azav) Date: 2007-09-10 08:43 Message: Logged In: YES user_id=1861531 Originator: YES This only fixes part of the problem. For instance, version tables will still be created with the foreign key constraints of the original table. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-07 20:37 Message: Logged In: NO I stumbled across the same problem. As constraints are directly copied to version tables, each version of a row needs to hold new values in all unique columns. This may not be acceptable to all applications. In order to fix this a minor change can be made to the file /sqlobject/versioning/__init__.py. You merely need to add a few lines. Heres the result from a diff between the original and my changed version: 48c48,51 < columns[column] = defi.__class__(**defi._kw) --- > kwds = dict(defi._kw) > for kw in ["alternateID", "unique"]: > if kw in kwds: del kwds[kw] > columns[column] = defi.__class__(**kwds) I dont know if this is the way the sqlobject authors would do it, but it seems to work. Hopefully it will result in a faster patch :-) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 |
|
From: <sub...@co...> - 2007-09-10 20:59:05
|
Author: novalis
Date: 2007-09-10 14:58:57 -0600 (Mon, 10 Sep 2007)
New Revision: 2909
Modified:
SQLObject/trunk/sqlobject/versioning/__init__.py
SQLObject/trunk/sqlobject/versioning/test/test_version.py
Log:
versioning now works with constraints like unique
Modified: SQLObject/trunk/sqlobject/versioning/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/__init__.py 2007-09-10 17:38:23 UTC (rev 2908)
+++ SQLObject/trunk/sqlobject/versioning/__init__.py 2007-09-10 20:58:57 UTC (rev 2909)
@@ -45,8 +45,13 @@
for column, defi in cls.sqlmeta.columnDefinitions.items():
if column.endswith("ID") and isinstance(defi, ForeignKey):
column = column[:-2]
- columns[column] = defi.__class__(**defi._kw)
+ #remove incompatible constraints
+ kwds = dict(defi._kw)
+ for kw in ["alternateID", "unique"]:
+ if kw in kwds: del kwds[kw]
+ columns[column] = defi.__class__(**kwds)
+
#ascend heirarchy
if cls.sqlmeta.parentClass:
getColumns(columns, cls.sqlmeta.parentClass)
Modified: SQLObject/trunk/sqlobject/versioning/test/test_version.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-09-10 17:38:23 UTC (rev 2908)
+++ SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-09-10 20:58:57 UTC (rev 2909)
@@ -43,10 +43,14 @@
class Extra(SQLObject):
name = StringCol()
versions = Versioning(extraCols={'extra' : StringCol(default=_set_extra())})
+class HasAltId(SQLObject):
+ name = StringCol()
+ altid = IntCol(alternateID=True)
+ versions = Versioning()
def setup():
- classes = [MyClass, Base, Child, Government, Monarchy, VChild, Extra]
+ classes = [MyClass, Base, Child, Government, Monarchy, VChild, Extra, HasAltId]
if hasattr(HasForeign, "_connection"):
classes.insert(0, HasForeign)
else:
@@ -157,3 +161,9 @@
extra.name = 'new'
assert extra.versions[0].extra == 'read all about it'
assert sorted(extra.versions[0].getChangedFields()) == ['Name']
+
+def test_altid():
+ setup()
+ extra = HasAltId(name="fleem", altid=5)
+ extra.name = "morx"
+
|
|
From: SourceForge.net <no...@so...> - 2007-09-10 18:16:38
|
Bugs item #1768433, was opened at 2007-08-06 14:01 Message generated for change (Comment added) made by novalis_dt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Private: No Submitted By: azav (azav) Assigned to: Nobody/Anonymous (nobody) Summary: Versioning broken in 0.9.1 Initial Comment: The versions table uses the same constraints as the original table, so having for instance a unique column in a table will raise a DuplicateEntryError when a second version with the same name is created. ---------------------------------------------------------------------- Comment By: David Turner (novalis_dt) Date: 2007-09-10 18:16 Message: Logged In: YES user_id=83137 Originator: NO I think the old versions ought to have the same foreign key constraints. Why does this cause problems? ---------------------------------------------------------------------- Comment By: azav (azav) Date: 2007-09-10 08:43 Message: Logged In: YES user_id=1861531 Originator: YES This only fixes part of the problem. For instance, version tables will still be created with the foreign key constraints of the original table. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-09-07 20:37 Message: Logged In: NO I stumbled across the same problem. As constraints are directly copied to version tables, each version of a row needs to hold new values in all unique columns. This may not be acceptable to all applications. In order to fix this a minor change can be made to the file /sqlobject/versioning/__init__.py. You merely need to add a few lines. Heres the result from a diff between the original and my changed version: 48c48,51 < columns[column] = defi.__class__(**defi._kw) --- > kwds = dict(defi._kw) > for kw in ["alternateID", "unique"]: > if kw in kwds: del kwds[kw] > columns[column] = defi.__class__(**kwds) I dont know if this is the way the sqlobject authors would do it, but it seems to work. Hopefully it will result in a faster patch :-) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1768433&group_id=74338 |