feat: add noTransaction parameter to tables.create() and columns.crea…#1049
feat: add noTransaction parameter to tables.create() and columns.crea…#10497ttp wants to merge 2 commits intosupabase:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR adds a Sequence Diagram(s)(omitted) Assessment against linked issues
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
avallete
left a comment
There was a problem hiding this comment.
I’m leaning against approving this.
I’d rather keep postgres-meta endpoints atomic by default and avoid adding app-specific transaction control to these helpers. For cases like this, Studio should build and own the full SQL/transaction it needs and use the lower-level query path instead of extending the tables.create() / columns.create() API surface with noTransaction.
Fixes #42089 Supersedes #43352 and supabase/postgres-meta#1049 ## Problem When creating a table in the Dashboard, if a column-specific error occurs (e.g., invalid enum value or broken foreign key), the Dashboard displays an error toast, but the side panel remains open. In the background, the table is actually created (partially), leading to a _42P07: relation already exists_ error if the user tries to click _Save_ again. ## Solution We actually had nested transactions which is not supported by Postgres. - [x] Allow generating SQL without transactions from `@supabase/pg-meta` - [x] Fix the table creation - [x] Fix some accessibility issues - [x] Add tests ## How to test 1. Click _New table_ in the Table editor 2. Add a column with an _int8_ type and set its default value to `bazinga` 3. Click _Save_ You should see an error. 4. Fix the default value by setting it to `10` 5. Click _Save_ Results: - You should see a success message about the table creation - The table should have the column with the correct default value
|
Closed in favor of #43909. Thanks! |
Fixes #42089 Supersedes #43352 and supabase/postgres-meta#1049 ## Problem When creating a table in the Dashboard, if a column-specific error occurs (e.g., invalid enum value or broken foreign key), the Dashboard displays an error toast, but the side panel remains open. In the background, the table is actually created (partially), leading to a _42P07: relation already exists_ error if the user tries to click _Save_ again. ## Solution We actually had nested transactions which is not supported by Postgres. - [x] Allow generating SQL without transactions from `@supabase/pg-meta` - [x] Fix the table creation - [x] Fix some accessibility issues - [x] Add tests ## How to test 1. Click _New table_ in the Table editor 2. Add a column with an _int8_ type and set its default value to `bazinga` 3. Click _Save_ You should see an error. 4. Fix the default value by setting it to `10` 5. Click _Save_ Results: - You should see a success message about the table creation - The table should have the column with the correct default value
Summary
Adds optional
noTransactionparameter totables.create()andcolumns.create()that skipsBEGIN...COMMITwrappers when set totrue, enabling atomic multi-operation transactions.Problem
Each
create()call wraps SQL in its own transaction.Solution
Added
noTransactionparameter (defaults tofalsefor BC) that conditionally wraps SQL.Related