Azure / Azure/data-api-builder

[Bug]: Creating a relationship to the same table twice causes null data.

Abierto
#1,718 5 comentarios 0 reacciones 1 asignado Reclamado por @seantleonard Ver en GitHub
bug cri triage
Lenguaje dominante
C#
Estrellas
1.5k
Forks
370
Merge medio
3 d 22 h
PR fusionados (30 d)
9

Descripción

### 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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.