GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Support for custom models · Issue #755 · sqlc-dev/sqlc Open Labels enhancementNew feature or requestNew feature or request DescriptionExample:
-- name: ListRolesWithPermissions :many -- model: Roles -- path: internal/domain/roles SELECT r.role_id, r.display_name, r.description, array_agg(permissions.method)::text[] AS permissions FROM roles r LEFT JOIN permissions USING (role_id) GROUP BY r.role_id; -- name ListRoles :many -- model: Roles -- path: internal/domain/roles SELECT role_id, display_name, description FROM roles; /* returned colums exists in the model so we can reuse it */ It isn't generated file! type Role struct { RoleID uuid.UUID // here we can add some custom struct tags and methods DisplayName string Description string Permissions []sql.NullString // using []string throws an error if an array is empty } Generated method func (q *Queries) ListRoles(ctx context.Context) ([]roles.Role, error) P.S. These features can be useful because with it we can both use sqlc and follow Clean Architecture. And reuse structs for tables for complex queries with joins. So my question is if I'd correctly implement this functionality would you approve PR (I'm asking because this feature can be not in the spirit of the project) Reacted by Miha Vrhovnik, Aleksandr Baryshnikov, kejith, Oscar Beaumont, Patrick Veverka, Itamar Maltz, Dmitry, David Penn, Said Saifi, Thomas Sörensen and 54 more Reacted by kejith, H.R. Shadhin, Alisher Muzaffarov, James Lee, Leo, Pavlo Dosenko, renxzen and anurag-dalvi Activity
MetadataMetadataAssigneesLabelsenhancementNew feature or requestNew feature or request TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |