Add failing test to test correct view column detection
This commit is contained in:
@@ -24,6 +24,7 @@ spec = do
|
|||||||
, {"schema":"test","name":"comments","insertable":true}
|
, {"schema":"test","name":"comments","insertable":true}
|
||||||
, {"schema":"test","name":"complex_items","insertable":true}
|
, {"schema":"test","name":"complex_items","insertable":true}
|
||||||
, {"schema":"test","name":"compound_pk","insertable":true}
|
, {"schema":"test","name":"compound_pk","insertable":true}
|
||||||
|
, {"schema":"test","name":"filtered_tasks","insertable":true}
|
||||||
, {"schema":"test","name":"ghostBusters","insertable":true}
|
, {"schema":"test","name":"ghostBusters","insertable":true}
|
||||||
, {"schema":"test","name":"has_count_column","insertable":false}
|
, {"schema":"test","name":"has_count_column","insertable":false}
|
||||||
, {"schema":"test","name":"has_fk","insertable":true}
|
, {"schema":"test","name":"has_fk","insertable":true}
|
||||||
@@ -57,6 +58,61 @@ spec = do
|
|||||||
{matchStatus = 200}
|
{matchStatus = 200}
|
||||||
|
|
||||||
describe "Table info" $ do
|
describe "Table info" $ do
|
||||||
|
it "The structure of complex views is correctly detected" $
|
||||||
|
request methodOptions "/filtered_tasks" [] "" `shouldRespondWith`
|
||||||
|
[json|
|
||||||
|
{
|
||||||
|
"pkey": [
|
||||||
|
"myId"
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"references": null,
|
||||||
|
"default": null,
|
||||||
|
"precision": 32,
|
||||||
|
"updatable": true,
|
||||||
|
"schema": "test",
|
||||||
|
"name": "myId",
|
||||||
|
"type": "integer",
|
||||||
|
"maxLen": null,
|
||||||
|
"enum": [],
|
||||||
|
"nullable": true,
|
||||||
|
"position": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"references": null,
|
||||||
|
"default": null,
|
||||||
|
"precision": null,
|
||||||
|
"updatable": true,
|
||||||
|
"schema": "test",
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"maxLen": null,
|
||||||
|
"enum": [],
|
||||||
|
"nullable": true,
|
||||||
|
"position": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"references": {
|
||||||
|
"schema": "test",
|
||||||
|
"column": "id",
|
||||||
|
"table": "projects"
|
||||||
|
},
|
||||||
|
"default": null,
|
||||||
|
"precision": 32,
|
||||||
|
"updatable": true,
|
||||||
|
"schema": "test",
|
||||||
|
"name": "projectID",
|
||||||
|
"type": "integer",
|
||||||
|
"maxLen": null,
|
||||||
|
"enum": [],
|
||||||
|
"nullable": true,
|
||||||
|
"position": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|]
|
||||||
|
|
||||||
it "is available with OPTIONS verb" $
|
it "is available with OPTIONS verb" $
|
||||||
request methodOptions "/menagerie" [] "" `shouldRespondWith`
|
request methodOptions "/menagerie" [] "" `shouldRespondWith`
|
||||||
[json|
|
[json|
|
||||||
|
|||||||
Vendored
+1
@@ -28,6 +28,7 @@ GRANT ALL ON TABLE
|
|||||||
, projects_view
|
, projects_view
|
||||||
, simple_pk
|
, simple_pk
|
||||||
, tasks
|
, tasks
|
||||||
|
, filtered_tasks
|
||||||
, tsearch
|
, tsearch
|
||||||
, users
|
, users
|
||||||
, users_projects
|
, users_projects
|
||||||
|
|||||||
Vendored
+19
-9
@@ -540,6 +540,15 @@ CREATE TABLE simple_pk (
|
|||||||
extra character varying NOT NULL
|
extra character varying NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: users_projects; Type: TABLE; Schema: test; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE users_projects (
|
||||||
|
user_id integer NOT NULL,
|
||||||
|
project_id integer NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: tasks; Type: TABLE; Schema: test; Owner: -
|
-- Name: tasks; Type: TABLE; Schema: test; Owner: -
|
||||||
@@ -551,6 +560,16 @@ CREATE TABLE tasks (
|
|||||||
project_id integer
|
project_id integer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW filtered_tasks AS
|
||||||
|
SELECT id AS "myId", name, project_id AS "projectID"
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IN (
|
||||||
|
SELECT id FROM projects WHERE id = 1
|
||||||
|
) AND
|
||||||
|
project_id IN (
|
||||||
|
SELECT project_id FROM users_projects WHERE user_id = 1
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: tsearch; Type: TABLE; Schema: test; Owner: -
|
-- Name: tsearch; Type: TABLE; Schema: test; Owner: -
|
||||||
@@ -571,15 +590,6 @@ CREATE TABLE users (
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: users_projects; Type: TABLE; Schema: test; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE TABLE users_projects (
|
|
||||||
user_id integer NOT NULL,
|
|
||||||
project_id integer NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: users_tasks; Type: TABLE; Schema: test; Owner: -
|
-- Name: users_tasks; Type: TABLE; Schema: test; Owner: -
|
||||||
|
|||||||
Reference in New Issue
Block a user