Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature supabase plugin integration #9213

Merged

Conversation

blank0537
Copy link
Contributor

Closes #9138
PR contains an implementation of the Supabase plugin. A few changes in operations/fields that are not as per the given design.

MARKETPLACE INPUTS

Project Url: Implemented as per design. Taking supabase project url from user in this field.
Service Role Secret: Implemented as per design. Taking supabase service role key from user in this encrypted field.

QUERY BUILDER INPUTS

Note: For the Table field, it will appear after the user selects the operation from the dropdown(Also took references from other datasources) and it will be a text field instead of a dropdown because there is no supabase method to fetch tables list.

Where option: As per design, Usage of this to filter data. It has three fields.
First is text field. It needs column name of table to filter by,
Second is dropdown. It has filter list operators. (Provided in issue),
Third is text field. It needs value to filter.

Sort: As per design, Usage of this to sort data. It has two fields.
First is text field. It needs column name of table which will be used to sort data
Second is dropdown. It has two options to sort data by ascending and descending.

Operations

All operations are implemented as mentioned in the issue.

Count Rows

Table: Pass table name here.(refer note for table)
Where: As per design, (refer Where option above)

Get Rows

Table: Pass table name here.(refer note for table)
Where: As per design, (refer Where filter above)
Sort: As per design, (refer Sort above)
Limit: As per design, Pass numeric value to get number of rows from table.

Create Row(s)

This does not have Values field(as per design). I added Body field instead because it needs json object to create row and also supabase has bulk row creation capability so I implemented that instead. Now it can handle single or bulk row creation.
Table: Pass table name here.(refer note for table)
Body: It takes Array of objects to create row(s) in table.

Update Row(s)

As per my understanding, I guess the expectation here is to update the column by giving value in the table for multiple rows based on filtration.
This does not have Values field(as per design). Instead It has two fields one for Column Name and one for Value
Table: Pass table name here.(refer note for table)
Where: As per design, (refer Where option above)
Column Name: Pass column name of table. It will update values to given column name.
Value: Pass value which needs to be updated to that column

Delete Row(s)

Table: Pass table name here.(refer note for table)
Where: As per design, (refer Where option above)
Limit: As per design, Pass numeric value to get number of rows from table.

SOLUTION VIDEO (E2E)

9138-supabase.mp4

@karan-rathod-316 @2001asjad Let me know if any change required.

Copy link

@mansukh-tj
Copy link
Collaborator

We have tested the PR. There are a few issues that we'd like you to fix before we merge this.

  1. Get rows - is not working for tables with more than 0 rows
  2. Update Row(s) needs a revamp as user should be able to update more than 1 column at once - you may use columns component used in Update row operation of TJDB
  3. According to our understanding, the In operator in Where clause isn't working ideally. It should take inputs like this (2,6,7) or ("Jack","John")
  4. For count operation, can you just return the { count: n } , n being number of records?

@blank0537
Copy link
Contributor Author

blank0537 commented Mar 28, 2024

@mansukh-tj
1 - I didn't get this. My table has more than 0 rows and I'm getting data. Please provide an example that didn't work for you.
3 - Ok. I thought requirement was accepting single value only. One more thing, is it going to be round brackets? because as per supabase documentation it accepts an array(with square brackets). Let me know the format then I'll make change accordingly.

@mansukh-tj
Copy link
Collaborator

  1. Sharing screen recording
Screen.Recording.2024-03-29.at.11.42.51.AM.mov
  1. Can do as per Supabase's documentation.

@blank0537
Copy link
Contributor Author

1- Just want to confirm are you using "anon public" key or "service_role" secret key? If its "anon public" key you have to define RLS policy for that table in supabase. if its "service_role" secret key then it will bypass that automatically.
Also was not able to replicate this error message on my setup with same data on supabase.
I wonder if network calls are getting resolved correctly on deployed server. Because this error message is not related to supabase.
From my findings in codebase, Its probably getting triggered from appUtils.js file from catch block of runQuery function.
Once I push new changes (adding few checks to validate) then we can try again to see if it works.
3- ok will move forward with this

@blank0537
Copy link
Contributor Author

@mansukh-tj

We have tested the PR. There are a few issues that we'd like you to fix before we merge this.

  1. Get rows - is not working for tables with more than 0 rows
  2. Update Row(s) needs a revamp as user should be able to update more than 1 column at once - you may use columns component used in Update row operation of TJDB
  3. According to our understanding, the In operator in Where clause isn't working ideally. It should take inputs like this (2,6,7) or ("Jack","John")
  4. For count operation, can you just return the { count: n } , n being number of records?

These are resolved.

Also added some validation error messages after runquery execution

  • Select one operation -> when operation from dropdown is not selected
  • Table name is required -> if table name not provided in field (for all operations)
  • Body required to create rows in table -> if rows data not provided (create rows)
  • No column(s) provided to update -> if no column provided (update rows)
  • Provide column(s) with valid data -> when column name not provided (update rows)
  • Duplicate column keys are not allowed -> when adding duplicate column names (update rows)

Copy link

github-actions bot commented Apr 1, 2024

Copy link

github-actions bot commented Apr 2, 2024

Copy link

github-actions bot commented Apr 3, 2024

Copy link
Collaborator

@akshaysasidrn akshaysasidrn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comment, please check @blank0537

server/src/assets/marketplace/plugins.json Outdated Show resolved Hide resolved
frontend/src/_components/DynamicForm.jsx Outdated Show resolved Hide resolved
@blank0537
Copy link
Contributor Author

@akshaysasidrn mentioned comments resolved.

Copy link

github-actions bot commented Apr 4, 2024

Copy link
Collaborator

@akshaysasidrn akshaysasidrn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some issue again on testing, please check @blank0537

marketplace/plugins/supabase/lib/index.ts Outdated Show resolved Hide resolved
marketplace/plugins/supabase/lib/index.ts Outdated Show resolved Hide resolved
@blank0537
Copy link
Contributor Author

@akshaysasidrn mentioned comments resolved.

Copy link

github-actions bot commented Apr 5, 2024

@akshaysasidrn akshaysasidrn merged commit 533878b into ToolJet:develop Apr 5, 2024
66 checks passed
@akshaysasidrn
Copy link
Collaborator

Thank you for the contribution @blank0537!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supabase Integration
4 participants