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

User Defined Type unpacking not working #39

Open
Resiak opened this issue Oct 29, 2014 · 2 comments
Open

User Defined Type unpacking not working #39

Resiak opened this issue Oct 29, 2014 · 2 comments

Comments

@Resiak
Copy link

Resiak commented Oct 29, 2014

Hi,

I've just created an UDT to use into my application but it seems there is something wrong when retrieving the data.
The UDT has a very simple structure:

CREATE TYPE mytype (a int, b text);

I've then run the insert command and I can see (using Datastax DevCenter) that the data in the table looks right, infact in the column I have something like {a: 125, b: '3'}.
When unpacking though I get an array with value string(4) "}"

I've also tried to use my UDT into a map, but I've got a similar result.
I'm using Cassandra 2.1.0

@LarsFronius
Copy link
Collaborator

Hey @Resiak - can you send me a bit of code, including the inserts you are doing so I can write a regression test for this and work on it?

@steambao
Copy link

Here is an example which I'm having trouble with.

If there are two or more results in the set (like the first insert record), I get a null result.
If there is only one one result in the set (like the second insert record), I get only the first field in the User Defined Type like below:

public 'phone_numbers' =>
array (size=1)
0 => string 'Home' (length=4)

Are User defined types supported? Has anyone had success with them?


-- User Defined Type
CREATE TYPE phone_number (
type text,
number text
);

-- User Table
CREATE TABLE IF NOT EXISTS user(
username text,
password text,
phone_numbers set<frozen<phone_number>>,
PRIMARY KEY (username)
);

-- Example Insert Data
INSERT INTO user(username, password, phone_numbers)
VALUES ('test', 'test', {
{
type: 'Home',
number: '000111222'
},
{
type: 'Work',
number: '1111222333'
}
});
INSERT INTO user(username, password, phone_numbers)
VALUES ('test2', 'test2', {
{
type: 'Office',
number: '333222111'
}
});

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

3 participants