Supabase Postgres RLS/Insert Issue: text[] columns for target_professional_industries and target_job_titles never populate #37519
Replies: 1 comment 3 replies
-
|
RLS does not impact columns. But your Insert policy is not correct. It must be WITH CHECK and not USING. This though would not insert anything to the row and not just leave out 1 column. I notice you have null conditionals on the ensure_array for the two that fail, but not the one that works... FWIW. And you get no errors at all? It might be better to use the SB Discord and post your real code so users there can look at it and help in a more interactive fashion. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I’ve been banging my head against the wall for days on this and could use expert help.
My issue:
When I insert a row into my study_plans table via my Next.js app, all columns save as expected except
target_professional_industries (text[])
target_job_titles (text[])
No matter what I do, these always save as empty arrays ([]), even though the payload sent from my API contains correct values (strings or UUIDs).
Strangely, target_audience_skills (also a text[]) works fine and saves values like ["5ff5ff245227a5352856e77a"].
Table schema for demographics:
sql
Copy
Edit
-- Partial table definition
create table study_plans (
...
target_professional_industries text[],
target_job_titles text[],
target_audience_skills text[],
...
);
API/Insert code (simplified):
js
Copy
Edit
const insertObject = {
...
target_professional_industries: ensureArray(target_professional_industries ?? targetProfessionalIndustries),
target_job_titles: ensureArray(target_job_titles ?? targetJobTitles),
target_audience_skills: ensureArray(target_audience_skills),
...
};
(ensureArray is a helper that always returns a string[])
RLS Policies:
RLS is enabled on the table.
Insert policy:
sql
Copy
Edit
CREATE POLICY "Anyone can insert"
ON study_plans
FOR INSERT
USING (true);
What I’ve tried:
Matching column names/casing between API and Supabase
Checking if the frontend sends as strings, stringified arrays, or actual arrays
Manually inserting via Supabase dashboard (works fine)
Double/triple-checking the API logs (shows correct values sent)
Disabling and re-enabling RLS
Changing default values to {} or []
Screenshot:
(Attach the one you uploaded showing the columns)
Q:
Is there any chance a subtle RLS or column-level Postgres config could cause only these text[] fields to reject values when inserted via API, but not in dashboard?
Any known issues with Postgres, RLS, or text[] columns and certain array formats?
What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions