firebase / firebase/firebase-tools

Data Connect Swift Generation Struct Property Name Conflict

Open
#10,341 4 comments 0 reactions 0 assignees View on GitHub
api: dataconnect reproducible type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:15.14.0**

**Platform:macOS**

### [REQUIRED] Test case

Starting with the codelab for iOS: https://firebase.google.com/codelabs/firebase-dataconnect-ios#0

### [REQUIRED] Steps to reproduce
1. Modify the Review table to have another property that is also a User:
```
# Reviews is a join table between User and Movie.
# It has a composite primary keys `userUid` and `movieId`.
# A user can leave reviews for many movies. A movie can have reviews from many users.
# User <-> Review is a one-to-many relationship
# Movie <-> Review is a one-to-many relationship
# Movie <-> User is a many-to-many relationship
type Review @table(name: "Reviews", key: ["movie", "user"]) {
user: User!
otherUser: User!
# The user field adds the following foreign key field. Feel free to uncomment and customize it.
# userUid: String!
movie: Movie!
# The movie field adds the following foreign key field. Feel free to uncomment and customize it.
# movieId: UUID!
rating: Int
reviewText: String
reviewDate: Date! @default(expr: "request.time")
}
```
and correct the AddReview query:
```
mutation AddReview($movieId: UUID!, $rating: Int!, $reviewText: String!)
@auth(level: USER) {
review_upsert(
data: {
userId_expr: "auth.uid"
otherUserId_expr: "auth.uid"
movieId: $movieId
rating: $rating
reviewText: $reviewText
# reviewDate defaults to today in the schema. No need to set it manually.
}
)
}
```
2. Create the following query:
```
query ListReviewsRepro @auth(level: PUBLIC) {
reviews {
rating
reviewText
user { id username }
otherUser { id username }
}
}
```
3. Generate the sdk for swift

### [REQUIRED] Expected behavior

The User structs underneath the ListReviewsReproQuery class should have unique names like generating for Android creates:
```
@kotlinx.serialization.Serializable
public data class User(

val id: String,
val username: String
) {


}

@kotlinx.serialization.Serializable
public data class OtherUser(

val id: String,
val username: String
) {


}
```

### [REQUIRED] Actual behavior

The same name is given to struct for both the user and other user properties with the ListReviewsReproQuery. This prevents the iOS code from being able to build

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.