These are chat archives for arenanet/api-cdi

16th
Jun 2017
smiley
@codemasher
Jun 16 2017 00:02
why does postgres return t and f for boolean columns and how can i fix it? D:
@codemasher what's wrong with t/f
smiley
@codemasher
Jun 16 2017 00:21
        if((bool)$result[0]->active){
            // postgres t/f
            $this->markTestSkipped('['.$this->DBDriver->dialect.'] invalid boolean value');
        }
which driver are you using
smiley
@codemasher
Jun 16 2017 00:21
a non-empty string value will always evaluate to true
PDO and native postgres extension
Archomeda
@Archomeda
Jun 16 2017 00:21
i don't think i've ever seen t/f being used
PDO is giving you a string instead of a boolean? wtf?
you should be getting a PHP boolean value back out
Archomeda
@Archomeda
Jun 16 2017 00:23
it always converted it to the boolean type of the programming language
smiley
@codemasher
Jun 16 2017 00:23
firebird, mysql and sqlite return integers
(it depends on how the DB stores the booleans)
(and returns them)
yes, but mysql> SELECT true + true;
Archomeda
@Archomeda
Jun 16 2017 00:24
if you can't use if (bool) { // true } else { // false } it's trash :P
smiley
@codemasher
Jun 16 2017 00:24
yep
Archomeda
@Archomeda
Jun 16 2017 00:25
who in his right mind would check if equals t...
smiley
@codemasher
Jun 16 2017 00:25
yea, that'd be a pure string comparison then
Archomeda
@Archomeda
Jun 16 2017 00:26
you can try doing char(stupid_string_value) === 116 or w/e php's equivalent is
smiley
@codemasher
Jun 16 2017 00:26
it's weird when you write a querybuilder and the test for it and run into crap like this :D
Archomeda
@Archomeda
Jun 16 2017 00:26
:P
too bad the ascii of both t and f are even :(
or do char(stupid_string_value) % 3
so you're saying that
$res = $db->query('SELECT true');
$row = $res->fetch(PDO::FETCH_NUM);
$row[0] === "t"; // ?????
Archomeda
@Archomeda
Jun 16 2017 00:27
116%3 = 2, 102%3 = 0 :P
like I'm finding that super hard to believe
Archomeda
@Archomeda
Jun 16 2017 00:28
although this does give false positives if it's not guaranteed t/f :(
smiley
@codemasher
Jun 16 2017 00:28
wait no @lye i lied, it's only the native postgres driver
seems like the native driver is buggy af and converting everything to a string :S
smiley
@codemasher
Jun 16 2017 00:29
um no, the native driver is surprisingly good, it just des what the postgres docs say
it returns t/f :D
Archomeda
@Archomeda
Jun 16 2017 00:30
seriously, who expects that
umm what
@codemasher no, that's not how libpq works
smiley
@codemasher
Jun 16 2017 00:30
CREATE TABLE test1 (a boolean, b text);
INSERT INTO test1 VALUES (TRUE, 'sic est');
INSERT INTO test1 VALUES (FALSE, 'non est');
SELECT * FROM test1;
 a |    b
---+---------
 t | sic est
 f | non est

SELECT * FROM test1 WHERE a;
 a |    b
---+---------
 t | sic est
you check the result of PQftype and then do the per-type appropriate thing
psql just serializes everything to a string
the application should not just serialize everything to a string
smiley
@codemasher
Jun 16 2017 00:31
thee problem is that i don't know the column types in beforehand so that i could fix it for that one driver
windwarrior
@windwarrior
Jun 16 2017 00:32
wait you have the schema right
that should say its type?
PQftype should return the type OID of the requested column number, yeah
smiley
@codemasher
Jun 16 2017 00:32
:point_up: 16. Juni 2017 02:26
libpq has a header file for the built-in type OIDs
@codemasher the actual postgresql client lib doesn't require you to have a schema
you just do a query and then look at the types it passes back in the result
smiley
@codemasher
Jun 16 2017 00:33
i wish it was a driver setting available as php constant
casting everything to strings is dumb
it shouldn't even be a setting
the driver should give you back true/false
like, as a native boolean type
smiley
@codemasher
Jun 16 2017 00:34
yea, or at least a usable equivalent
Archomeda
@Archomeda
Jun 16 2017 00:34
let's delete computers and start again
let's delete computers and not start again
windwarrior
@windwarrior
Jun 16 2017 00:35
select computer from world
t
windwarrior
@windwarrior
Jun 16 2017 00:35
what type would that give
yes
have you ever noticed, f is just an upside-down t
Archomeda
@Archomeda
Jun 16 2017 00:35
but... if we don't start again, we can never have gw2 :(
smiley
@codemasher
Jun 16 2017 00:35
lmao
windwarrior
@windwarrior
Jun 16 2017 00:35
oh my god
mind blown
i'm going to go home now before i turn into /r/showerthoughts
Archomeda
@Archomeda
Jun 16 2017 00:36
... can't unsee now
windwarrior
@windwarrior
Jun 16 2017 00:36
have a nice evening, @lye
Archomeda
@Archomeda
Jun 16 2017 00:36
f is a false t
windwarrior
@windwarrior
Jun 16 2017 00:36
I suggest we encode booleans as emoji
all emoji that are kinda angry are false
all emoji that are kinda happy are true
all emoji that are indifferent are maybe
and the file emoji is File Not Found
smiley
@codemasher
Jun 16 2017 00:37
:o: :x:
windwarrior
@windwarrior
Jun 16 2017 00:39
in fact, lets just delete all types that are not the emoji type
Archomeda
@Archomeda
Jun 16 2017 00:39
✅☑✔
windwarrior
@windwarrior
Jun 16 2017 00:39
you can create numbers by using the number emoji things
no sane person ever uses a string if (s)he can cover it with a sufficiently expressive emoji
therefore; we dont need anything else QED
coining emoji-typed languages, brb
smiley
@codemasher
Jun 16 2017 00:43
:rage4: = no
:goberserk: = I DOUBLE DARE YOU
(boolean explained)
sorry
smiley
@codemasher
Jun 16 2017 14:27
it's so ugly...
$j = 0;
foreach($row as $k => $item){

    if(pg_field_type($result,$j) === 'boolean'){
        $row[$k] = $item === 't';
    }

    $j++;
}
Nabrok
@Nabrok
Jun 16 2017 15:11
What does the last box in that image say?
Archomeda
@Archomeda
Jun 16 2017 15:24
eh... maybe click on it? :P
Darqam
@Darqam
Jun 16 2017 15:41
Lye, is there something planned for v2/account/mastery since https://api.guildwars2.com/v2/account/mastery/points is a thing now? The current endpoint is https://api.guildwars2.com/v2/account/masteries
Darqam
@Darqam
Jun 16 2017 15:51
Also, is there any endpoint to resolve the mastery point ids? Not talking about the mastery tracks from /v2/masteries I believe
Nabrok
@Nabrok
Jun 16 2017 16:13
If I click on it, it goes to twitter where the image is even more cut off than it is here
Archomeda
@Archomeda
Jun 16 2017 16:22
well, you can click on the image on twitter as well
ChieftainAlex
@ChieftainAlex
Jun 16 2017 16:25
@darqam - the mastery point ids might be the same ones that are exposed on the v2/continents/ endpoint? In which case, they're visible on the world map widget.
Darqam
@Darqam
Jun 16 2017 16:26
hmmmm
ChieftainAlex
@ChieftainAlex
Jun 16 2017 16:28
image.png
i.e.
Darqam
@Darqam
Jun 16 2017 16:29
ok cool, but I'm not explaining how to resolve that on the wiki page cause continents endpoint scares and confuses me
@Darqam I don't have plans for it, I'm just not good at naming endpoints
really regret not just using a random guid for each endpoint name
Like /v2/account/masteries could have been /v2/bb4177a7-b7be-44ff-9bd3-8354c3ff58cc and /v2/account/mastery/points could have been /v2/c28525e3-29ac-4e70-9af1-aeeb086a1b64
or just /bb4177a7-b7be-44ff-9bd3-8354c3ff58cc and /c28525e3-29ac-4e70-9af1-aeeb086a1b64
ChieftainAlex
@ChieftainAlex
Jun 16 2017 16:51
@darqam, since there isn't an endpoint that exposes names, only coordinates, I've hardcoded them into the widget
{
         "59": "Auric Basin Insight: Lastgear Standing",
        "119": "Auric Basin Insight: The Falls",
        "137": "Auric Basin Insight: Masks of the Fallen",
         "40": "Auric Basin Insight: Luminate's Throne",
        "114": "Auric Basin Insight: Southwatch Creep",
        "116": "Auric Basin Insight: Jawatl Grounds",
        "144": "Auric Basin Insight: Burnisher Quarry",
        "120": "Auric Basin Insight: Eastwatch Bluff",
         "46": "Tangled Depths Insight: Twisting Viaduct",
         "61": "Tangled Depths Insight: Order of Whispers Outpost",
        "112": "Tangled Depths Insight: Nuhoch Lane",
          "8": "Tangled Depths Insight: Northern Confluence",
         "20": "Tangled Depths Insight: Terraced Hive",
          "9": "Verdant Brink Insight: Outside Noble Ledges",
          "3": "Verdant Brink Insight: The Corpse Grove",
        "143": "Verdant Brink Insight: Creaking Cavern",
         "86": "Verdant Brink Insight: Canopy Over Pact Encampment",
          "4": "Verdant Brink Insight: Thistlevine Ravine",
         "75": "Verdant Brink Insight: Holdfast Hollow",
         "95": "Verdant Brink Insight: Fumerol Caves",
         "43": "Verdant Brink Insight: Creeping Crevasse",
         "42": "Verdant Brink Insight: Heartless Pass",
        "140": "Bloodstone Fen Insight: Temple of Renewal",
        "139": "Bloodstone Fen Insight: Fragmented Wastes",
        "287": "Ember Bay Insight: Caliph's Steps",
        "285": "Ember Bay Insight: Ashen Skerries",
        "291": "Bitterfrost Frontier Insight: The Svanir Hive",
        "293": "Bitterfrost Frontier Insight: Griffin Old Growth",
        "289": "Bitterfrost Frontier Insight: The Bitter Cold",
        "156": "Lake Doric Insight: Watcher's Hollow",
        "173": "Lake Doric Insight: Lakeside Bazaar",
        "187": "Lake Doric Insight: Melandru's Refuge",
        "184": "Lake Doric Insight: Melandru's Flourish",
        "304": "Draconis Mons Insight: Savage Rise",
        "300": "Draconis Mons Insight: Scalding Gorge",
        "298": "Draconis Mons Insight: Western Boiling Sea"
}
smiley
@codemasher
Jun 16 2017 16:52
@lye thanks for the hint on PQftype - it's actually in php as pg_field_type()and i totally overlooked it :D
but still... it's weird and ugly...
i still think the driver should be doing that for you
:fire: going to turn off /v2/commerce/delivery for like an hour to double-check something
Archomeda
@Archomeda
Jun 16 2017 17:07
:fire:
Quaggan BooOOoot
@QuagganBooOOoot
Jun 16 2017 17:07
:fire_engine:
ChieftainAlex
@ChieftainAlex
Jun 16 2017 17:15
Darqam, only a small subset of mastery insights turn out to be on the map (like ingame), they should be under the achievements though :/
ChieftainAlex
@ChieftainAlex
Jun 16 2017 17:43
Out of the 224 mastery points I have to play with on my account, I can only find 98 of them in the maps or achievement API, dunno where the rest came from.
eugh yeah /v2/commerce/delivery appears to be the cause of some issues
i screwed up the backend implementation it appears
darthmaim
@darthmaim
Jun 16 2017 17:55
:(
Darqam
@Darqam
Jun 16 2017 18:03
@ChieftainAlex hum ok. well I was hoping for a quick and easy 'ids can be resolved again <this>' for the wiki page. Oh well, doubt people will really care.... but it could be nice to figure out which masteries you have left I guess
ChieftainAlex
@ChieftainAlex
Jun 16 2017 18:22
I stuck the ids I found on the talk page.
Darqam
@Darqam
Jun 16 2017 19:50
and made a massive horizontal scroll bar, congrats
smiley
@codemasher
Jun 16 2017 20:21
Failed asserting that '3' is identical to 3.
databases are hard
sup sqlite???
Archomeda
@Archomeda
Jun 16 2017 20:25
well... it's right though, '3' does not equal 3
smiley
@codemasher
Jun 16 2017 20:26
indeed, it's just that this is an integer field
at least according to the database
dunno what the PDO driver is thinking what it is
Archomeda
@Archomeda
Jun 16 2017 20:31
:(
not sure what's worse: cross browser javascript or cross database php...
you should probably get a driver that isn't garbo >_>
converting everything to strings is a pretty good sign imo
smiley
@codemasher
Jun 16 2017 22:35
(i'm writing a driver wrapper)
otherwise i wouldn't run into these weird things :D
PDO SQLite does even return crazy values for getColumnMeta so i can't fix it like as for the pg_* driver
(or more like i could fix it but i guess it's not worth the effort)
ugh
just use Go instead
it actually has working database drivers
windwarrior
@windwarrior
Jun 16 2017 22:47
or rust, probably has very safe drivers
but more seriously, someone way smarter has probably figured out how to argue about different databases
stand on the shoulders of giants
ChieftainAlex
@ChieftainAlex
Jun 16 2017 22:57
@lye honestly I'm not sure Go will help