You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include getters and setters with models so we may work with interfaces instead of specific structs #2466
Selecting all fields and a subset of fields for the same table yields different structs. Currently, we're required to write a mapper function which transforms the row(s) in to an abstraction our applications can understand - however, if sqlc was to provide getters and setters, we'd be able to define interfaces which the results conform to and leave a lot of the heavy lifting to go.
Please see the example below:
CREATETABLE `products`
(
`name`varchar(255) NOT NULL,
`price`int(11) NOT NULL
)
For this particular problem extending the template for structs to include getters and setters would be sufficient, however - it may be a better idea to allow the extension of the template via the config file instead?
What database engines need to be changed?
PostgreSQL, MySQL
What programming language backends need to be changed?
changed the title [-]Include getters and setters with models so methods can work with interfaces instead of specific types[/-][+]Include getters and setters with models so we can work with interfaces instead of specific types[/+]on Jul 15, 2023
changed the title [-]Include getters and setters with models so we can work with interfaces instead of specific types[/-][+]Include getters and setters with models so we may work with interfaces instead of specific structs[/+]on Jul 16, 2023
Activity
[-]Include getters and setters with models so methods can work with interfaces instead of specific types[/-][+]Include getters and setters with models so we can work with interfaces instead of specific types[/+][-]Include getters and setters with models so we can work with interfaces instead of specific types[/-][+]Include getters and setters with models so we may work with interfaces instead of specific structs[/+]kyleconroy commentedon Sep 20, 2023
Closed via #2471 (comment)