php-cassandra-binary icon indicating copy to clipboard operation
php-cassandra-binary copied to clipboard

User Defined Type unpacking not working

Open Resiak opened this issue 10 years ago • 2 comments

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

Resiak avatar Oct 29 '14 11:10 Resiak

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?

LarsFronius avatar Nov 14 '14 09:11 LarsFronius

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' } });

steambao avatar Jan 11 '15 16:01 steambao