-
Notifications
You must be signed in to change notification settings - Fork 1
apisexample
Laurent MICHEL edited this page Nov 9, 2020
·
4 revisions
Let's consider the following schema:
table1(key1) joined with table2(key2)
{
"succes": {
"status": "OK",
"object_map": {
"table2": {
"schema": "public",
"description": "",
"join_tables": {
"table1": {
"schema": "public",
"columns": [],
"constraints": "",
"from": "key1",
"target": "key2"
}
}
}
}
}
}
{
"status": "OK",
"base_table": "table1",
"joined_tables": [
"table2"
]
}
{
"status": "OK",
"query": "SELECT TOP 100 public.table1.key1 FROM public.table1"
}
Let's suppose that table1
has one column named col1
{
"status": "OK",
"attribute_handlers": [{"name": "col1", "db_name": "col1", "type"; "int", "ucd": "", "utype": "", "description": "", "range": ""}]
}
Let's suppose we want col1 > 0
API call: setTableConstraint("table1", "col1 > 0")
{
"status": "OK",
"query": "SELECT TOP 100 public.table1.key1 FROM public.table1 WHERE public.table1.col1 > 0"
}
Let's suppose that table2
has one column named col2
{
"status": "OK",
"attribute_handlers": [{"name": "col2", "db_name": "col2", "type": "int", "ucd": "", "utype": "", "description": "", "range": ""}]
}
Let's suppose we want col2 = 99
API call: setTableConstraint("table2", "col2 = 99")
{
"status": "OK",
"query": "SELECT TOP 100 public.table1.key1 FROM public.table1 "
"JOIN public.table2 ON public.table2.key2 = public.table1 "
"WHERE public.table1.col1 > 0 AND public.table2.col2 = 99"
}
Let's suppose that only one row (key1 = 12345) of table1 matches the query.
{
"status": "ok",
"root_ids": [12345]}
API call getTableQueryIds("table2", "12345")
Let's suppose that 2 rows (key1 = 111 and key2 = 222) of table2 match the query.
{
"status": "ok",
"root_ids": [111, 222]}
The query actually run is
SELECT TOP 100 public.table2.key2 FROM public.table2 WHERE public.table2.key2 = 12345