Closed tpitale closed 8 years ago
Oddly, atoll
seems to return the same negative int value.
To be clear … the reason I went digging was because any time I tried to save a new record the save would fail and the returned id would be some negative integer of this sort.
@dbussink have you dealt with this before?
Looks like a real issue indeed. Best way to handle it is probably to let Ruby do the heavy lifting here and call the Ruby C-API methods to do the string -> number conversion. This would then also overflow to a Bignum when necessary.
I don't see a macro for converting a STR2NUM or something like that. Do you have something in mind? Or just calling to_i
in the adapter or somewhere else higher up?
rb_cstr_to_inum
would be usable for this I think.
Oh, sweet!
The call to parse the string returned
inserted_id
insideexecute_non_query
indo_postgres.c
usingatoi
fails to parse ids returned that are big integers.I changed: https://github.com/datamapper/do/blob/master/do_postgres/ext/do_postgres/do_postgres.c#L546
To:
to see what was up, and got:
String value = 20002471289, Int value = -1472365191
I'm going to try changing it to
atoll
locally, to see what happens.