Fixes chinook table/column customizations to have consistent casing

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6642
GitOrigin-RevId: 629879fa057c3860aac1c3a83d2dfd199edb44e1
This commit is contained in:
Solomon 2022-11-01 15:07:34 -07:00 committed by hasura-bot
parent 4b968b17e0
commit f5c68ee49e
3 changed files with 230 additions and 202 deletions

View File

@ -53,18 +53,18 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums(limit: 1) {
id
title
Album(limit: 1) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums:
- id: 1
title: For Those About To Rock We Salute You
Album:
- AlbumId: 1
Title: For Those About To Rock We Salute You
|]
it "works with a primary key" $ \(testEnvironment, _) ->
@ -74,18 +74,18 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums_by_pk(id: 1) {
id
title
Album_by_pk(AlbumId: 1) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums_by_pk:
id: 1
title: "For Those About To Rock We Salute You"
Album_by_pk:
AlbumId: 1
Title: "For Those About To Rock We Salute You"
|]
it "works with non existent primary key" $ \(testEnvironment, _) ->
@ -95,16 +95,16 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums_by_pk(id: 999999) {
id
title
Album_by_pk(AlbumId: 999999) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums_by_pk: null
Album_by_pk: null
|]
it "works with a composite primary key" $ \(testEnvironment, _) ->
@ -142,18 +142,18 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums (limit: 3, offset: 2, order_by: {id: asc}) {
id
Album (limit: 3, offset: 2, order_by: {AlbumId: asc}) {
AlbumId
}
}
|]
)
[yaml|
data:
albums:
- id: 3
- id: 4
- id: 5
Album:
- AlbumId: 3
- AlbumId: 4
- AlbumId: 5
|]
describe "Array Relationships" $ do
@ -165,11 +165,11 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getArtist {
artists_by_pk(id: 1) {
id
name
albums {
title
Artist(where: {ArtistId: {_eq: 1}}) {
ArtistId
Name
Albums {
Title
}
}
}
@ -177,16 +177,16 @@ tests opts = describe "Queries" $ do
)
[yaml|
data:
artists_by_pk:
name: AC/DC
id: 1
albums:
- title: For Those About To Rock We Salute You
- title: Let There Be Rock
Artist:
- Name: AC/DC
ArtistId: 1
Albums:
- Title: For Those About To Rock We Salute You
- Title: Let There Be Rock
|]
describe "Foreign Key Constraint On" do
it "joins on PlaylistId" $ \(testEnvironment, _) -> do
it "joins on playlist_id" $ \(testEnvironment, _) -> do
-- NOTE: Ordering is used for the query due to inconsistencies in data-set ordering.
shouldReturnYaml
opts
@ -194,7 +194,7 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getPlaylist {
Playlist_by_pk(PlaylistId: 1) {
Playlist(where: {PlaylistId: {_eq: 1}}) {
Tracks (order_by: {TrackId: desc}, limit: 3) {
TrackId
}
@ -204,11 +204,11 @@ tests opts = describe "Queries" $ do
)
[yaml|
data:
Playlist_by_pk:
Tracks:
- TrackId: 3503
- TrackId: 3502
- TrackId: 3501
Playlist:
- Tracks:
- TrackId: 3503
- TrackId: 3502
- TrackId: 3501
|]
describe "Object Relationships" do
@ -220,11 +220,11 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums_by_pk(id: 1) {
id
title
artist {
name
Album(where: {AlbumId: {_eq: 1}}) {
AlbumId
Title
Artist {
Name
}
}
}
@ -232,11 +232,11 @@ tests opts = describe "Queries" $ do
)
[yaml|
data:
albums_by_pk:
id: 1
title: "For Those About To Rock We Salute You"
artist:
name: "AC/DC"
Album:
- AlbumId: 1
Title: "For Those About To Rock We Salute You"
Artist:
Name: "AC/DC"
|]
describe "Foreign Key Constraint On" $ do
@ -247,7 +247,7 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getPlaylist {
PlaylistTrack_by_pk(PlaylistId: 1, TrackId: 2) {
PlaylistTrack(where: {PlaylistId: {_eq: 1}, TrackId: {_eq: 2}}) {
Playlist {
Name
}
@ -257,9 +257,9 @@ tests opts = describe "Queries" $ do
)
[yaml|
data:
PlaylistTrack_by_pk:
Playlist:
Name: "Music"
PlaylistTrack:
- Playlist:
Name: "Music"
|]
describe "Where Clause Tests" $ do
@ -270,22 +270,22 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums(where: {id: {_in: [1, 3, 5]}}) {
id
title
Album(where: {AlbumId: {_in: [1, 3, 5]}}) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums:
- id: 1
title: For Those About To Rock We Salute You
- id: 3
title: Restless and Wild
- id: 5
title: Big Ones
Album:
- AlbumId: 1
Title: For Those About To Rock We Salute You
- AlbumId: 3
Title: Restless and Wild
- AlbumId: 5
Title: Big Ones
|]
it "works with '_nin' predicate" $ \(testEnvironment, _) ->
@ -295,20 +295,20 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums(where: {id: {_in: [1, 3, 5]}, title: {_nin: ["Big Ones"]}}) {
id
title
Album(where: {AlbumId: {_in: [1, 3, 5]}, Title: {_nin: ["Big Ones"]}}) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums:
- id: 1
title: For Those About To Rock We Salute You
- id: 3
title: Restless and Wild
Album:
- AlbumId: 1
Title: For Those About To Rock We Salute You
- AlbumId: 3
Title: Restless and Wild
|]
it "works with '_eq' predicate" $ \(testEnvironment, _) ->
@ -318,18 +318,18 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums(where: {id: {_eq: 1}}) {
id
title
Album(where: {AlbumId: {_eq: 1}}) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums:
- id: 1
title: For Those About To Rock We Salute You
Album:
- AlbumId: 1
Title: For Those About To Rock We Salute You
|]
it "works with '_neq' predicate" $ \(testEnvironment, _) ->
@ -339,20 +339,20 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums(where: {id: {_neq: 2, _in: [1, 2, 3]}}) {
id
title
Album(where: {AlbumId: {_neq: 2, _in: [1, 2, 3]}}) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums:
- id: 1
title: For Those About To Rock We Salute You
- id: 3
title: Restless and Wild
Album:
- AlbumId: 1
Title: For Those About To Rock We Salute You
- AlbumId: 3
Title: Restless and Wild
|]
it "works with '_lt' predicate" $ \(testEnvironment, _) ->
@ -362,18 +362,18 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums(where: {id: {_lt: 2}}) {
id
title
Album(where: {AlbumId: {_lt: 2}}) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums:
- id: 1
title: For Those About To Rock We Salute You
Album:
- AlbumId: 1
Title: For Those About To Rock We Salute You
|]
it "works with '_lte' predicate" $ \(testEnvironment, _) ->
@ -383,20 +383,20 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getArtists {
artists(where: {id: {_lte: 2}}) {
id
name
Artist(where: {ArtistId: {_lte: 2}}) {
ArtistId
Name
}
}
|]
)
[yaml|
data:
artists:
- id: 1
name: AC/DC
- id: 2
name: Accept
Artist:
- ArtistId: 1
Name: AC/DC
- ArtistId: 2
Name: Accept
|]
it "works with '_gt' predicate" $ \(testEnvironment, _) ->
@ -406,18 +406,18 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getArtists {
artists(where: {id: {_gt: 274}}) {
id
name
Artist(where: {ArtistId: {_gt: 274}}) {
ArtistId
Name
}
}
|]
)
[yaml|
data:
artists:
- id: 275
name: Philip Glass Ensemble
Artist:
- ArtistId: 275
Name: Philip Glass Ensemble
|]
it "works with '_gte' predicate" $ \(testEnvironment, _) ->
@ -427,20 +427,20 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getArtists {
artists(where: {id: {_gte: 274}}) {
id
name
Artist(where: {ArtistId: {_gte: 274}}) {
ArtistId
Name
}
}
|]
)
[yaml|
data:
artists:
- id: 274
name: Nash Ensemble
- id: 275
name: Philip Glass Ensemble
Artist:
- ArtistId: 274
Name: Nash Ensemble
- ArtistId: 275
Name: Philip Glass Ensemble
|]
describe "Order By Tests" $ do
@ -451,22 +451,22 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums(limit: 3, order_by: {id: asc}) {
id
title
Album(limit: 3, order_by: {AlbumId: asc}) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums:
- id: 1
title: For Those About To Rock We Salute You
- id: 2
title: Balls to the Wall
- id: 3
title: Restless and Wild
Album:
- AlbumId: 1
Title: For Those About To Rock We Salute You
- AlbumId: 2
Title: Balls to the Wall
- AlbumId: 3
Title: Restless and Wild
|]
it "works with order_by id desc" $ \(testEnvironment, _) ->
@ -476,22 +476,22 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbum {
albums(limit: 3, order_by: {id: desc}) {
id
title
Album(limit: 3, order_by: {AlbumId: desc}) {
AlbumId
Title
}
}
|]
)
[yaml|
data:
albums:
- id: 347
title: Koyaanisqatsi (Soundtrack from the Motion Picture)
- id: 346
title: 'Mozart: Chamber Music'
- id: 345
title: 'Monteverdi: L''Orfeo'
Album:
- AlbumId: 347
Title: Koyaanisqatsi (Soundtrack from the Motion Picture)
- AlbumId: 346
Title: 'Mozart: Chamber Music'
- AlbumId: 345
Title: 'Monteverdi: L''Orfeo'
|]
it "can order by an aggregate" $ \(testEnvironment, _) -> do
@ -502,9 +502,9 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getArtists {
artists(limit: 3, order_by: {albums_aggregate: {count: desc}}) {
name
albums_aggregate {
Artist(limit: 3, order_by: {Albums_aggregate: {count: desc}}) {
Name
Albums_aggregate {
aggregate {
count
}
@ -515,17 +515,17 @@ tests opts = describe "Queries" $ do
)
[yaml|
data:
artists:
- name: Iron Maiden
albums_aggregate:
Artist:
- Name: Iron Maiden
Albums_aggregate:
aggregate:
count: 21
- name: Led Zeppelin
albums_aggregate:
- Name: Led Zeppelin
Albums_aggregate:
aggregate:
count: 14
- name: Deep Purple
albums_aggregate:
- Name: Deep Purple
Albums_aggregate:
aggregate:
count: 11
|]
@ -538,30 +538,30 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query getAlbums {
albums(limit: 4, order_by: [{artist: {name: asc}}, {title: desc}]) {
artist {
name
Album(limit: 4, order_by: [{Artist: {Name: asc}}, {Title: desc}]) {
Artist {
Name
}
title
Title
}
}
|]
)
[yaml|
data:
albums:
- artist:
name: AC/DC
title: Let There Be Rock
- artist:
name: AC/DC
title: For Those About To Rock We Salute You
- artist:
name: Aaron Copland & London Symphony Orchestra
title: A Copland Celebration, Vol. I
- artist:
name: Aaron Goldberg
title: Worlds
Album:
- Artist:
Name: AC/DC
Title: Let There Be Rock
- Artist:
Name: AC/DC
Title: For Those About To Rock We Salute You
- Artist:
Name: Aaron Copland & London Symphony Orchestra
Title: A Copland Celebration, Vol. I
- Artist:
Name: Aaron Goldberg
Title: Worlds
|]
describe "Custom scalar types and operators" $ do
it "works with custom scalar types and comparison operators" $ \(testEnvironment, _) -> do
@ -573,16 +573,16 @@ tests opts = describe "Queries" $ do
testEnvironment
[graphql|
query MyQuery {
employees(where: {birth_date: {in_year: 1965}}) {
birth_date
last_name
Employee(where: {BirthDate: {in_year: 1965}}) {
BirthDate
LastName
}
}
|]
)
[yaml|
data:
employees:
- birth_date: '1965-03-03T00:00:00-08:00'
last_name: Johnson
Employee:
- BirthDate: '1965-03-03T00:00:00-08:00'
LastName: Johnson
|]

View File

@ -6,6 +6,8 @@ module Test.DataConnector.SelectPermissionsSpec
)
where
--------------------------------------------------------------------------------
import Data.Aeson (Value)
import Data.ByteString (ByteString)
import Data.List.NonEmpty qualified as NE

View File

@ -57,42 +57,35 @@ name : *source
kind: *backendTypeString
tables:
- table: [Album]
configuration:
custom_root_fields:
select: albums
select_by_pk: albums_by_pk
column_config:
AlbumId:
custom_name: id
Title:
custom_name: title
ArtistId:
custom_name: artist_id
object_relationships:
- name: artist
- name: Artist
using:
manual_configuration:
remote_table: [Artist]
column_mapping:
ArtistId: ArtistId
select_permissions:
- role: test-role
permission:
columns:
- AlbumId
- Title
- ArtistId
filter:
_exists:
_table: [Customer]
_where:
CustomerId:
_eq: X-Hasura-CustomerId
- table: [Artist]
configuration:
custom_root_fields:
select: artists
select_by_pk: artists_by_pk
column_config:
ArtistId:
custom_name: id
Name:
custom_name: name
array_relationships:
- name: albums
- name: Albums
using:
manual_configuration:
remote_table: [Album]
column_mapping:
ArtistId: ArtistId
- table: Playlist
- table: [Playlist]
array_relationships:
- name : Tracks
using:
@ -100,7 +93,7 @@ tables:
column: PlaylistId
table:
- PlaylistTrack
- table: PlaylistTrack
- table: [PlaylistTrack]
object_relationships:
- name: Playlist
using:
@ -111,17 +104,50 @@ tables:
remote_table: [Track]
column_mapping:
TrackId: TrackId
- table: Track
- table: Employee
configuration:
custom_root_fields:
select: employees
select_by_pk: employee_by_pk
column_config:
BirthDate:
custom_name: birth_date
LastName:
custom_name: last_name
- table: [Track]
- table: [Employee]
array_relationships:
- name: SupportRepForCustomers
using:
manual_configuration:
remote_table: [Customer]
column_mapping:
EmployeeId: SupportRepId
select_permissions:
- role: test-role
permission:
columns:
- EmployeeId
- FirstName
- LastName
- Country
filter:
SupportRepForCustomers:
Country:
_ceq: [ "$", "Country" ]
- table: [Customer]
object_relationships:
- name: SupportRep
using:
manual_configuration:
remote_table: [Employee]
column_mapping:
SupportRepId: EmployeeId
select_permissions:
- role: test-role
permission:
columns:
- CustomerId
- FirstName
- LastName
- Country
- SupportRepId
filter:
SupportRep:
Country:
_ceq: [ "$", "Country" ]
configuration:
*config
|]