On Friday, November 8, 2013 11:52:10 AM UTC-8, Snarke wrote: > On Oct 15, 2013, at 7:07 , Jeremy Evans wrote: > > > Well, that's two issues. The first is not typecasting UUIDs (leaving > them as plain strings). A pg_uuid extension could be added that turned > those strings into UUID objects, though I'm not sure how much that would > help. > > Er, *is* there some existing code related to "UUID objects?" I tried > looking for it, but all I've found is a gem for generating UUIDs which > returns strings. Since a UUID is fundamentally a big number, with the > string form more a matter of human convenience, there's a voice in the back > of my head that is muttering that they ought to actually be stored that > way. > > I started using UUIDs instead of sequential integers as my primary table > keys a couple years ago. Postgres and Sequel are handing them back to me as > strings, but, since one ought not to do things like concatenate UUIDs, it > seems to me it would be better if my UUID keys were coming back as some > kind of specific UUID object, esp. since it *is* "type uuid" inside > Postgres. > > Or am I just trying to make more work for myself?
Personally, I think you are trying to make more work for yourself. There is no existing code in Sequel related to UUID objects. The pg driver returns column values as strings, so unless Sequel does a conversion, you are left with a string. Sequel doesn't convert the uuid type, which is why you get strings for it. A pg_uuid extension as I mentioned above could make it so Sequel will take such a string and return a UUID object automatically. I just don't see the benefits of that approach. Your argument that because you shouldn't concatenate UUIDs they shouldn't be returned as strings doesn't make sense to me. You shouldn't add/substract/multiply/divide primary key integers, but Sequel returns those as plain integers that can be used in such a way. Wrapping in another type just to make it more difficult for you to do something you shouldn't be doing isn't commonly done in ruby, though there are programming languages such as Haskell where it is more common. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/groups/opt_out.
