pgsync icon indicating copy to clipboard operation
pgsync copied to clipboard

Support concat for children node fields

Open abdullah2993 opened this issue 2 years ago • 4 comments

It would be really nice if concat transform could support the ability to concat child columns in parent e.g.

 {
    "database": "postgres",
    "index": "products",
    "nodes": {
      "table": "products",
      "children": [
        {
          "table": "vendors",
          "label": "vendor",
          "columns": [
            "name"
          ],
          "relationship": {
            "variant": "object",
            "type": "one_to_one"
          }
        },
        {
          "table": "line_items",
          "label": "items",
          "columns": [
            "description"
          ],
          "relationship": {
            "variant": "object",
            "type": "one_to_many",
            "foreign_key": {
              "child": [
                "product_id"
              ],
              "parent": [
                "id"
              ]
            }
          }
        }
      ],
      "columns": [
        "number",
        "purchase_order",
        "sku",
        "quantity",
        "stock_date",
        "amount"
      ],
      "transform": {
        "concat": {
          "columns": [
            "number",
            "purchase_order",
            "billing_address",
            "email_addresses",
            "estimate_date",
            "amount",
            "items.description", <------ support this
            "vendor.name" <------ support this
          ],
          "destination": "global_search_field",
          "delimiter": " "
        }
      }
    }
  }

support concating items.description and vendor.name in the given sample

abdullah2993 avatar Jul 07 '23 09:07 abdullah2993

I get what you mean. That could get complicated in generalised cases though. e.g if the parent had multiple children then you need to specify in index to concat.

toluaina avatar Jul 21 '23 16:07 toluaina

I'm not sure if I understand the question.

abdullah2993 avatar Jul 25 '23 17:07 abdullah2993

@toluaina It would be very interesting in cases of having a one_by_one relationship type to avoid and filter situations with multiple results. Is this issue still open, or is this other implementation for pgsync in some version snapshot? Is there a repository of plugins where I can find something similar? Thank you very much.

carlos-pereira-costoya avatar Jan 17 '24 14:01 carlos-pereira-costoya

Hi, I wanna ask a similar question why I really need concat for children node fields for translations. I have a table postgres movie which contains :

- id : bigint
- original_title : text

And athis table has a one-to-many relation with movie_translation :

- movieId : bigint
- title : text
- overview : text
- poster_path : url

So I wanna be able to search between title for the corresponding user language and with original_title. Elasticsearch recommend to use one field per language like this title_en, title_fr, overview_en, etc... I need to have this Elasticsearch result :

- id : bigint
- original_title : text
- title_en : text
- title_fr : text
- overview_en : text
- overview_fr : text
- poster_path_en : url
- poster_path_fr : url
-- and for each language available in movie_translation

How can we achieve this with pgsync ? Thx for ur help ! 😁

lxup avatar Aug 12 '24 18:08 lxup