-
Notifications
You must be signed in to change notification settings - Fork 552
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
Why is uuid/char translated as string? #58
Comments
Hi @mvdan. First let me apologize for not getting back to you quicker. I saw this issue right away and then promptly got distracted by other things. I'm going to respond to both issues here since they're essentially the same kind of problem. And the first thing I want to say is that I agree with you that there are inefficiencies in the in-memory representation. However it's a trade-off on multiple levels. The reason they behave like they do currently is that was the path of least resistance to get it working for these cases. Let me elaborate on the reasons: UUID:
Now these things could be circumvented by using []byte but then you've lost a lot of the reason for making the change since you're saving some 3 integers or so by not having the slice header. And recall that you'll always have multiple allocations of this anyway since you'll be forced into converting to slice all over the place (as usual when using non-slices). Char:
In summary the positive side of these changes are:
The downsides are:
I recognize the inefficiencies, and hopefully you recognize the tradeoffs that I've outlined and that neither is an ideal state. I don't want to say we'll never do this because this kind of inefficiency makes me really sad but I think we need some more data on whether or not this amounts to being a bottleneck in real-world applications. I'm sure there's some awful cases like a table with 80 char(1) columns... but I'd like to see something in the wild where this is hurting enough to make the change. I think rather than have this, I'd prefer a mechanism whereby users can select the types generated via config files - but that has it's own downsides in terms of complexity. Thoughts? |
Ah, didn't know that.
JSON/TOML and the rest would be covered by the Text one. And I don't know why Binary would be important here - currently it's just the string version, so you could just use Text as well.
Remember that the
Depends on the use-case. My understanding is that right now there is one stringification and allocation when gathering the fields from postgres. If we used
I would add the ability to use
I understand that's only because
Complicates how? There would be usability gains. If
If this is a problem, you could always fall back to the text marshaling which is what is currently done, right?
I don't know anything about that :) I'm not going to insist, so feel free to close this issue if you want to decline this request/proposal. This was more of a "I wonder why they do it this way" issue. I have a different view of the ups and downs of Thanks again! |
Also, since you merged the
I understood that If |
You're right about serialization I THINK. Having said that I've never had the TextMarshal work for JSON encoding for me. Not sure why but I'm sure I tried several times. Going to test this again :) Anyway. I'm going to think about this a little more with renewed enthusiasm about |
Hey @mvdan. We've been busy on other projects so let this issue drift a little. Did a bit more research on this one, we're good to go on all fronts. Aside from it being a breaking and just an optimization forgive me for a little more drift :) The facts we gathered were all correct -and- I found that the TextMarshaler problems I've seen in the past were probably my own doing. The information_schema data is also sufficient. We'll get to this one. |
Awesome! I assume you're talking about |
I still want the discussion searchable so that we can point to it later. Looked at UUID again and found several other negatives, so definitely not going to do that unless there's solid data and people having trouble keeping a lot of these in ram for long periods of time. Starting on "char" implementation. |
If I use a
uuid
(as a primary key) in a postgres table, sqlboiler generates astring
field in the model. Is there a reasoning behind this?I'm not too bothered by this, but I think it should either be
[16]byte
or atype UUID [16]byte
. It would make using https://github.com/satori/go.uuid easier, and it would consume less memory as it would be 16 bytes instead of 36 bytes (characters) plus the string header.CC @teasherm
The text was updated successfully, but these errors were encountered: