fixed issue 1598:Add SQLite to supported database stored migrations, thanks Alan (also reverted virtualfields that break tests)
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.6.0-development+timestamp.2013.07.19.17.41.29
|
Version 2.6.0-development+timestamp.2013.07.20.12.53.53
|
||||||
|
|||||||
+14
-13
@@ -1540,7 +1540,6 @@ class BaseAdapter(ConnectionPool):
|
|||||||
args_get = attributes.get
|
args_get = attributes.get
|
||||||
tablenames = tables(query)
|
tablenames = tables(query)
|
||||||
tablenames_for_common_filters = tablenames
|
tablenames_for_common_filters = tablenames
|
||||||
fields = [f for f in fields if not isinstance(f,Field.Virtual)] # skip virtual fields
|
|
||||||
for field in fields:
|
for field in fields:
|
||||||
if isinstance(field, basestring) \
|
if isinstance(field, basestring) \
|
||||||
and REGEX_TABLE_DOT_FIELD.match(field):
|
and REGEX_TABLE_DOT_FIELD.match(field):
|
||||||
@@ -2111,18 +2110,20 @@ class BaseAdapter(ConnectionPool):
|
|||||||
new_rows.append(new_row)
|
new_rows.append(new_row)
|
||||||
rowsobj = Rows(db, new_rows, colnames, rawrows=rows)
|
rowsobj = Rows(db, new_rows, colnames, rawrows=rows)
|
||||||
|
|
||||||
|
|
||||||
for tablename in virtualtables:
|
for tablename in virtualtables:
|
||||||
table = db[tablename]
|
table = db[tablename]
|
||||||
all_fields = filter(lambda nv: nv[1] in fields and
|
fields_virtual = [(f,v) for (f,v) in table.iteritems()
|
||||||
isinstance(nv[1],(FieldVirtual,FieldMethod)),
|
if isinstance(v,FieldVirtual)]
|
||||||
table.iteritems())
|
fields_lazy = [(f,v) for (f,v) in table.iteritems()
|
||||||
if all_fields:
|
if isinstance(v,FieldMethod)]
|
||||||
|
if fields_virtual or fields_lazy:
|
||||||
for row in rowsobj.records:
|
for row in rowsobj.records:
|
||||||
box = row[tablename] # CHECK THIS
|
box = row[tablename]
|
||||||
for fieldname,field in all_fields:
|
for f,v in fields_virtual:
|
||||||
box[fieldname] = field.f(row) \
|
box[f] = v.f(row)
|
||||||
if isinstance(field,FieldVirtual) else \
|
for f,v in fields_lazy:
|
||||||
(field.handler or VirtualCommand)(field.f,row)
|
box[f] = (v.handler or VirtualCommand)(v.f,row)
|
||||||
|
|
||||||
### old style virtual fields
|
### old style virtual fields
|
||||||
for item in table.virtualfields:
|
for item in table.virtualfields:
|
||||||
@@ -4245,15 +4246,15 @@ class DatabaseStoredFile:
|
|||||||
return self.db._adapter.escape(obj)
|
return self.db._adapter.escape(obj)
|
||||||
|
|
||||||
def __init__(self,db,filename,mode):
|
def __init__(self,db,filename,mode):
|
||||||
if not db._adapter.dbengine in ('mysql', 'postgres'):
|
if not db._adapter.dbengine in ('mysql', 'postgres', 'sqlite'):
|
||||||
raise RuntimeError("only MySQL/Postgres can store metadata .table files in database for now")
|
raise RuntimeError("only MySQL/Postgres/SQLite can store metadata .table files in database for now")
|
||||||
self.db = db
|
self.db = db
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
if not self.web2py_filesystem:
|
if not self.web2py_filesystem:
|
||||||
if db._adapter.dbengine == 'mysql':
|
if db._adapter.dbengine == 'mysql':
|
||||||
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;"
|
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;"
|
||||||
elif db._adapter.dbengine == 'postgres':
|
elif db._adapter.dbengine in ('postgres', 'sqlite'):
|
||||||
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY KEY(path));"
|
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content TEXT, PRIMARY KEY(path));"
|
||||||
self.db.executesql(sql)
|
self.db.executesql(sql)
|
||||||
DatabaseStoredFile.web2py_filesystem = True
|
DatabaseStoredFile.web2py_filesystem = True
|
||||||
|
|||||||
Reference in New Issue
Block a user