Work on CRUD v2 and better SQL WHERE part building... I hope.

This commit is contained in:
Scott Idem
2024-08-14 14:36:07 -04:00
parent 3d48220b8f
commit 18293764fd
4 changed files with 140 additions and 9 deletions

View File

@@ -298,6 +298,9 @@ def handle_get_obj_li(
import urllib
# This should be a list of SQL WHERE parts defined in JSON.
qry_dict_li = None
# This should be a dict list of fields with a list of values to search for using FULLTEXT.
fulltext_qry_dict_obj = None
@@ -325,6 +328,32 @@ def handle_get_obj_li(
log.info(jp_obj)
if jp_obj.get('qry'): # NOTE: This is for specific additional WHERE clauses in the SQL statement
# Example JSON:
# jp: {
# qry: [
# {
# type: "AND",
# field: "enable",
# operator: "=",
# value: TRUE
# },
# {
# type: "AND",
# field: "example",
# operator: ">=",
# value: 2
# },
# {
# type: "OR",
# field: "test",
# operator: "LIKE",
# value: "%xyz%"
# },
# ]
# }
qry_dict_li = jp_obj['qry']
if jp_obj.get('ft_qry'): # NOTE: This is for the fulltext query
fulltext_qry_dict_obj = jp_obj['ft_qry']
@@ -445,6 +474,7 @@ def handle_get_obj_li(
field_value = for_obj_id,
enabled = commons.enabled,
hidden = hidden,
qry_dict_li = qry_dict_li,
fulltext_qry_dict = fulltext_qry_dict_obj,
and_qry_dict = and_qry_dict_obj,
and_like_dict = and_like_dict_obj,
@@ -465,6 +495,7 @@ def handle_get_obj_li(
table_name = table_name,
enabled = commons.enabled,
hidden = hidden,
qry_dict_li = qry_dict_li,
fulltext_qry_dict = fulltext_qry_dict_obj,
and_qry_dict = and_qry_dict_obj,
and_like_dict = and_like_dict_obj,