Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose SQL type information in gotpl types #315

Open
nrolans opened this issue Sep 6, 2021 · 1 comment
Open

Expose SQL type information in gotpl types #315

nrolans opened this issue Sep 6, 2021 · 1 comment

Comments

@nrolans
Copy link

nrolans commented Sep 6, 2021

I have my own type for postgres inet but it is mapped to a string in the loader (similar to issue #122). I currently fork xo and remove inet from the case statement so that it matches the default case. I can take it from there in the same way I handle macaddr and cidr types. Another solution is to match on the table and field name in the go template. It is error-prone as I'd need to update the template every time a new field of this type is added.

Would it be possible to have access to the SQL type and nullable bool (and maybe more) in the go template Field struct? That would allow me to update the type as needed. This is already available in json due to the way it's generated, so not entirely unprecedented.

I have a similar issue with integers. We would like to use sql.NullInt32 for their null type. I understand that can't be made default as it was added later in go 1.13. Adding the sql type and nullable bool would help with this too.

@kenshaw
Copy link
Member

kenshaw commented Sep 6, 2021

We have plans to introduce a general type mapping functionality that would allow overriding the generated types, but have not had time to implement it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants