242 |
result.append(row[0]) |
result.append(row[0]) |
243 |
return result |
return result |
244 |
|
|
245 |
|
def Width(self, col): |
246 |
|
"""Return the maximum width of values in the column |
247 |
|
|
248 |
|
The return value is the the maximum length of string representation |
249 |
|
of the values in the column (represented by index or name).""" |
250 |
|
max = 0 |
251 |
|
|
252 |
|
type = self.column_map[col].type |
253 |
|
iname = self.column_map[col].internal_name |
254 |
|
cursor = self.db.cursor() |
255 |
|
cursor.execute("SELECT %s FROM %s;" % (iname, self.tablename)) |
256 |
|
values = [ i[0] for i in cursor.fetchall()] |
257 |
|
if not values: |
258 |
|
return None |
259 |
|
|
260 |
|
if type == sql_type_map[table.FIELDTYPE_DOUBLE]: |
261 |
|
format = "%.12f" |
262 |
|
elif type == sql_type_map[table.FIELDTYPE_INT]: |
263 |
|
format = "%d" |
264 |
|
else: |
265 |
|
format = "%s" |
266 |
|
for value in values: |
267 |
|
if value is None: continue |
268 |
|
l = len(format % value) |
269 |
|
if l > max: |
270 |
|
max = l |
271 |
|
|
272 |
|
return max |
273 |
|
|
274 |
def SimpleQuery(self, left, comparison, right): |
def SimpleQuery(self, left, comparison, right): |
275 |
"""Return the indices of all rows that matching a condition. |
"""Return the indices of all rows that matching a condition. |
276 |
|
|
534 |
def Dependencies(self): |
def Dependencies(self): |
535 |
"""Return a tuple containing the original table""" |
"""Return a tuple containing the original table""" |
536 |
return (self.table,) |
return (self.table,) |
537 |
|
|
538 |
|
def Width(self, col): |
539 |
|
return self.table.Width(col) |