From 0a076f313c15fc21cc8d0137b7cd7a1d32e0814e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 22 Dec 2025 17:14:50 +0800 Subject: [PATCH 1/4] bugfix --- xls2ddl/tmpls.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/xls2ddl/tmpls.py b/xls2ddl/tmpls.py index 4d4706a..37eb03b 100644 --- a/xls2ddl/tmpls.py +++ b/xls2ddl/tmpls.py @@ -166,6 +166,9 @@ return { """ data_new_tmpl = """ ns = params_kw.copy() +for k,v in ns.items(): + if v == 'NaN' or v == 'null': + ns[k] = None id = params_kw.id if not id or len(id) > 32: id = uuid() @@ -233,6 +236,9 @@ return { """ data_update_tmpl = """ ns = params_kw.copy() +for k,v in ns.items(): + if v == 'NaN' or v == 'null': + ns[k] = None {% if logined_userid %} userid = await get_user() if not userid: @@ -271,6 +277,28 @@ if params_kw.get('{{f}}'): db = DBPools() dbname = get_module_dbname('{{modulename}}') async with db.sqlorContext(dbname) as sor: +{% if logined_userid or logined_userorgid %} + ns1 = { +{% logined_userorgid %} + "{{logined_userorgid}}": userorgid, +{% endif %} +{% logined_userid %} + "{{logined_userid}}": userid, +{% endif %} + "id": params_kw.id + } + recs = await sor.R('{{summary[0].name}}', ns1) + if len(recs) < 1: + return { + "widgettype":"Error", + "options":{ + "title":"Update Error", + "cwidth":16, + "cheight":9, + "timeout":3, + "message":"Record no exist or with wrong ownership" + } + } r = await sor.U('{{summary[0].name}}', ns) debug('update success'); return { From e384efe28ea8b1b721e26aaf00be09be94a8301b Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 22 Dec 2025 17:21:50 +0800 Subject: [PATCH 2/4] buggix --- xls2ddl/tmpls.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xls2ddl/tmpls.py b/xls2ddl/tmpls.py index 37eb03b..f186a30 100644 --- a/xls2ddl/tmpls.py +++ b/xls2ddl/tmpls.py @@ -279,10 +279,10 @@ dbname = get_module_dbname('{{modulename}}') async with db.sqlorContext(dbname) as sor: {% if logined_userid or logined_userorgid %} ns1 = { -{% logined_userorgid %} +{% if logined_userorgid %} "{{logined_userorgid}}": userorgid, {% endif %} -{% logined_userid %} +{% if logined_userid %} "{{logined_userid}}": userid, {% endif %} "id": params_kw.id @@ -299,6 +299,7 @@ async with db.sqlorContext(dbname) as sor: "message":"Record no exist or with wrong ownership" } } +{% endif %} r = await sor.U('{{summary[0].name}}', ns) debug('update success'); return { From 25a50f79f425adeeba0def15ddea518045d5bd9a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 22 Dec 2025 17:30:14 +0800 Subject: [PATCH 3/4] bugfix --- xls2ddl/tmpls.py | 174 +++++++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/xls2ddl/tmpls.py b/xls2ddl/tmpls.py index f186a30..d20a01c 100644 --- a/xls2ddl/tmpls.py +++ b/xls2ddl/tmpls.py @@ -1,8 +1,8 @@ data_browser_tmpl = """ { "id":"{{tblname}}_tbl", - "widgettype":"Tabular", - "options":{ + "widgettype":"Tabular", + "options":{ "width":"100%", "height":"100%", {% if not notitle %} @@ -44,7 +44,7 @@ data_browser_tmpl = """ {% if get_data_url %} "data_url": "{{get_data_url}}", {% else %} - "data_url":"{%- raw -%}{{entire_url('./get_{%- endraw -%}{{summary[0].name}}{%- raw -%}.dspy')}}",{%- endraw %} + "data_url":"{%- raw -%}{{entire_url('./get_{%- endraw -%}{{summary[0].name}}{%- raw -%}.dspy')}}",{%- endraw %} {% endif %} "data_method":"{{data_method or 'GET'}}", "data_params":{%- raw -%}{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},{%- endraw %} @@ -62,7 +62,7 @@ data_browser_tmpl = """ "editexclouded":{{json.dumps(editexclouded, indent=4, ensure_ascii=False)}}, {% endif %} "fields":{{fieldliststr}} - }, + }, {% if subtables_condition %} {%- raw -%}{% {%- endraw %}if {{subtables_condition}} {%- raw -%} %}{%- endraw -%} {% endif %} @@ -72,9 +72,9 @@ data_browser_tmpl = """ {% if subtables_condition %} {%- raw -%}{% endif %}{%- endraw %} {% endif %} - "page_rows":160, - "cache_limit":5 - } + "page_rows":160, + "cache_limit":5 + } {% if bindsstr %} ,"binds":{{bindsstr}} {% endif %} @@ -116,11 +116,11 @@ ns['userorgid'] = userorgid {% endif %} debug(f'get_{{tblname}}.dspy:{ns=}') if not ns.get('page'): - ns['page'] = 1 + ns['page'] = 1 if not ns.get('sort'): {% if sortby %} {% if type(sortby) == type("") %} - ns['sort'] = '{{sortby}}' + ns['sort'] = '{{sortby}}' {% else %} ns['sort'] = {{json.dumps(sortby)}} {% endif %} @@ -157,8 +157,8 @@ debug(f'{sql=}') db = DBPools() dbname = get_module_dbname('{{modulename}}') async with db.sqlorContext(dbname) as sor: - r = await sor.sqlPaging(sql, ns) - return r + r = await sor.sqlPaging(sql, ns) + return r return { "total":0, "rows":[] @@ -210,28 +210,28 @@ ns['{{logined_userorgid}}'] = userorgid db = DBPools() dbname = get_module_dbname('{{modulename}}') async with db.sqlorContext(dbname) as sor: - r = await sor.C('{{summary[0].name}}', ns.copy()) - return { - "widgettype":"Message", - "options":{ + r = await sor.C('{{summary[0].name}}', ns.copy()) + return { + "widgettype":"Message", + "options":{ "user_data":ns, "cwidth":16, "cheight":9, - "title":"Add Success", + "title":"Add Success", "timeout":3, - "message":"ok" - } - } + "message":"ok" + } + } return { - "widgettype":"Error", - "options":{ - "title":"Add Error", + "widgettype":"Error", + "options":{ + "title":"Add Error", "cwidth":16, "cheight":9, "timeout":3, - "message":"failed" - } + "message":"failed" + } } """ data_update_tmpl = """ @@ -271,7 +271,7 @@ ns['{{logined_userorgid}}'] = userorgid {% endif %} {% for f in confidential_fields or [] %} if params_kw.get('{{f}}'): - ns['{{f}}'] = password_encode(params_kw.get('{{f}}')) + ns['{{f}}'] = password_encode(params_kw.get('{{f}}')) {% endfor %} db = DBPools() @@ -300,33 +300,33 @@ async with db.sqlorContext(dbname) as sor: } } {% endif %} - r = await sor.U('{{summary[0].name}}', ns) - debug('update success'); - return { - "widgettype":"Message", - "options":{ - "title":"Update Success", + r = await sor.U('{{summary[0].name}}', ns) + debug('update success'); + return { + "widgettype":"Message", + "options":{ + "title":"Update Success", "cwidth":16, "cheight":9, "timeout":3, - "message":"ok" - } - } - + "message":"ok" + } + } + return { - "widgettype":"Error", - "options":{ - "title":"Update Error", + "widgettype":"Error", + "options":{ + "title":"Update Error", "cwidth":16, "cheight":9, "timeout":3, - "message":"failed" - } + "message":"failed" + } } """ data_delete_tmpl = """ ns = { - 'id':params_kw['id'], + 'id':params_kw['id'], } {% if logined_userid %} userid = await get_user() @@ -361,29 +361,29 @@ ns['{{logined_userorgid}}'] = userorgid db = DBPools() dbname = get_module_dbname('{{modulename}}') async with db.sqlorContext(dbname) as sor: - r = await sor.D('{{summary[0].name}}', ns) - debug('delete success'); - return { - "widgettype":"Message", - "options":{ - "title":"Delete Success", + r = await sor.D('{{summary[0].name}}', ns) + debug('delete success'); + return { + "widgettype":"Message", + "options":{ + "title":"Delete Success", "timeout":3, "cwidth":16, "cheight":9, - "message":"ok" - } - } + "message":"ok" + } + } debug('Delete failed'); return { - "widgettype":"Error", - "options":{ - "title":"Delete Error", + "widgettype":"Error", + "options":{ + "title":"Delete Error", "timeout":3, "cwidth":16, "cheight":9, - "message":"failed" - } + "message":"failed" + } } """ @@ -392,39 +392,39 @@ is_checked = params_kw.get('has_{{relation.param_field}}') debug(f'{params_kw=}, {is_checked=}') dbname = get_module_dbname('{{modulename}}') if is_checked == 'true': - ns = { - "id":uuid(), - "{{relation.param_field}}":params_kw.{{relation.param_field}}, - "{{relation.outter_field}}":params_kw.{{relation.outter_field}} - } - db = DBPools(); - async with db.sqlorContext(dbname) as sor: - await sor.C('{{tblname}}', ns) + ns = { + "id":uuid(), + "{{relation.param_field}}":params_kw.{{relation.param_field}}, + "{{relation.outter_field}}":params_kw.{{relation.outter_field}} + } + db = DBPools(); + async with db.sqlorContext(dbname) as sor: + await sor.C('{{tblname}}', ns) - return { - "widgettype":"Message", - "options":{ - "title":"Success", - "message":"record add success", - "timeout":2 - } - } + return { + "widgettype":"Message", + "options":{ + "title":"Success", + "message":"record add success", + "timeout":2 + } + } else: - ns = { - "{{relation.param_field}}":params_kw.{{relation.param_field}}, - "{{relation.outter_field}}":params_kw.{{relation.outter_field}} - } - sql = "delete from {{tblname}} where {{relation.param_field}}=" + "${" + "{{relation.param_field}}" + "}$" + " and {{relation.outter_field}}=" + "${" + "{{relation.outter_field}}" + "}$" - db = DBPools() - async with db.sqlorContext(dbname) as sor: - await sor.sqlExe(sql, ns) + ns = { + "{{relation.param_field}}":params_kw.{{relation.param_field}}, + "{{relation.outter_field}}":params_kw.{{relation.outter_field}} + } + sql = "delete from {{tblname}} where {{relation.param_field}}=" + "${" + "{{relation.param_field}}" + "}$" + " and {{relation.outter_field}}=" + "${" + "{{relation.outter_field}}" + "}$" + db = DBPools() + async with db.sqlorContext(dbname) as sor: + await sor.sqlExe(sql, ns) - return { - "widgettype":"Message", - "options":{ - "title":"Success", - "message":"delete record success", - "timeout":3 - } - } + return { + "widgettype":"Message", + "options":{ + "title":"Success", + "message":"delete record success", + "timeout":3 + } + } """ From c6739a3a5368129251043616d8089e36e60e7c79 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 22 Dec 2025 17:30:51 +0800 Subject: [PATCH 4/4] bugfix --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 3778fbb..421dfe8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name=xls2ddl -version = 1.1.1 +version = 1.1.2 description = a xlsx file to database ddl converter author = "yu moqing" author_email = "yumoqing@gmail.com"