Not getting results from IHP DataSync despite setting Row Level Policy

Viewed 43

I want to use DataSync on my current application, using IHP 0.16. I believe I have followed all the installation steps in FrontController and Routes.

I have a characters table with a user_id column connected to the users table. I have set the policy on the characters table resulting in this generated SQL:

CREATE POLICY "Users can manage their characters" ON characters USING (user_id = ihp_user_id()) WITH CHECK (user_id = ihp_user_id());
ALTER TABLE characters ENABLE ROW LEVEL SECURITY;

Trying to run this in the JavaScript console

await query("characters").fetch()

I get this error in JavaScript output:

enter image description here

And this error in IHP output:

Query (2.119753ms): "SELECT relrowsecurity FROM pg_class WHERE oid = ?::regclass" ["characters"]
Query (0.111442ms): "SET LOCAL ROLE ?" [Identifier {fromIdentifier = "ihp_authenticated"}]
Query (0.130888ms): "SET LOCAL rls.ihp_user_id = ?" Only {fromOnly = Just 0d7b46b1-bcb4-46a2-bf77-ad27dace8416}
FormatError {fmtMessage = "1 single '?' characters, but 3 parameters", fmtQuery = "SELECT ? FROM ??", fmtParams = ["*","characters",""]}

This seems to be another error than the row level security error in the DataSync tutorial in the IHP docs. Any idea on what causes this error?

1 Answers
Related