Replies: 5 comments 23 replies
-
I feel like mapping or key/value construction should either use
You'll need to account for usage of quoted identifiers somehow. Let's breakdown this: More readable? More readable and more context and allows for unicode and also multi-conditions in future? |
Beta Was this translation helpful? Give feedback.
-
So I am trying to keep this similar to the root table with Restriction - is you have to put this in order, db2rest will walk from root --> child 1 .... child n Please share more of these scenarios so that the syntax can be firmed up. |
Beta Was this translation helpful? Give feedback.
-
How to indicate LEFT JOIN RIGHT JOIN? |
Beta Was this translation helpful? Give feedback.
-
@susanta-mukhopadhyay @thadguidry - take some time to review the syntax of ORDS https://www.thatjeffsmith.com/archive/2019/09/some-query-filtering-examples-in-ords/ |
Beta Was this translation helpful? Give feedback.
-
Opening a new discussion for the join request body syntax evolution. This one is already way too long. We kind of all convinced on filter, fields, sort, pagination, and join. (We may also consider subquery in the future :)) |
Beta Was this translation helpful? Give feedback.
-
Current Syntax
<url_base>/{table/view}?select=<list_of_columns>&filter=<rsql_filter_statement>page=<page_size>&size=<page_size>&sort=<col_id>&sort=<col_name>,<sort_order>
select
request parameter is missing, then all the columns of the root table/view are retrieved.select
can also specify implicit joins or resource embedding.select=film_id:id,title,description,release_year:yearOfRelease,language_id;language(name)
In this case, DB2Rest checks if an FK relationship exists between film -> language tables. If a foreign key exits, then an implicit join is applied and data is retrieved. The retrieved rows - include columns from the root table and the field
name
from thelanguage
table.This is a very concise syntax. However, it is difficult to understand by looking at it. Also, it results in complex parser code. In case, there is no foreign key between the tables, there is no way currently to specify an explicit join.
filter : This results in the where clause of the SQL statement. This follows the RSQL specification. However, the RSQL specification only supports the columns of the root table. It also needs to support fields of any join tables going forward.
page : page number of the search result to retrieve.
size : specifies the number of records to retrieve
page
andsize
are used to computeoffset
andlimit
for offset pagination.Is it possible to combine
page
andsize
along withfilter
for more efficientseek
pagination?Proposal for new Syntax and defaults
select
request parameter tofields
fields
to include fields of both root and join table columns. (what if a table has two foreign keys to another table - viz.film
has two fieldslanguage_id
fields as foreign keys of thelanguage
table - then how this will be specified?. See below)join
orembed
. There can be zero or morejoin
parameters.join=language
: looks for an implicit join relation between the root table (e.g.:film
) and thelanguage
table. This will apply inner join if the foreign key relationship is not nullable, otherwise left join is applied. Also, this will include all the columns from thelanguage
table as part of the columns list.join=language?fields:language_id,name
: Does same as in item#4, however only includes the columnslanguage_id
,name
.join=language?fields:language_id,name&condition:language_id, language_id; inner
: In this case, explicit join is applied because the foreign keys are not defined. The columnslanguage_id
, andname
are included. There is an explicit inner-join between thelanguage_id
of the root table (e.g.film
) and thelanguage.language_id
column.join=language?fields:language_id,name&condition:alternate_language_id, language_id; left
: In this case, there is an explicit left-join between thealternate_language_id
of the root table (e.g.film
) and thelanguage.language_id
column.In the case of no#6, no#7 - the first column belongs to the root table and the second column belongs to the non-root table. In case, the first table is non-root, use the
<table_name>.<column_name>
syntax.If no column from the join table is to be included, specify that with
-
: e.gjoin=language?fields=-
In case of implicit join and foreign key is not found - raise the error
unable to find table relationship
.Do not include any table alias only column alias are allowed.
schema
request parameter is to be removed completely. Schema/catalog to be detected based on access permission when looking up a table in the metadata cache.filter
- can include conditions for filtering based on join table columns - e.g 'year_of_release=eq=2023;director.country_id=eq=1' this will translate toThat should be it. Please let me know your thoughts if anything I have overlooked or missed.
Beta Was this translation helpful? Give feedback.
All reactions