Rename "source" to "sourceType" for "kind": "Relationship". (#531)

## Description

To clarify the purpose of the `"source"` field, we've decided to rename
it to `"sourceType"`. This hopefully makes it clearer that the value
should be a type name.

`"source"` is still accepted as an alias in order to stop this from
being a breaking change.

I have added the aliasing capability for struct fields in
`opendds_derive`.

All test metadata has been updated to use `"sourceType"`, but I've added
one test case that uses `"source"` instead just to make sure that it
still works.

## Changelog

- Add a changelog entry (in the "Changelog entry" section below) if the
changes
  in this PR have any user-facing impact. See
[changelog
guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide).
- If no changelog is required ignore/remove this section and add a
  `no-changelog-required` label to the PR.

### Product

_(Select all products this will be available in)_

- [x] community-edition
- [x] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [ ] enhancement
- [ ] bugfix
- [x] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

- OpenDDS: The `"source"` field for relationships has been renamed to
`"sourceType"`. Metadata using `"source"` will continue to work as
usual, but new metadata should be authored with `"sourceType"` instead.

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

V3_GIT_ORIGIN_REV_ID: 305cbf7a62ee49a715e95ad892b8d00647f05cef
This commit is contained in:
Samir Talwar 2024-04-30 19:20:17 +02:00 committed by hasura-bot
parent ca61619c06
commit c4b659e12c
62 changed files with 1515 additions and 155 deletions

View File

@ -62,7 +62,7 @@ pub fn resolve(
} in &metadata_accessor.relationships
{
let qualified_relationship_source_type_name =
Qualified::new(subgraph.to_string(), relationship.source.to_owned());
Qualified::new(subgraph.to_string(), relationship.source_type.to_owned());
let object_representation = object_types_with_relationships
.get_mut(&qualified_relationship_source_type_name)
.ok_or_else(|| Error::RelationshipDefinedOnUnknownType {
@ -391,7 +391,7 @@ pub fn resolve_relationship(
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
source_type: &data_connector_type_mappings::ObjectTypeRepresentation,
) -> Result<Relationship, Error> {
let source_type_name = Qualified::new(subgraph.to_string(), relationship.source.clone());
let source_type_name = Qualified::new(subgraph.to_string(), relationship.source_type.clone());
let (relationship_target, source_data_connector, target_name) = match &relationship.target {
relationships::RelationshipTarget::Model(target_model) => {
let qualified_target_model_name = Qualified::new(

View File

@ -432,7 +432,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles_relationship",
"description": "Gets the corresponding articles of the author.",
"deprecated": {

View File

@ -430,7 +430,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles_relationship",
"description": "Gets the corresponding articles of the author.",
"target": {

View File

@ -362,7 +362,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Tracks",
"target": {
"model": {
@ -394,7 +394,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "Album",
"target": {
"model": {
@ -426,7 +426,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "TrackAlbums",
"target": {
"model": {
@ -604,7 +604,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Artist",
"target": {
"model": {

View File

@ -466,7 +466,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Tracks",
"target": {
"model": {
@ -498,7 +498,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "Album",
"target": {
"model": {
@ -530,7 +530,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "Genre",
"target": {
"model": {
@ -562,7 +562,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "TrackAlbums",
"target": {
"model": {
@ -719,7 +719,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Artist",
"target": {
"model": {

View File

@ -529,7 +529,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Tracks",
"target": {
"model": {
@ -561,7 +561,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "Album",
"target": {
"model": {
@ -593,7 +593,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "Genre",
"target": {
"model": {
@ -625,7 +625,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "TrackAlbums",
"target": {
"model": {
@ -803,7 +803,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Artist",
"target": {
"model": {

View File

@ -558,7 +558,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "Movies",
"target": {
"model": {

View File

@ -558,7 +558,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "Movies",
"target": {
"model": {

View File

@ -558,7 +558,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "Movies",
"target": {
"model": {

View File

@ -560,7 +560,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "Movies",
"target": {
"model": {

View File

@ -358,7 +358,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -383,7 +383,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {

View File

@ -330,7 +330,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {

View File

@ -348,7 +348,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {

View File

@ -269,7 +269,7 @@
},
{
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "MovieFromActor",
"target": {
"command": {

View File

@ -136,7 +136,7 @@
},
{
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "getMovieFromActor",
"target": {
"command": {

View File

@ -180,7 +180,7 @@
},
{
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "getMovieFromActor",
"target": {
"command": {
@ -209,7 +209,7 @@
},
{
"definition": {
"source": "commandMovie",
"sourceType": "commandMovie",
"name": "getActorsFromMovie",
"target": {
"command": {

View File

@ -139,7 +139,7 @@
},
{
"definition": {
"source": "commandMovie",
"sourceType": "commandMovie",
"name": "getActorsFromMovie",
"target": {
"command": {
@ -343,7 +343,7 @@
},
{
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "MovieFromActor",
"target": {
"command": {

View File

@ -338,7 +338,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "Movies",
"target": {
"model": {

View File

@ -312,7 +312,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "Movies",
"target": {
"model": {

View File

@ -302,7 +302,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "Movies",
"target": {
"model": {

View File

@ -242,7 +242,7 @@
},
{
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "MovieFromCommand",
"target": {
"command": {

View File

@ -338,7 +338,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "MultiMappingCheckAuthor",
"target": {
"model": {

View File

@ -631,7 +631,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -331,7 +331,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Artist",
"target": {
"model": {

View File

@ -281,7 +281,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -276,7 +276,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandActor",
"sourceType": "commandActor",
"name": "Movies",
"target": {
"model": {

View File

@ -242,7 +242,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -257,7 +257,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -281,7 +281,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -257,7 +257,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {
@ -289,7 +289,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {
@ -432,7 +432,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "newspaper_article",
"sourceType": "newspaper_article",
"name": "Author",
"target": {
"model": {
@ -464,7 +464,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "NewspaperArticles",
"target": {
"model": {

View File

@ -307,7 +307,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -409,7 +409,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {

View File

@ -363,7 +363,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {

View File

@ -562,7 +562,7 @@
{
"kind": "Relationship",
"definition": {
"source": "movie_analytics",
"sourceType": "movie_analytics",
"name": "MovieFromCommand",
"target": {
"command": {

View File

@ -405,7 +405,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandMovie",
"sourceType": "commandMovie",
"name": "AnalyticsFromMovie",
"target": {
"model": {
@ -436,7 +436,7 @@
{
"kind": "Relationship",
"definition": {
"source": "movie_analytics",
"sourceType": "movie_analytics",
"name": "MovieFromCommand",
"target": {
"command": {

View File

@ -876,7 +876,7 @@
"version": "v1",
"definition": {
"name": "Actors",
"source": "movie",
"sourceType": "movie",
"target": {
"model": {
"name": "Actors",
@ -908,7 +908,7 @@
"version": "v1",
"definition": {
"name": "Analytics",
"source": "movie",
"sourceType": "movie",
"target": {
"model": {
"name": "MovieAnalytics",
@ -940,7 +940,7 @@
"version": "v1",
"definition": {
"name": "MovieFromCommand",
"source": "actor",
"sourceType": "actor",
"target": {
"command": {
"name": "get_movie_by_id"
@ -969,7 +969,7 @@
"version": "v1",
"definition": {
"name": "ActorsFromCommand",
"source": "movie",
"sourceType": "movie",
"target": {
"command": {
"name": "get_actors_by_movie"

View File

@ -517,7 +517,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "staff_member",
"sourceType": "staff_member",
"name": "favourite_artist",
"target": {
"model": {

View File

@ -553,7 +553,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "Movie",
"target": {
"model": {
@ -585,7 +585,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Actors",
"target": {
"model": {
@ -617,7 +617,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Analytics",
"target": {
"model": {
@ -665,7 +665,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie_analytics",
"sourceType": "movie_analytics",
"name": "Movie",
"target": {
"model": {

View File

@ -548,7 +548,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "Movie",
"target": {
"model": {
@ -580,7 +580,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Actors",
"target": {
"model": {
@ -612,7 +612,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Analytics",
"target": {
"model": {
@ -644,7 +644,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie_analytics",
"sourceType": "movie_analytics",
"name": "Movie",
"target": {
"model": {

View File

@ -582,7 +582,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "Movie",
"target": {
"model": {
@ -614,7 +614,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Actors",
"target": {
"model": {
@ -646,7 +646,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Analytics",
"target": {
"model": {
@ -678,7 +678,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie_analytics",
"sourceType": "movie_analytics",
"name": "Movie",
"target": {
"model": {

View File

@ -810,7 +810,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "Movie",
"target": {
"model": {
@ -842,7 +842,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "FavouriteAuthor",
"target": {
"model": {
@ -874,7 +874,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Actors",
"target": {
"model": {
@ -906,7 +906,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Analytics",
"target": {
"model": {
@ -938,7 +938,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie_analytics",
"sourceType": "movie_analytics",
"name": "Movie",
"target": {
"model": {

View File

@ -256,7 +256,7 @@
"version": "v1",
"definition": {
"name": "Albums",
"source": "Artist",
"sourceType": "Artist",
"target": {
"model": {
"relationshipType": "Array",
@ -288,7 +288,7 @@
"version": "v1",
"definition": {
"name": "Album2",
"source": "Album",
"sourceType": "Album",
"target": {
"model": {
"subgraph": "connector_2",

View File

@ -632,7 +632,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "Movie",
"target": {
"model": {
@ -664,7 +664,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Actors",
"target": {
"model": {
@ -696,7 +696,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie",
"sourceType": "movie",
"name": "Analytics",
"target": {
"model": {
@ -728,7 +728,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "movie_analytics",
"sourceType": "movie_analytics",
"name": "Movie",
"target": {
"model": {

View File

@ -335,7 +335,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Tracks",
"target": {
"model": {
@ -368,7 +368,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Artist",
"target": {
"model": {

View File

@ -447,7 +447,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Tracks",
"target": {
"model": {
@ -479,7 +479,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "Album",
"target": {
"model": {
@ -512,7 +512,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Artist",
"target": {
"model": {

View File

@ -327,7 +327,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "Album",
"target": {
"model": {
@ -480,7 +480,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Tracks",
"target": {
"model": {
@ -513,7 +513,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Artist",
"target": {
"model": {

View File

@ -5174,7 +5174,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandArticle",
"sourceType": "commandArticle",
"name": "article",
"description": "commandArticle - article relationship description",
"target": {
@ -5205,7 +5205,7 @@
},
{
"definition": {
"source": "article",
"sourceType": "article",
"name": "AuthorFromCommand",
"description": "AuthorFromCommand description",
"target": {
@ -5237,7 +5237,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {
@ -5269,7 +5269,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {
@ -5302,7 +5302,7 @@
"version": "v1",
"definition": {
"name": "Artist",
"source": "Album",
"sourceType": "Album",
"target": {
"model": {
"relationshipType": "Object",
@ -5334,7 +5334,7 @@
"version": "v1",
"definition": {
"name": "Albums",
"source": "Artist",
"sourceType": "Artist",
"target": {
"model": {
"relationshipType": "Array",
@ -5366,7 +5366,7 @@
"version": "v1",
"definition": {
"name": "Employee",
"source": "Customer",
"sourceType": "Customer",
"target": {
"model": {
"relationshipType": "Object",
@ -5398,7 +5398,7 @@
"version": "v1",
"definition": {
"name": "Customers",
"source": "Employee",
"sourceType": "Employee",
"target": {
"model": {
"relationshipType": "Array",
@ -5430,7 +5430,7 @@
"version": "v1",
"definition": {
"name": "Employee",
"source": "Employee",
"sourceType": "Employee",
"target": {
"model": {
"relationshipType": "Object",
@ -5462,7 +5462,7 @@
"version": "v1",
"definition": {
"name": "Employees",
"source": "Employee",
"sourceType": "Employee",
"target": {
"model": {
"relationshipType": "Array",
@ -5494,7 +5494,7 @@
"version": "v1",
"definition": {
"name": "Customer",
"source": "Invoice",
"sourceType": "Invoice",
"target": {
"model": {
"relationshipType": "Object",
@ -5526,7 +5526,7 @@
"version": "v1",
"definition": {
"name": "Invoices",
"source": "Customer",
"sourceType": "Customer",
"target": {
"model": {
"relationshipType": "Array",
@ -5558,7 +5558,7 @@
"version": "v1",
"definition": {
"name": "Invoice",
"source": "InvoiceLine",
"sourceType": "InvoiceLine",
"target": {
"model": {
"relationshipType": "Object",
@ -5590,7 +5590,7 @@
"version": "v1",
"definition": {
"name": "InvoiceLines",
"source": "Invoice",
"sourceType": "Invoice",
"target": {
"model": {
"relationshipType": "Array",
@ -5622,7 +5622,7 @@
"version": "v1",
"definition": {
"name": "Track",
"source": "InvoiceLine",
"sourceType": "InvoiceLine",
"target": {
"model": {
"relationshipType": "Object",
@ -5654,7 +5654,7 @@
"version": "v1",
"definition": {
"name": "InvoiceLines",
"source": "Track",
"sourceType": "Track",
"target": {
"model": {
"relationshipType": "Array",
@ -5686,7 +5686,7 @@
"version": "v1",
"definition": {
"name": "Playlist",
"source": "PlaylistTrack",
"sourceType": "PlaylistTrack",
"target": {
"model": {
"relationshipType": "Object",
@ -5718,7 +5718,7 @@
"version": "v1",
"definition": {
"name": "PlaylistTracks",
"source": "Playlist",
"sourceType": "Playlist",
"target": {
"model": {
"relationshipType": "Array",
@ -5750,7 +5750,7 @@
"version": "v1",
"definition": {
"name": "Track",
"source": "PlaylistTrack",
"sourceType": "PlaylistTrack",
"target": {
"model": {
"relationshipType": "Object",
@ -5782,7 +5782,7 @@
"version": "v1",
"definition": {
"name": "PlaylistTracks",
"source": "Track",
"sourceType": "Track",
"target": {
"model": {
"relationshipType": "Array",
@ -5814,7 +5814,7 @@
"version": "v1",
"definition": {
"name": "Album",
"source": "Track",
"sourceType": "Track",
"target": {
"model": {
"relationshipType": "Object",
@ -5846,7 +5846,7 @@
"version": "v1",
"definition": {
"name": "Tracks",
"source": "Album",
"sourceType": "Album",
"target": {
"model": {
"relationshipType": "Array",
@ -5878,7 +5878,7 @@
"version": "v1",
"definition": {
"name": "Genre",
"source": "Track",
"sourceType": "Track",
"target": {
"model": {
"relationshipType": "Object",
@ -5910,7 +5910,7 @@
"version": "v1",
"definition": {
"name": "Tracks",
"source": "Genre",
"sourceType": "Genre",
"target": {
"model": {
"relationshipType": "Array",
@ -5942,7 +5942,7 @@
"version": "v1",
"definition": {
"name": "MediaType",
"source": "Track",
"sourceType": "Track",
"target": {
"model": {
"relationshipType": "Object",
@ -5974,7 +5974,7 @@
"version": "v1",
"definition": {
"name": "Tracks",
"source": "MediaType",
"sourceType": "MediaType",
"target": {
"model": {
"relationshipType": "Array",
@ -6006,7 +6006,7 @@
"version": "v1",
"definition": {
"name": "topology_topology",
"source": "topology_layer",
"sourceType": "topology_layer",
"target": {
"model": {
"relationshipType": "Object",
@ -6038,7 +6038,7 @@
"version": "v1",
"definition": {
"name": "topology_layers",
"source": "topology_topology",
"sourceType": "topology_topology",
"target": {
"model": {
"relationshipType": "Array",

View File

@ -352,6 +352,18 @@ fn test_disallow_conflicting_object_field_name_and_relationship_name() -> anyhow
Ok(())
}
#[test]
fn test_allow_metadata_with_deprecated_field() -> anyhow::Result<()> {
// {"kind": "Relationship", "source": "<source>"} is deprecated in favor of "sourceType"
let metadata =
read_metadata("validate_metadata_artifacts/metadata_with_deprecated_field.json")?;
let gds = GDS::new(metadata);
gds?; // assert that it is OK
Ok(())
}
fn read_metadata(path: &str) -> anyhow::Result<open_dds::Metadata> {
let json = read_file(path)?;
let value = open_dds::Metadata::from_json_str(&json)?;

View File

@ -1026,7 +1026,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {
@ -1058,7 +1058,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -1199,7 +1199,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "commandArticle",
"sourceType": "commandArticle",
"name": "article",
"target": {
"model": {
@ -1830,7 +1830,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {
@ -1862,7 +1862,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {
@ -2164,7 +2164,7 @@
},
{
"definition": {
"source": "Artist",
"sourceType": "Artist",
"name": "Albums",
"target": {
"model": {
@ -2196,7 +2196,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Tracks",
"target": {
"model": {
@ -2228,7 +2228,7 @@
},
{
"definition": {
"source": "Album",
"sourceType": "Album",
"name": "Artist",
"target": {
"model": {
@ -2260,7 +2260,7 @@
},
{
"definition": {
"source": "Track",
"sourceType": "Track",
"name": "Album",
"target": {
"model": {

View File

@ -345,7 +345,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "Movies",
"target": {
"model": {

View File

@ -340,7 +340,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "actor",
"sourceType": "actor",
"name": "Movies",
"target": {
"model": {

View File

@ -68,7 +68,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "Article",
"sourceType": "Article",
"name": "author",
"target": {
"model": {

View File

@ -68,7 +68,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "Article",
"sourceType": "Article",
"name": "author",
"target": {
"model": {

View File

@ -46,7 +46,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "Foo",
"sourceType": "Foo",
"name": "foo",
"target": {
"model": {

View File

@ -553,7 +553,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"sourceType": "author",
"name": "Articles",
"target": {
"model": {
@ -585,7 +585,7 @@
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "article",
"sourceType": "article",
"name": "Author",
"target": {
"model": {

View File

@ -2116,7 +2116,7 @@
"required": [
"mapping",
"name",
"source",
"sourceType",
"target"
],
"properties": {
@ -2128,7 +2128,7 @@
}
]
},
"source": {
"sourceType": {
"description": "The source type of the relationship.",
"allOf": [
{

View File

@ -246,7 +246,9 @@ pub struct RelationshipV1 {
/// The name of the relationship.
pub name: RelationshipName,
/// The source type of the relationship.
pub source: CustomTypeName,
#[serde(alias = "source")]
#[opendd(alias = "source")]
pub source_type: CustomTypeName,
/// The target of the relationship.
pub target: RelationshipTarget,
/// The mapping configuration of source to target for the relationship.

View File

@ -27,6 +27,7 @@ struct StructOpts {
struct FieldOpts {
default: Option<bool>,
rename: Option<String>,
alias: Option<String>,
#[darling(default)]
json_schema: JsonSchemaFieldOpts,
}
@ -149,6 +150,7 @@ pub struct NamedField<'a> {
pub field_name: &'a syn::Ident,
pub field_type: &'a syn::Type,
pub renamed_field: String,
pub field_alias: Option<String>,
pub is_default: bool,
pub is_optional: bool,
pub default_exp: Option<syn::Expr>,
@ -166,8 +168,8 @@ impl<'a> NamedField<'a> {
.ok_or_else(|| syn::Error::new_spanned(field, "field does not have an identifier"))?;
let renamed_field = field_opts
.rename
.clone()
.unwrap_or_else(|| field_name.to_string().to_case(Case::Camel));
let field_alias = field_opts.alias;
let is_default = field_opts.default.unwrap_or(false);
let is_optional = is_option_type(&field.ty);
let default_exp = field_opts.json_schema.default_exp;
@ -175,6 +177,7 @@ impl<'a> NamedField<'a> {
field_name,
field_type,
renamed_field,
field_alias,
is_default,
is_optional,
default_exp,

View File

@ -46,24 +46,24 @@ fn impl_deserialize_named_fields<'a>(
quote! {
let mut __object_map = match json {
serde_json::Value::Object(map) => map,
_ => {
return Err(open_dds::traits::OpenDdDeserializeError {
error: serde::de::Error::invalid_type(
serde::de::Unexpected::Other("not an object"),
&"object",
),
path: open_dds::traits::JSONPath::new(),
})
}
_ => {
return Err(open_dds::traits::OpenDdDeserializeError {
error: serde::de::Error::invalid_type(
serde::de::Unexpected::Other("not an object"),
&"object",
),
path: open_dds::traits::JSONPath::new(),
})
},
};
let __value = #named_fields_value;
let __remaing_keys = __object_map.keys().cloned().collect::<Vec<_>>();
let __remaining_keys = __object_map.keys().cloned().collect::<Vec<_>>();
// Check for unexpected keys
if !__remaing_keys.is_empty() {
if !__remaining_keys.is_empty() {
return Err(open_dds::traits::OpenDdDeserializeError {
error: serde::de::Error::custom(format!(
"unexpected keys: {}; expecting: {}",
__remaing_keys.join(", "),
__remaining_keys.join(", "),
[#(#expected_fields),*].join(", "),
)),
path: open_dds::traits::JSONPath::new(),
@ -83,10 +83,22 @@ fn generate_named_fields_value<'a>(
let field_name_str = field.renamed_field.as_str();
let field_value_deserialize = quote! {
open_dds::traits::OpenDd::deserialize(__value).map_err(|e| open_dds::traits::OpenDdDeserializeError{
path: e.path.prepend_key(#field_name_str.to_string()),
error: e.error,
})
|__value| open_dds::traits::OpenDd::deserialize(__value)
.map_err(|e| open_dds::traits::OpenDdDeserializeError {
path: e.path.prepend_key(#field_name_str.to_string()),
error: e.error,
})
};
let deserialize_field = quote! {
__object_map.remove(#field_name_str).map(#field_value_deserialize)
};
let deserialize_alias = match &field.field_alias {
None => quote! {},
Some(alias) => quote! {
.or_else(|| __object_map.remove(#alias).map(#field_value_deserialize))
},
};
let field_value_fallback = if field.is_default {
@ -107,7 +119,7 @@ fn generate_named_fields_value<'a>(
};
field_deserializations.push(quote! {
#field_name: __object_map.remove(#field_name_str).map(|__value| #field_value_deserialize).transpose()?#field_value_fallback
#field_name: #deserialize_field #deserialize_alias .transpose()? #field_value_fallback
});
}