Skip to content

Commit

Permalink
Omit the public schema in configuration generation response (#142)
Browse files Browse the repository at this point in the history
### What

We were asked to omit the schema in the configuration generation
response if that schema is `public`.

### How

```patch
-        s.schema_name || '_' || rel.relation_name,
+        CASE
+          WHEN s.schema_name = 'public'
+          THEN rel.relation_name
+          ELSE s.schema_name || '_' || rel.relation_name
+        END,
```

And then regenerate the deployment file and re-run the tests.
  • Loading branch information
soupi committed Nov 3, 2023
1 parent 9239dcb commit 287dd6e
Show file tree
Hide file tree
Showing 96 changed files with 1,147 additions and 1,151 deletions.
2 changes: 1 addition & 1 deletion benchmarks/component/benchmarks/select-by-pk.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const testid = "select-by-pk";
const agentSocket = __ENV.AGENT_SOCKET || "localhost:8100";
const url = `http://${agentSocket}/query`;
const data = {
collection: "public_Album",
collection: "Album",
query: {
fields: {
id: { type: "column", column: "AlbumId", arguments: {} },
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/component/benchmarks/select-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const testid = "select-variables";
const agentSocket = __ENV.AGENT_SOCKET || "localhost:8100";
const url = `http://${agentSocket}/query`;
const data = {
collection: "public_Album",
collection: "Album",
query: {
fields: {
Title: {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/component/benchmarks/select-where.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const testid = "select-where";
const agentSocket = __ENV.AGENT_SOCKET || "localhost:8100";
const url = `http://${agentSocket}/query`;
const data = {
collection: "public_Album",
collection: "Album",
query: {
fields: {
id: { type: "column", column: "AlbumId", arguments: {} },
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/component/benchmarks/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const testid = "select";
const agentSocket = __ENV.AGENT_SOCKET || "localhost:8100";
const url = `http://${agentSocket}/query`;
const data = {
collection: "public_Album",
collection: "Album",
query: {
fields: {
id: { type: "column", column: "AlbumId", arguments: {} },
Expand Down
6 changes: 5 additions & 1 deletion crates/connectors/ndc-postgres/src/configuration.sql
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,11 @@ FROM
-- Tables and views
SELECT
jsonb_object_agg(
s.schema_name || '_' || rel.relation_name,
CASE
WHEN s.schema_name = 'public'
THEN rel.relation_name
ELSE s.schema_name || '_' || rel.relation_name
END,
jsonb_build_object(
'schemaName',
s.schema_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ expression: result
"rows": [
{
"track": "Grito De Alerta",
"public_Album": {
"Album": {
"rows": [
{
"album": "Meus Momentos",
"public_Artist": {
"Artist": {
"rows": [
{
"artist": "Gonzaguinha"
Expand All @@ -24,11 +24,11 @@ expression: result
},
{
"track": "Não Dá Mais Pra Segurar (Explode Coração)",
"public_Album": {
"Album": {
"rows": [
{
"album": "Meus Momentos",
"public_Artist": {
"Artist": {
"rows": [
{
"artist": "Gonzaguinha"
Expand All @@ -41,11 +41,11 @@ expression: result
},
{
"track": "Começaria Tudo Outra Vez",
"public_Album": {
"Album": {
"rows": [
{
"album": "Meus Momentos",
"public_Artist": {
"Artist": {
"rows": [
{
"artist": "Gonzaguinha"
Expand All @@ -58,11 +58,11 @@ expression: result
},
{
"track": "O Que É O Que É ?",
"public_Album": {
"Album": {
"rows": [
{
"album": "Meus Momentos",
"public_Artist": {
"Artist": {
"rows": [
{
"artist": "Gonzaguinha"
Expand All @@ -75,11 +75,11 @@ expression: result
},
{
"track": "Sangrando",
"public_Album": {
"Album": {
"rows": [
{
"album": "Meus Momentos",
"public_Artist": {
"Artist": {
"rows": [
{
"artist": "Gonzaguinha"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ expression: result
"rows": [
{
"Title": "Let There Be Rock",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "AC/DC"
Expand All @@ -17,7 +17,7 @@ expression: result
},
{
"Title": "Big Ones",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Aerosmith"
Expand All @@ -27,7 +27,7 @@ expression: result
},
{
"Title": "Jagged Little Pill",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Alanis Morissette"
Expand All @@ -37,7 +37,7 @@ expression: result
},
{
"Title": "Facelift",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Alice In Chains"
Expand All @@ -47,7 +47,7 @@ expression: result
},
{
"Title": "Warner 25 Anos",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Antônio Carlos Jobim"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ expression: result
"rows": [
{
"0Title": "For Those About To Rock We Salute You",
"public_Artist": {
"Artist": {
"rows": [
{
"0ArtistId": 1,
"Albums": {
"rows": [
{
"0Title": "For Those About To Rock We Salute You",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "AC/DC"
Expand All @@ -29,7 +29,7 @@ expression: result
},
{
"0Title": "Let There Be Rock",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "AC/DC"
Expand All @@ -45,15 +45,15 @@ expression: result
},
{
"0Title": "Let There Be Rock",
"public_Artist": {
"Artist": {
"rows": [
{
"0ArtistId": 1,
"Albums": {
"rows": [
{
"0Title": "For Those About To Rock We Salute You",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "AC/DC"
Expand All @@ -63,7 +63,7 @@ expression: result
},
{
"0Title": "Let There Be Rock",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "AC/DC"
Expand All @@ -86,15 +86,15 @@ expression: result
"rows": [
{
"0Title": "Balls to the Wall",
"public_Artist": {
"Artist": {
"rows": [
{
"0ArtistId": 2,
"Albums": {
"rows": [
{
"0Title": "Balls to the Wall",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "Accept"
Expand All @@ -104,7 +104,7 @@ expression: result
},
{
"0Title": "Restless and Wild",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "Accept"
Expand All @@ -120,15 +120,15 @@ expression: result
},
{
"0Title": "Restless and Wild",
"public_Artist": {
"Artist": {
"rows": [
{
"0ArtistId": 2,
"Albums": {
"rows": [
{
"0Title": "Balls to the Wall",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "Accept"
Expand All @@ -138,7 +138,7 @@ expression: result
},
{
"0Title": "Restless and Wild",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "Accept"
Expand All @@ -161,15 +161,15 @@ expression: result
"rows": [
{
"0Title": "Big Ones",
"public_Artist": {
"Artist": {
"rows": [
{
"0ArtistId": 3,
"Albums": {
"rows": [
{
"0Title": "Big Ones",
"public_Artist": {
"Artist": {
"rows": [
{
"0Name": "Aerosmith"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ expression: result
"rows": [
{
"Name": "A Copland Celebration, Vol. I",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Aaron Copland & London Symphony Orchestra"
Expand All @@ -17,7 +17,7 @@ expression: result
},
{
"Name": "Worlds",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Aaron Goldberg"
Expand All @@ -27,7 +27,7 @@ expression: result
},
{
"Name": "Sir Neville Marriner: A Celebration",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Academy of St. Martin in the Fields Chamber Ensemble & Sir Neville Marriner"
Expand All @@ -37,7 +37,7 @@ expression: result
},
{
"Name": "Fauré: Requiem, Ravel: Pavane & Others",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Academy of St. Martin in the Fields, John Birch, Sir Neville Marriner & Sylvia McNair"
Expand All @@ -47,7 +47,7 @@ expression: result
},
{
"Name": "The World of Classical Favourites",
"public_Artist": {
"Artist": {
"rows": [
{
"Name": "Academy of St. Martin in the Fields & Sir Neville Marriner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ FROM
FROM
(
SELECT
"%0_public_Album"."Title" AS "Title"
"%0_Album"."Title" AS "Title"
FROM
"public"."Album" AS "%0_public_Album"
"public"."Album" AS "%0_Album"
WHERE
("%0_public_Album"."AlbumId" = 35)
("%0_Album"."AlbumId" = 35)
) AS "%2_rows"
) AS "%2_rows"
) AS "%1_universe"
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ FROM
FROM
(
SELECT
"%0_public_Album"."Title" AS "Title"
"%0_Album"."Title" AS "Title"
FROM
"public"."Album" AS "%0_public_Album"
"public"."Album" AS "%0_Album"
WHERE
(
"%0_public_Album"."Title" !~~* cast($1 as varchar)
)
("%0_Album"."Title" !~~* cast($1 as varchar))
ORDER BY
"%0_public_Album"."AlbumId" ASC
"%0_Album"."AlbumId" ASC
LIMIT
5
) AS "%2_rows"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ FROM
FROM
(
SELECT
"%0_public_Album"."Title" AS "Title"
"%0_Album"."Title" AS "Title"
FROM
"public"."Album" AS "%0_public_Album"
"public"."Album" AS "%0_Album"
WHERE
("%0_public_Album"."Title" ~~ cast($1 as varchar))
("%0_Album"."Title" ~~ cast($1 as varchar))
ORDER BY
"%0_public_Album"."AlbumId" ASC
"%0_Album"."AlbumId" ASC
) AS "%2_rows"
) AS "%2_rows"
) AS "%1_universe"
Loading

0 comments on commit 287dd6e

Please sign in to comment.