Files
postgrest/test/load/fixtures.sql
T
steve-chavezandLaurence Isla 490d1dc5d3 add: config to emit warning for legacy target names
Adds the `url_use_legacy_target_names` config.

Enabled (default):
* It allows using the resource name in filters,
  orders or limits when it has an alias, e.g.
  `table?select=alias:target(*)&target.id=eq.1`
* Logs a WARNING with a hint to use the alias
* Returns a Warning header in the response

Disabled:
* It returns an error, only the alias is allowed
* No warnings returned

This feature is deprecated
2026-07-11 02:15:07 +00:00

57 lines
1.5 KiB
PL/PgSQL

CREATE ROLE postgrest_test_anonymous;
CREATE ROLE postgrest_test_author;
GRANT postgrest_test_anonymous TO :"PGUSER";
GRANT postgrest_test_author TO :"PGUSER";
CREATE SCHEMA test;
-- PUT+PATCH target needs one record and column to modify
CREATE TABLE test.actors (
PRIMARY KEY (actor),
actor INT,
name TEXT,
last_modified TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO test.actors VALUES (1, 'John Doe');
-- POST target needs generated PK
CREATE TABLE test.films (
id INT PRIMARY KEY,
title TEXT,
year TEXT,
runtime TEXT,
genres TEXT[],
director TEXT,
actors TEXT,
plot TEXT,
"posterUrl" TEXT
);
-- DELETE target remains empty
CREATE TABLE test.roles (
actor INT REFERENCES test.actors,
film INT REFERENCES test.films,
character TEXT
);
CREATE TABLE test.authors_only ();
CREATE FUNCTION test.call_me (name TEXT) RETURNS TEXT
STABLE LANGUAGE SQL AS $$
SELECT 'Hello ' || name || ', how are you?';
$$;
GRANT USAGE ON SCHEMA test TO postgrest_test_anonymous, postgrest_test_author;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA test TO postgrest_test_anonymous;
REVOKE ALL PRIVILEGES ON TABLE
authors_only
FROM postgrest_test_anonymous;
GRANT ALL ON TABLE authors_only TO postgrest_test_author;
SELECT format('CREATE TABLE test.actors_%s ();', n)
FROM generate_series(1, 450) n -- 500 is the upper limit for table not found error hint generation
\gexec
-- TODO add many function for fuzzy search (somehow this is making the loadtest start slow)