Azure / Azure/data-api-builder
[Bug]: Creating a relationship to the same table twice causes null data.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 370
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 8
Description
### What happened?
Love this project!
Though I am encountering an issue.
I have an Orders table which has a two columns CountryTypeId and ShippingCountryTypeId.
I have a CountryTypes table which lists countries.
My C# Order model has a CountryType member and a ShippingCountryType member.
```
CountryType () {
int CountryTypeId
string CountryTypeName
string CountryTypeCode
}
```
The goal is to fill these two members from a graphQl request. I do not have a join table in the database.
I want to pull data from CountryTypes table twice (2 joins), essentially, once for each the matching CountryTypeId and another for the ShippingCountryTypeId.
My dab.config looks like this:
```
"Order": {
"source": {
..... for brevity
},
"graphql": {
"enabled": true,
..... for brevity
}
},
"CountryType": {
"cardinality": "one",
"target.entity": "CountryType",
"source.fields": [
"CountryTypeId"
],
"target.fields": [
"CountryTypeId"
],
"linking.source.fields": ["CountryTypeId"],
"linking.target.fields": ["CountryTypeId"]
},
"ShippingCountryType": {
"cardinality": "one",
"target.entity": "CountryType",
"source.fields": [
"ShippingCountryTypeId"
],
"target.fields": [
"CountryTypeId"
],
"linking.source.fields": ["ShippingCountryTypeId"],
"linking.target.fields": ["CountryTypeId"]
}
}
```
Graphql retuned:
```
"CountryType": null,
"ShippingCountryType": null
```
If I do:
```
"CountryType": {
"cardinality": "one",
"target.entity": "CountryType",
"source.fields": [
"CountryTypeId"
],
"target.fields": [
"CountryTypeId"
]
}
}
```
It returns the proper data.
### Version
0.8.50+69f45352c90fae016c33c4e6c1294105898269cc
### What database are you using?
Azure SQL
### What hosting model are you using?
Local (including CLI)
### Which API approach are you accessing DAB through?
GraphQL
### Relevant log output
_No response_
### Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Contributor guide
Assessment
This issue has not been assessed yet.