Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 031bb51

Browse files
committed
return empty slice for many to many addresses
1 parent 6fcd613 commit 031bb51

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

‎db/ent/ent/schema/user.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package schema
22

33
import (
44
"context"
5+
"fmt"
6+
"time"
7+
58
"entgo.io/ent"
69
"entgo.io/ent/schema/edge"
710
"entgo.io/ent/schema/field"
811
"entgo.io/ent/schema/mixin"
9-
"fmt"
10-
"time"
1112
)
1213

1314
// User holds the schema definition for the User entity.

‎db/ent/many2Many.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
// ListM2M eager loads addresses for each user.
10-
// Generated sql:
10+
// By supplying a Debug() method, the generated sql are as follows:
1111
/*
1212
SELECT
1313
DISTINCT "entUsers"."id",

‎db/sqlc/manyToMany.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func (r *database) ListM2M(ctx context.Context) ([]*sqlx.UserResponseWithAddress
2121
MiddleName: u.MiddleName.String,
2222
LastName: u.LastName,
2323
Email: u.Email,
24+
Address: []*sqlx.AddressForCountry{},
2425
})
2526
}
2627

‎db/sqlx/manyToMany.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"database/sql"
66
"fmt"
7+
78
"github.com/jmoiron/sqlx"
89
)
910

@@ -57,6 +58,7 @@ func (r *database) ListM2M(ctx context.Context) ([]*UserResponseWithAddressesSql
5758
MiddleName: u.MiddleName.String,
5859
LastName: u.LastName,
5960
Email: u.Email,
61+
Address: []*AddressForCountry{},
6062
})
6163
}
6264

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /