fix: cast SQL booleans to python
This commit is contained in:
parent
3adc83e7c6
commit
ca33deae12
1 changed files with 7 additions and 4 deletions
|
|
@ -593,7 +593,10 @@ def describe_database_table(context, doctype, column):
|
|||
|
||||
|
||||
def _extract_table_stats(doctype: str, columns: list[str]) -> dict:
|
||||
from frappe.utils import get_table_name
|
||||
from frappe.utils import cstr, get_table_name
|
||||
|
||||
def sql_bool(val):
|
||||
return cstr(val).lower() in ("yes", "1", "true")
|
||||
|
||||
table = get_table_name(doctype, wrap_in_backticks=True)
|
||||
|
||||
|
|
@ -603,7 +606,7 @@ def _extract_table_stats(doctype: str, columns: list[str]) -> dict:
|
|||
{
|
||||
"column": field["Field"],
|
||||
"type": field["Type"],
|
||||
"is_nullable": field["Null"],
|
||||
"is_nullable": sql_bool(field["Null"]),
|
||||
"default": field["Default"],
|
||||
}
|
||||
)
|
||||
|
|
@ -618,11 +621,11 @@ def _extract_table_stats(doctype: str, columns: list[str]) -> dict:
|
|||
for idx in frappe.db.sql(f"show index from {table}", as_dict=True):
|
||||
indexes.append(
|
||||
{
|
||||
"unique": not idx["Non_unique"],
|
||||
"unique": not sql_bool(idx["Non_unique"]),
|
||||
"cardinality": idx["Cardinality"],
|
||||
"name": idx["Key_name"],
|
||||
"sequence": idx["Seq_in_index"],
|
||||
"nullable": idx["Null"],
|
||||
"nullable": sql_bool(idx["Null"]),
|
||||
"column": idx["Column_name"],
|
||||
"type": idx["Index_type"],
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue