-
Notifications
You must be signed in to change notification settings - Fork 24
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
Straightforward distinguishing between arrays and maps #89
Comments
From what i see, |
Imagine space where tuples consist of 2 fields: NUM primary key and TABLE "payload". $fields = [];
$fields[0] = 'field0Val';
$fields[5] = 'field5Val';
$field[7] = 'field7Val';
$fields = [];
$fields[0] = 'field0Val';
$fields[1] = 'field1Val';
$field[2] = 'field2Val';
Of course you can disallow to use 0 as field identifier on the app level, so it doesn't look like a critical issue, or may be it is not an issue at all - just bad choice of field identifier in someone's app) |
Ah, I see. I have the similar issue with the msgpack php extension ;) In my own msgpack implementation I use MP ext type to pack arbitrary types (see https://github.com/rybakit/msgpack.php#custom-types) but, afaik, Tarantool's msgpack doesn't support it yet. |
I make the issue rtsisyk/msgpuck#10 at 3 month ago. The part code of the implenentation MP ext type in the hhvm_msgpack: https://github.com/akalend/hhvm-msgpack/blob/hhvm-v-3.12/msgpuck.h |
@zaglex what'll happened if you'll do something like this?
|
Yes, @bigbes, you are right, I'm speaking about enforcing Map or Array. $data[1] = NULL;
$tarantool->call('myfunc', [$data]); I get this: data[0] - nil
data[1] - cdata<void *>: NULL |
Ah, you mean that this solves problem with unset from my first example. Yes, it looks like a workaround. |
@bigbes I don't see any other sane way to force php array to be packed as MP map. And with
The only problem atm is that on Lua side you will not be able to unpack this extension. |
@rybakit it was said - you're creating |
@bigbes Of course, you can create the classes and do some checks it in the connector, but:
I'm thinking out loud now, but you may consider to add the
And Tarantool can even have predefined ext types for common cases:
So instead of creating custom |
|
There is a related issue regarding bin/utf8 distinguishing: msgpack/msgpack-php#89. |
For the record, here is an example of what I was talking above regarding the custom |
Conversion from php-array to lua-table may be little bit tricky.
Consider the case:
On lua side you will se such a table:
But then you do this on php-side:
And on lua side you will se this:
I understand why it happens, but anyway this may be confusing and may cause unexpected errors.
Is there any way to force tarantool client to trait array either as "real array" or as "map"? Would be great to have special classes like MessagePackArray and MessagePackMap, or even LuaArray and LuaTable for this purpose.
The text was updated successfully, but these errors were encountered: