PostgREST not recognizing the objects(tables/functions/views) in a schema even after adding it to the exposed schemas
Last edited: 8/12/2026
PostgREST 会报错,因为无法识别 schema 中的对象(表/函数/视图),并记录类似的错误:
🌐 PostgREST is returning errors by not recognizing the objects(tables/functions/views) in a schema and logging errors similar to:
1Could not find the table 'X' in the schema cache为什么会这样 #
🌐 Why this happens
当暴露多个模式时,列表中的第一个条目被视为默认模式,因此 PostgREST 只会针对该模式解析未限定的对象名称。
🌐 When multiple schemas are exposed, the first entry in the list is treated as the default, so PostgREST resolves unqualified object names only against that schema.
这种行为是故意的,因为它可以防止当不同的模式包含同名对象时发生冲突。
🌐 This behavior is intentional, as it prevents conflicts when different schemas contain objects with the same name.
怎么修这个 #
🌐 How to fix this
如果你想在不指定模式的情况下使用对象,你需要先放好它。否则,你应该使用模式初始化 Supabase 客户端(“使用自定义模式”),或者在每个请求中使用 ".schema('your_schema')" 指定模式(“每个查询切换模式”)
🌐 If you want to use the objects without specifying a schema, you'd need to put it first. Else, you should initialise the Supabase client with the schema(”With custom schemas”) or specify the schema on each request using ".schema('your_schema')" ("Switching schemas per query")