Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Support for custom types (UUID, etc) #52

Open
oharlem opened this issue Jan 10, 2016 · 1 comment
Open

Support for custom types (UUID, etc) #52

oharlem opened this issue Jan 10, 2016 · 1 comment

Comments

@oharlem
Copy link

oharlem commented Jan 10, 2016

Hi,

I'm using Cassandra with OrientDB in one system and have to handle uuid<->string conversions throughout the app having to store as a string in OrientDB, while using native uuid/timeuuid in Cassandra.
It would be great to be able to use actual UUID type with queries, not a string value.

Currently:

  1. There's an error if I'm trying to bind a UUID value, ex.
    ...Command(orient.NewSQLCommand(INSERT INTO Users SET userID = ?, p.UserID))
  2. Workaround is to convert to a string manually:
    ....Command(orient.NewSQLCommand(INSERT INTO Users SET userID = ?, p.UserID.String()))
  3. On reading from a query, need to read as a string value and then to parse into UUID again, ex. uuid.Parse(uuidStr).

Thank you,
D.

@dennwc
Copy link
Collaborator

dennwc commented Jan 10, 2016

Hi @mpmlj ,

For case 3 you can use RegisterMapDecoderHook to provide function that can converts strings to UUID type (or vice versa). This will help to decode Documents to maps/structs with UUID. Still, Documents itself will contain raw string values.

For case 1-2 I think the right way will be to allow conversion to string via TextMarshaler interface. Does the package you are using provides implementation for this interface?

@dennwc dennwc self-assigned this Jan 10, 2016
@dennwc dennwc changed the title [ feature request ] Possibility to bind UUID Support for custom types (UUID, etc) Jan 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants