258 |
return None |
return None |
259 |
|
|
260 |
if type == sql_type_map[table.FIELDTYPE_DOUBLE]: |
if type == sql_type_map[table.FIELDTYPE_DOUBLE]: |
261 |
prec = self.Precision(col) |
format = "%.12f" |
|
format = "%%.%df" % prec |
|
262 |
elif type == sql_type_map[table.FIELDTYPE_INT]: |
elif type == sql_type_map[table.FIELDTYPE_INT]: |
263 |
format = "%d" |
format = "%d" |
264 |
else: |
else: |
271 |
|
|
272 |
return max |
return max |
273 |
|
|
|
def Precision(self, col): |
|
|
"""Return the precision of the column |
|
|
|
|
|
The return value is the maximum number of numeric characters after the |
|
|
decimal if column type is double. Else precision zero is returned. |
|
|
The column can be represented by index or name. |
|
|
""" |
|
|
|
|
|
type = self.column_map[col].type |
|
|
if type == sql_type_map[table.FIELDTYPE_DOUBLE]: |
|
|
iname = self.column_map[col].internal_name |
|
|
cursor = self.db.cursor() |
|
|
cursor.execute("SELECT %s FROM %s;" % (iname, self.tablename)) |
|
|
values = [ i[0] for i in cursor.fetchall()] |
|
|
if not values: |
|
|
return 0 |
|
|
|
|
|
max = 0 |
|
|
for value in values: |
|
|
if value is None: continue |
|
|
l = len(str(value % 1)) |
|
|
if l > max: |
|
|
max = l |
|
|
if max > 2: |
|
|
return max - 2 |
|
|
else: |
|
|
return 0 |
|
|
else: |
|
|
return 0 |
|
|
|
|
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 |
|
|
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) |