ariga/ogent

Generated field name casing is wrong in some cases

swalkerhppr opened this issue · 0 comments

Ogen has different casing rules than ent/entoas. If you have a field with any of the following, generation will fail because the ent/entoas casing is different.

rules = [...]string{
		"ACL", "API", "ASCII", "AWS", "CPU", "CSS", "DNS", "EOF", "GB", "GUID",
		"HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "KB", "LHS", "MAC", "MB",
		"QPS", "RAM", "RHS", "RPC", "SLA", "SMTP", "SQL", "SSH", "SSO", "TLS",
		"TTL", "UI", "UID", "URI", "URL", "UTF8", "UUID", "VM", "XML", "XMPP",
		"XSRF", "XSS", "SMS", "CDN", "TCP", "UDP", "DC", "PFS", "P2P",
		"SHA256", "SHA1", "MD5", "SRP", "2FA", "OAuth", "OAuth2",

		"PNG", "JPG", "GIF", "MP4", "WEBP",
	}

From: https://github.com/ogen-go/ogen/blob/425b5bb1ce73a9e48065457b7abcd9e424f8b2b5/internal/naming/rules.go#L14

For instance, having a field called "md5" results in ret.Md5 = e.Md5 , but it should generate ret.MD5 = e.Md5.

I looked for an easy way to convert a string to the ogen format, but it doesn't seem like there are any exported functions from ogen to apply the naming rules.

I am going to work around it by adding a lookup table in my fork, but I'm not sure if that is the full solution to the issue.