perl-rethinkdb
perl-rethinkdb copied to clipboard
Two systems treating numbers differently.
I have a perl script that creates records to insert into rethink.
A simplified version of the code is $x->{‘y’} = 1;
r->db(‘a’)->table(‘b’)->insert($x)->run;
On my ubuntu box y is a string “1” On my mac y is a number 1
Where would this be triggered.
Can you get me the perl versions from each box?
I have more or less stopped working on this project since RethinkDB announced they were abandoning the project, but I'll see if I can find out what's up with this.
Mac: This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail)
Ubnuntu: This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi (with 60 registered patches, see perl -V for more detail)
I've worked around it by forcing to a string for consistency.
Thanks !
Weird. I'm not having this problem. Can you try running this script and give me the output?
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use Rethinkdb;
my $x = {};
$x->{'y'} = 1;
r->connect->repl;
r->db_create('a')->run;
r->db('a')->table_create('b')->run;
r->db('a')->table('b')->insert($x)->run;
my $res = r->db('a')->table('b')->run;
print Dumper($res);
If it still appears like a string, try running the script like RDB_DEBUG=1 perl test.pl
.
Thought I'd add my observations: I've had the same problem with the just the JSON module and occasionally with Rethinkdb (everything I have runs on ubuntu atm). Sometimes no matter what I do it writes out a number quoted as a string, regardless of the source of the data, or any "magic" I tried to do, i.e. $data{key} = int(delete $data{key});
, it still writes it out as a string. It's forced me to add extra conditions to my C++ code to compensate...
I think @dwburke is correct. Looks like there is some issue with older versions of perl & JSON. https://rt.cpan.org/Public/Bug/Display.html?id=111634
Tho, the issue appears to be opposite of what @rob0101 is reporting. I found that both perl v5.18.2 & v.5.27.8 both seemed to work fine on my ubuntu machine.
Test
perl -MJSON -e '$x=1.1; print "$x\n"; warn encode_json [$x]'
Tho, perl 5.18.2 failed this test and the newer version was fine.
Both produce a numeric with that script.
Weird.
Hey njlg, we(RethinkDB) returned as a community project, if you are interested in mantaining this driver, we can add it to the official organization
@thelinuxlich Awesome! Yeah, I'll do some research and see what I need to do to bring this up-to-date.
I will add you to the org, then you can move the repo there