removed unwanted whitespaces
This commit is contained in:
+44
-43
@@ -91,7 +91,7 @@ Example of usage:
|
||||
>>> person.drop()
|
||||
|
||||
Supported field types:
|
||||
id string text boolean integer double decimal password upload
|
||||
id string text boolean integer double decimal password upload
|
||||
blob time date datetime
|
||||
|
||||
Supported DAL URI strings:
|
||||
@@ -507,7 +507,7 @@ class ConnectionPool(object):
|
||||
|
||||
def pool_connection(self, f, cursor=True):
|
||||
"""
|
||||
this function defines: self.connection and self.cursor
|
||||
this function defines: self.connection and self.cursor
|
||||
(iff cursor is True)
|
||||
if self.pool_size>0 it will try pull the connection from the pool
|
||||
if the connection is not active (closed by db server) it will loop
|
||||
@@ -691,7 +691,7 @@ class BaseAdapter(ConnectionPool):
|
||||
# make a guess here for circular references
|
||||
id_fieldname = referenced in table._db \
|
||||
and table._db[referenced]._id.name or 'id'
|
||||
ftype = self.types[field.type[:9]] % dict(
|
||||
ftype = self.types[field.type[:9]] % dict(
|
||||
index_name = field.name+'__idx',
|
||||
field_name = field.name,
|
||||
constraint_name = constraint_name,
|
||||
@@ -749,11 +749,11 @@ class BaseAdapter(ConnectionPool):
|
||||
sql=ftype)
|
||||
|
||||
if isinstance(field.default,(str,int,float)):
|
||||
# Caveat: sql_fields and sql_fields_aux
|
||||
# Caveat: sql_fields and sql_fields_aux
|
||||
# differ for default values.
|
||||
# sql_fields is used to trigger migrations and sql_fields_aux
|
||||
# is used for create tables.
|
||||
# The reason is that we do not want to trigger
|
||||
# The reason is that we do not want to trigger
|
||||
# a migration simply because a default value changes.
|
||||
not_null = self.NOT_NULL(field.default, field.type)
|
||||
ftype = ftype.replace('NOT NULL', not_null)
|
||||
@@ -785,7 +785,7 @@ class BaseAdapter(ConnectionPool):
|
||||
|
||||
if hasattr(table,'_primarykey'):
|
||||
query = "CREATE TABLE %s(\n %s,\n %s) %s" % \
|
||||
(tablename, fields,
|
||||
(tablename, fields,
|
||||
self.PRIMARY_KEY(', '.join(table._primarykey)),other)
|
||||
else:
|
||||
query = "CREATE TABLE %s(\n %s\n)%s" % \
|
||||
@@ -823,7 +823,7 @@ class BaseAdapter(ConnectionPool):
|
||||
if not fake_migrate:
|
||||
self.create_sequence_and_triggers(query,table)
|
||||
table._db.commit()
|
||||
# Postgres geom fields are added now,
|
||||
# Postgres geom fields are added now,
|
||||
# after the table has been created
|
||||
for query in postcreation_fields:
|
||||
self.execute(query)
|
||||
@@ -911,7 +911,7 @@ class BaseAdapter(ConnectionPool):
|
||||
schema = parms.split(',')[0]
|
||||
query = [ "SELECT DropGeometryColumn ('%(schema)s', '%(table)s', '%(field)s');" % dict(schema=schema, table=tablename, field=key,) ]
|
||||
elif not self.dbengine in ('firebird',):
|
||||
query = ['ALTER TABLE %s DROP COLUMN %s;'
|
||||
query = ['ALTER TABLE %s DROP COLUMN %s;'
|
||||
% (tablename, key)]
|
||||
else:
|
||||
query = ['ALTER TABLE %s DROP %s;' % (tablename, key)]
|
||||
@@ -1097,11 +1097,11 @@ class BaseAdapter(ConnectionPool):
|
||||
self.expand(second, 'string'))
|
||||
|
||||
def STARTSWITH(self, first, second):
|
||||
return '(%s LIKE %s)' % (self.expand(first),
|
||||
return '(%s LIKE %s)' % (self.expand(first),
|
||||
self.expand(second+'%', 'string'))
|
||||
|
||||
def ENDSWITH(self, first, second):
|
||||
return '(%s LIKE %s)' % (self.expand(first),
|
||||
return '(%s LIKE %s)' % (self.expand(first),
|
||||
self.expand('%'+second, 'string'))
|
||||
|
||||
def CONTAINS(self, first, second):
|
||||
@@ -1114,13 +1114,13 @@ class BaseAdapter(ConnectionPool):
|
||||
def EQ(self, first, second=None):
|
||||
if second is None:
|
||||
return '(%s IS NULL)' % self.expand(first)
|
||||
return '(%s = %s)' % (self.expand(first),
|
||||
return '(%s = %s)' % (self.expand(first),
|
||||
self.expand(second, first.type))
|
||||
|
||||
def NE(self, first, second=None):
|
||||
if second is None:
|
||||
return '(%s IS NOT NULL)' % self.expand(first)
|
||||
return '(%s <> %s)' % (self.expand(first),
|
||||
return '(%s <> %s)' % (self.expand(first),
|
||||
self.expand(second, first.type))
|
||||
|
||||
def LT(self,first,second=None):
|
||||
@@ -1156,7 +1156,7 @@ class BaseAdapter(ConnectionPool):
|
||||
self.expand(second, first.type))
|
||||
|
||||
def MUL(self, first, second):
|
||||
return '(%s * %s)' % (self.expand(first),
|
||||
return '(%s * %s)' % (self.expand(first),
|
||||
self.expand(second, first.type))
|
||||
|
||||
def DIV(self, first, second):
|
||||
@@ -1179,7 +1179,7 @@ class BaseAdapter(ConnectionPool):
|
||||
def COMMA(self, first, second):
|
||||
return '%s, %s' % (self.expand(first), self.expand(second))
|
||||
|
||||
def expand(self, expression, field_type=None):
|
||||
def expand(self, expression, field_type=None):
|
||||
if isinstance(expression, Field):
|
||||
return '%s.%s' % (expression.tablename, expression.name)
|
||||
elif isinstance(expression, (Expression, Query)):
|
||||
@@ -1375,24 +1375,24 @@ class BaseAdapter(ConnectionPool):
|
||||
icommand = self.JOIN()
|
||||
if not isinstance(inner_join, (tuple, list)):
|
||||
inner_join = [inner_join]
|
||||
ijoint = [t._tablename for t in inner_join
|
||||
ijoint = [t._tablename for t in inner_join
|
||||
if not isinstance(t,Expression)]
|
||||
ijoinon = [t for t in inner_join if isinstance(t, Expression)]
|
||||
itables_to_merge={} #issue 490
|
||||
[itables_to_merge.update(
|
||||
dict.fromkeys(self.tables(t))) for t in ijoinon]
|
||||
ijoinont = [t.first._tablename for t in ijoinon]
|
||||
[itables_to_merge.pop(t) for t in ijoinont
|
||||
[itables_to_merge.pop(t) for t in ijoinont
|
||||
if t in itables_to_merge] #issue 490
|
||||
iimportant_tablenames = ijoint + ijoinont + itables_to_merge.keys()
|
||||
iexcluded = [t for t in tablenames
|
||||
iexcluded = [t for t in tablenames
|
||||
if not t in iimportant_tablenames]
|
||||
if left:
|
||||
join = attributes['left']
|
||||
command = self.LEFT_JOIN()
|
||||
if not isinstance(join, (tuple, list)):
|
||||
join = [join]
|
||||
joint = [t._tablename for t in join
|
||||
joint = [t._tablename for t in join
|
||||
if not isinstance(t, Expression)]
|
||||
joinon = [t for t in join if isinstance(t, Expression)]
|
||||
#patch join+left patch (solves problem with ordering in left joins)
|
||||
@@ -1402,7 +1402,7 @@ class BaseAdapter(ConnectionPool):
|
||||
joinont = [t.first._tablename for t in joinon]
|
||||
[tables_to_merge.pop(t) for t in joinont if t in tables_to_merge]
|
||||
important_tablenames = joint + joinont + tables_to_merge.keys()
|
||||
excluded = [t for t in tablenames
|
||||
excluded = [t for t in tablenames
|
||||
if not t in important_tablenames ]
|
||||
def alias(t):
|
||||
return str(self.db[t])
|
||||
@@ -1809,10 +1809,10 @@ class BaseAdapter(ConnectionPool):
|
||||
else:
|
||||
id = value
|
||||
colset.update_record = (
|
||||
lambda _ = (colset, table, id), **a:
|
||||
lambda _ = (colset, table, id), **a:
|
||||
update_record(_, a))
|
||||
colset.delete_record = (
|
||||
lambda t = table, i = id:
|
||||
lambda t = table, i = id:
|
||||
t._db(t._id==i).delete())
|
||||
for (referee_table, referee_name) in table._referenced_by:
|
||||
s = db[referee_table][referee_name]
|
||||
@@ -1826,9 +1826,9 @@ class BaseAdapter(ConnectionPool):
|
||||
for tablename in virtualtables:
|
||||
### new style virtual fields
|
||||
table = db[tablename]
|
||||
fields_virtual = [(f,v) for (f,v) in table.items()
|
||||
fields_virtual = [(f,v) for (f,v) in table.items()
|
||||
if isinstance(v,FieldVirtual)]
|
||||
fields_lazy = [(f,v) for (f,v) in table.items()
|
||||
fields_lazy = [(f,v) for (f,v) in table.items()
|
||||
if isinstance(v,FieldLazy)]
|
||||
if fields_virtual or fields_lazy:
|
||||
for row in rowsobj.records:
|
||||
@@ -2101,7 +2101,7 @@ class JDBCSQLiteAdapter(SQLiteAdapter):
|
||||
|
||||
def after_connection(self):
|
||||
# FIXME http://www.zentus.com/sqlitejdbc/custom_functions.html for UDFs
|
||||
self.connection.create_function('web2py_extract', 2,
|
||||
self.connection.create_function('web2py_extract', 2,
|
||||
SQLiteAdapter.web2py_extract)
|
||||
|
||||
def execute(self, a):
|
||||
@@ -2257,7 +2257,7 @@ class PostgreSQLAdapter(BaseAdapter):
|
||||
|
||||
def adapt(self,obj):
|
||||
#if self.driver == self.drivers.get('pg8000'):
|
||||
# obj = str(obj).replace('%','%%')
|
||||
# obj = str(obj).replace('%','%%')
|
||||
return psycopg2_adapt(obj).getquoted()
|
||||
|
||||
def sequence_name(self,table):
|
||||
@@ -2519,7 +2519,7 @@ class NewPostgreSQLAdapter(PostgreSQLAdapter):
|
||||
if fieldtype.startswith('list:string'):
|
||||
obj = [str(item) for item in obj]
|
||||
else:
|
||||
obj = [int(item) for item in obj]
|
||||
obj = [int(item) for item in obj]
|
||||
return 'ARRAY[%s]' % ','.join(repr(item) for item in obj)
|
||||
return BaseAdapter.represent(self, obj, fieldtype)
|
||||
|
||||
@@ -4100,7 +4100,7 @@ class GoogleDatastoreAdapter(NoSQLAdapter):
|
||||
|
||||
def parse_id(self, value, field_type):
|
||||
return value
|
||||
|
||||
|
||||
def create_table(self,table,migrate=True,fake_migrate=False, polymodel=None):
|
||||
myfields = {}
|
||||
for k in table.fields:
|
||||
@@ -4300,7 +4300,7 @@ class GoogleDatastoreAdapter(NoSQLAdapter):
|
||||
if isinstance(attributes.get('reusecursor'), str):
|
||||
cursor = attributes.get('reusecursor')
|
||||
items = gae.Query(tableobj, projection=query_projection, cursor=cursor)
|
||||
|
||||
|
||||
for filter in filters:
|
||||
if attributes.get('projection') == True and \
|
||||
filter.name in query_projection and \
|
||||
@@ -4375,7 +4375,7 @@ class GoogleDatastoreAdapter(NoSQLAdapter):
|
||||
requests, and the filters must be identical. It is up to the user
|
||||
to follow google's limitations: https://developers.google.com/appengine/docs/python/datastore/queries#Query_Cursors
|
||||
"""
|
||||
|
||||
|
||||
(items, tablename, fields) = self.select_raw(query,fields,attributes)
|
||||
# self.db['_lastsql'] = self._select(query,fields,attributes)
|
||||
rows = [[(t==self.db[tablename]._id.name and item) or \
|
||||
@@ -5266,7 +5266,7 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
|
||||
.define_tables() returns a dictionary mapping dal tablenames
|
||||
to the server mailbox names with the following structure:
|
||||
|
||||
|
||||
{<tablename>: str <server mailbox name>}
|
||||
|
||||
Here is a list of supported fields:
|
||||
@@ -5434,7 +5434,7 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
self.imap4 = self.driver.IMAP4
|
||||
connection = self.imap4(driver_args["host"], driver_args["port"])
|
||||
data = connection.login(driver_args["user"], driver_args["password"])
|
||||
|
||||
|
||||
# static mailbox list
|
||||
connection.mailbox_names = None
|
||||
|
||||
@@ -5649,7 +5649,7 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
Field("email", "string", writable=False, readable=False),
|
||||
Field("attachments", "list:string", writable=False, readable=False),
|
||||
)
|
||||
|
||||
|
||||
return self.connection.mailbox_names
|
||||
|
||||
def create_table(self, *args, **kwargs):
|
||||
@@ -5893,7 +5893,7 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
self.connection.mailbox_names[tablename])
|
||||
string_query = "(%s)" % query
|
||||
result, data = self.connection.search(None, string_query)
|
||||
store_list = [item.strip() for item in data[0].split()
|
||||
store_list = [item.strip() for item in data[0].split()
|
||||
if item.strip().isdigit()]
|
||||
# change marked flags
|
||||
for number in store_list:
|
||||
@@ -6346,7 +6346,7 @@ copy_reg.pickle(Row, Row_pickler, Row_unpickler)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Everything below should be independent of the specifics of the database
|
||||
# Everything below should be independent of the specifics of the database
|
||||
# and should work for RDBMs and some NoSQL databases
|
||||
################################################################################
|
||||
|
||||
@@ -6440,7 +6440,7 @@ def smart_query(fields,text):
|
||||
value = constants[item[1:]]
|
||||
else:
|
||||
value = item
|
||||
if field.type in ('text','string'):
|
||||
if field.type in ('text','string'):
|
||||
if op == '=': op = 'like'
|
||||
if op == '=': new_query = field==value
|
||||
elif op == '<': new_query = field<value
|
||||
@@ -7324,7 +7324,7 @@ class Table(dict):
|
||||
archive_name = archive_name % dict(tablename=self._tablename)
|
||||
if archive_name in archive_db.tables():
|
||||
return # do not try define the archive if already exists
|
||||
fieldnames = self.fields()
|
||||
fieldnames = self.fields()
|
||||
field_type = self if archive_db is self._db else 'bigint'
|
||||
archive_table = archive_db.define_table(
|
||||
archive_name,
|
||||
@@ -7607,18 +7607,18 @@ class Table(dict):
|
||||
*args, **kwargs
|
||||
):
|
||||
"""
|
||||
Import records from csv file.
|
||||
Column headers must have same names as table fields.
|
||||
Import records from csv file.
|
||||
Column headers must have same names as table fields.
|
||||
Field 'id' is ignored.
|
||||
If column names read 'table.file' the 'table.' prefix is ignored.
|
||||
'unique' argument is a field which must be unique
|
||||
'unique' argument is a field which must be unique
|
||||
(typically a uuid field)
|
||||
'restore' argument is default False;
|
||||
if set True will remove old values in table first.
|
||||
'id_map' ff set to None will not map ids.
|
||||
The import will keep the id numbers in the restored table.
|
||||
The import will keep the id numbers in the restored table.
|
||||
This assumes that there is an field of type id that
|
||||
is integer and in incrementing order.
|
||||
is integer and in incrementing order.
|
||||
Will keep the id numbers in restored table.
|
||||
"""
|
||||
|
||||
@@ -7703,7 +7703,7 @@ class Table(dict):
|
||||
curr_id = self.insert(**dict(items))
|
||||
if first:
|
||||
first = False
|
||||
# First curr_id is bigger than csv_id,
|
||||
# First curr_id is bigger than csv_id,
|
||||
# then we are not restoring but
|
||||
# extending db table with csv db table
|
||||
if curr_id>csv_id:
|
||||
@@ -8442,7 +8442,7 @@ class Set(object):
|
||||
def count(self,distinct=None):
|
||||
return self.db._adapter.count(self.query,distinct)
|
||||
|
||||
def select(self, *fields, **attributes):
|
||||
def select(self, *fields, **attributes):
|
||||
if self.query is None:# and fields[0]._table._common_filter != None:
|
||||
return self(fields[0]._table).select(*fields,**attributes)
|
||||
adapter = self.db._adapter
|
||||
@@ -9120,3 +9120,4 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user