evseevnn-zz / php-cassandra-binary

PHP library for Cassandra database via a binary protocol.
http://evseevnn.github.io/php-cassandra-binary/
MIT License
69 stars 33 forks source link

User Defined Type unpacking not working #39

Open Resiak opened 10 years ago

Resiak commented 10 years ago

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 commented 10 years ago

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 commented 9 years ago

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