#Core Haxe

1 messages ยท Page 3 of 1

velvet lodge
#

feels wrong, but alright... either way, i cant add to mysql with just a string value

toxic stratus
#

i thought it might have been a modern addition

#

but even haxe.json parses it correctly

velvet lodge
#
INSERT INTO persons.person (personId,lastName,firstName,iconId,hourlyRate)
    VALUES (1,'bob','tim',1,1);
#

this fails

#

(firstName is a json column)

#

this passes:

#
INSERT INTO persons.person (personId,lastName,firstName,iconId,hourlyRate)
    VALUES (1,'bob','{}',1,1);
#

("tim" changed to "{}")

toxic stratus
#

via db core or mysql gui?

velvet lodge
#

gui

#

ok, this is alright though:

INSERT INTO persons.person (personId,lastName,firstName,iconId,hourlyRate)
    VALUES (1,'bob','"tim"',1,1);

So that makes sense seeing as "tim" is valid json but tim (no quotes) isnt

toxic stratus
#

change tim to 711 and it will pass

#

if you want it to be valid change it to '"tim"'

velvet lodge
#

yeah, i mentioned exactly this above ๐Ÿ™‚

toxic stratus
#

ah yea

velvet lodge
#

ok, so this:

                return result.table.addAll([
                    Person(1, '711', 'Harrigan', 1, Bytes.ofString("this is ians contract document"), 111.222),
                    Person(2, '712', 'Barker', 3, null, 333.444),
                    Person(3, '713', 'Mallot', 2, null, 555.666),
                    Person(4, '714', 'Parker', 1, null, 777.888)
                ]);

and later this:

            var record = result.data;
            record.field("firstName", 777);
            record.field("lastName", "HARRIGAN_MODIFIED");
            record.field("hourlyRate", 999.123);

            return result.table.update(query($personId = 1), record);

works fine

#

so i wonder if we are barking up the wrong tree here and its not that at all

toxic stratus
#

could be

#

tried single quoting it, and it still fails

velvet lodge
#

i think you'll need to minimal repro it and see if it is that... like just a throw away app that opens the db and makes the update

#

is this nodejs btw?

toxic stratus
#

yea

velvet lodge
#

ok, cool

#

im not convinced it is the json column type now

toxic stratus
#

i'm struggling to parse the actual sql error tbh

velvet lodge
#

it updates fine for me

toxic stratus
#

i can't see what is problematic

velvet lodge
#

sql errors are shit in general, especially as the error wont (for good reasons) include the values

#

if it were a problem with the json, i think you would get a CONSTRAINT FAILURE error

#

lets see if because the where is a string value... ๐Ÿ‘€

#

nope

#

this all works fine:

            var record = result.data;
            record.field("firstName", 777);
            record.field("lastName", "HARRIGAN_MODIFIED");
            record.field("hourlyRate", 999.123);

            var lastName:Dynamic = "Harrigan";
            return result.table.update(query($lastName = lastName), record);

which is about as close as i think i can get to your usage

#
UPDATE Person SET personId = ?, lastName = ?, firstName = ?, iconId = ?, contractDocument = ?, hourlyRate = ? WHERE (`Person`.`lastName` = ?);`
toxic stratus
#

this is pretty much exactly what I have locally

#

some differences

velvet lodge
#

i think you'll need to minimal repro it outside of your actual app and see if that makes it make more sense

#

this end, it seems fine

toxic stratus
velvet lodge
#

whats the difference?

#

its just wrapped in a function

toxic stratus
#

you're entering 777 directly in the record instead of having it as a dynamic

#

you're whereing on the last name instead of the first name

velvet lodge
toxic stratus
#

oh wait, nvm on the last name thing

velvet lodge
toxic stratus
velvet lodge
#
            var record = result.data;
            var value:Dynamic = 777;
            record.field("firstName", value);
            record.field("lastName", "HARRIGAN_MODIFIED");
            record.field("hourlyRate", 999.123);

            var lastName:Dynamic = "Harrigan";
            return result.table.update(query($lastName = lastName), record);

all fine

#

i presume you are using latest everything?

#

i dont think ive fixed anything like this, but who knows

toxic stratus
#

yeah just added the libs to hbot yesterday

velvet lodge
#

so then, yeah, i guess your only remaning option is to minimal repro it... i cant see another way

#

shouldnt take long, few mins i would have thought

toxic stratus
#

query($lastName = lastName)

#

in my code I have query($lastName == lastName)

#

is this invalid?

velvet lodge
#

oh ๐Ÿ˜„

#

nope, seems fine

#

yeah, its handled:

                switch (op) {
                    case QOpEq:                 sb.add(" = ");
                    case QOpAssign:             sb.add(" = ");
                }
#

... so its not that... phew... was about to jump off the balcony

toxic stratus
#

haha

toxic stratus
#
import db.DatabaseError;
import haxe.Timer;
import db.IDatabase;
import db.DatabaseFactory;
import db.Record;
import Query.*;

class Main {
    var db:IDatabase;

    static function main() {
        new Main();
    }

    function new() {
        db = DatabaseFactory.instance.createDatabase(DatabaseFactory.MYSQL, {
            database: "haxe",
            host: "",
            user: "",
            pass: ""
        });

        db.setProperty('autoReconnect', true);
        db.setProperty('autoReconnectInterval', 5000);
        db.setProperty('replayQueriesOnReconnection', true);

        connect();
        var timer = new Timer(500);
        timer.run = () -> {};
    }

    function connect() {
        db.connect().then(function(state) {
            if (state.data) {
                db.table('state').then((result) -> {
                    var record = new Record();
                    record.field("key", "next_roundup");
                    record.field("value", 730);
                    return result.table.update(query($key = "next_roundup"), record);
                }).then(function(res) {
                    trace(res);

                    trace('success');
                    trace(res);
                }, function(err) {
                    trace(err);
                    // trace(queryExprToSql(query));
                    // trace(value.debugString());
                });
                trace('Database connected');
            } else {
                trace('Database not connected');
            }
        },function err(err:DatabaseError) {
                trace(err.call);
                trace(err.message);
        });
    }
}
#

here's my db setup

#

forgot the table creation

#

lol

velvet lodge
#
UPDATE state SET key = ?, value = ? WHERE (`state`.`key` = ?);
TestAll.hx:29: {
        message : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = ?, value = 
? WHERE (`state`.`key` = ?)' at line 1,
        call : update
#

๐Ÿฅณ

velvet lodge
#

fixed i think... just need to check some other stuff out first

toxic stratus
#

yay

velvet lodge
toxic stratus
#

we got something new ๐Ÿ˜„

velvet lodge
#

ok, but that might be "on you" now, no? does your test app work now?

toxic stratus
#

Json.stringify(value)

#

boom it works

velvet lodge
#

probably needed to be a string or something?

#

although seems odd... didnt need to be in the test app

toxic stratus
#

in my test app

velvet lodge
#

btw, the original issue was nothing to do with json, or anything, its that the "key" column is a reserved word, so needed to be key

toxic stratus
#

i get an empty message

toxic stratus
#

you know

#

I thought about that at some point

#

but just let it go as "that can't be it"

velvet lodge
#

same issue would have happened for deleting

toxic stratus
#

i defo have more normal uses for the mysql db

#

but being able to do something like this in mysql is pretty cool either way

#

it plays really nicely with haxe as well

#

for dbcore the readme says there's one-to-one and one-to-many

#

is many-to-many fine?

velvet lodge
#

im not sure ive played with many to many relationships in db-core / entities

toxic stratus
#

could something like a tag search work one - many?

#

I don't think it could

toxic stratus
#

are LIKE queries supported with db-core?

#

I couldn't find a test for anything that looks like it

velvet lodge
#

LIKE isnt supported in query dsl... not sure what the haxe syntax equiv could be

toxic stratus
#

you could do an "internally reserved" keyword

#

$LIKE

#

but not sure how elegant that is

velvet lodge
#

i wonder if $field % value would be alright?

#

its defo valid syntax, just dunno if its too esoteric

toxic stratus
#

might be a bit extra but why not an enum?

#
query(LIKE('a%'));
#

i guess it isn't very universal

velvet lodge
#

i just dont like "LIKE"... its very sql... and db-core isnt (supposed) to be sql

#

granted the only two plugins currently are sql, but i dont want to shoot myself in the foot

toxic stratus
#

ahhh that makes sense

#

wildcard in itself does seem okay, but it might lack some flexibility

#

like, would i be able to do a%z or a___%

#

oh, i guess so

#

it would probably just look a bit odd

#

$field % a%z

velvet lodge
#

i wonder if a whole new operation make sense "search" or something

#

that would mean you cant use "LIKE" in update / delete... but maybe thats ok? Seems dangerous / silly to do things like that anyway?

toxic stratus
#

I think that's actually a good compromise

#

because you can still just perform an update or delete with the results of the search altogether

#

I agree it seems a bit odd, but I can also see a use case for these things

#

eg removing duplicates

velvet lodge
#

yeah, i can defo see a use for "delete where like"

#

but at the same time, like you say, you could do that with the results of a search

#

im also not sure that "like" would map well to other non-sql things in the future (although "search" almost certainly would)

#

eg, i dont think you could do a "delete where like" on cassandra / solr / lucene (i could be wrong about that ofc)

#

so i guess a seach(fields:Array<String>, terms:Array<String>)? ๐Ÿค”

#

although how would that work with "(x like a or (y like b and z like c))"... hmm

toxic stratus
#

could search accept an expression?

velvet lodge
#

you mean a query expression? Like the other calls? Then we are back to "like" in the query dsl

#

maybe a new search dsl? But now its starting so sound over engineered / duplicated

toxic stratus
#

ahhh, yeah

#

search(['x like a', 'or y like b'])

#

this would work fine, no?

#

maybe not

#

this type of stuff is complicated ๐Ÿ˜„

velvet lodge
toxic stratus
#

@velvet lodge can I do a direct/inline mysql query with dbcore?

velvet lodge
#

nope... i think we discussed it before and consindered adding a "raw" call... ... ?

The thing i dont like about it, is it encourages "just use raw" - though i suppose thats not my business

toxic stratus
#

its mostly to be able to cover queries that aren't supported in core as of yet

velvet lodge
#

yeah, thats fair

toxic stratus
#

i would still report them as usual, probably worth putting them up as github issues in general

velvet lodge
#

right, you can use "raw" calls now on either ITable or IDatabase... both calls have the same signature (and work in the same way), and you have to "opt in" to allow it:

    #if allow_raw
    public function raw(data:String, values:Array<Any> = null):Promise<DatabaseResult<RecordSet>>;
    #end
#

its not thoroughly tested, so let me know if you get any issues

(side note: "thoroughly" is a bitch of a word to spell - had to google it ๐Ÿ˜„ )

toxic stratus
#

i was expecting something like raw('select foo ...)

velvet lodge
#

yeah, thats how you use it, on either ITable or IDatabase... where where you expecting to call "raw" from?

toxic stratus
#

what's values for?

velvet lodge
#

thats if you want to use it as a prepared statment (which is safer), so you can do:

theDB.raw("select * from x where field = 'bob'")
or
theDB.raw("select * from x where field = ?", ["bob"])
toxic stratus
#

ahhhh

velvet lodge
# toxic stratus oh so `data` == `query`

yeah, i didnt want to call it query, because, well, it might not be a query in the future, and in general, i dont like this whole "raw" stuff anyway (hence the opt in)... but i can see the utility in it (to make up for core-db shortcomings... ... ... currently)

toxic stratus
#

yeah, i figured its just a better way to handle things when you're busy

velvet lodge
#

yeah, makes sense

toxic stratus
#

i have no issues changing my code when the proper ways come along :)

velvet lodge
#

exactly... it will (hopefully) be a "well, at least i can do stuff until a better method comes along"

velvet lodge
#

not something i can be "happy" about as it highlights holes in core-db... but good its not a blocker anymore ๐Ÿ™‚

toxic stratus
#

src/systems/DatabaseSystem.hx:322: SELECT * FROM quotes WHERE title LIKE '%electr%';
src/systems/DatabaseSystem.hx:61: ceramic electron

#

๐Ÿ˜„

velvet lodge
#

?

toxic stratus
#

can search in any position of a string

#

its a luxury that firebase/nosql doesn't provide

toxic stratus
#

when I insert into the db the column name is id

#

why does it become insertedId here ๐Ÿค”

velvet lodge
#

_insertedId is something that comes from the db when you do an insert, yeah, but it shouldnt have overwritten anything

toxic stratus
#

ahh

#

I was expecting the id field to come back as the id field

#

in the insert response

velvet lodge
#

i dont think it returns that, unless it requeries it... afaik, the only thing you get back from an insert is the inserted id, i dont really understand why those other fields are there...

#

what is your call?

toxic stratus
#

it's the primary key/auto increment field

velvet lodge
#

yeah

toxic stratus
#

so I just wanted to do stuff with the response and was confused when the id field had no value

#

just a standard insert, this is to do with the response from the insert

velvet lodge
#

i think i would expect only { insertId: 487 }

#

all that said and done, there is a refreshSchema() call at the start, so technically it should be possible to find out what the primary key is and set that field...

toxic stratus
#
db/mysql/MySqlTable.hx:159: {
    fieldCount : 0, 
    affectedRows : 1, 
    insertId : 38, 
    info : , 
    serverStatus : 2, 
    warningStatus : 0, 
    changedRows : 0
}
velvet lodge
toxic stratus
#

nah, its the only field missing

#

seems a bit off

#

considering it does actually send the id

#

just with a different name ๐Ÿ˜„

velvet lodge
#

i think thats usual tbh... ive never seen insert queries be like "this is the primary key name, and its value is 38"

toxic stratus
#

possibly, it might legit be over a decade since i used mysql

velvet lodge
#

i do like the idea of core-db working it out though... my concern is a) getting it wrong and b) adding overheard to inserts

toxic stratus
#

it does seem fitting for core-db

#

the overhead issue, i'm not sure how that could be worked out

velvet lodge
#

so its might not be that much of an overheard, but what if the schema changes while things are running... like an ALTER table raw query or something?

#

i guess in that case, since you used "raw" you would have to manualy call clearCachedSchema

toxic stratus
#

in this particular instance i'm not using raw

velvet lodge
#

no no, i understand, im just saying if you alter table via raw then the cached schema will be out of date, but upon reflection i kinda think "thats a you problem for using raw alter table"... ... if you use addColumn / removeColumn (for example, which will create an alter table query) then it also clears the cached schema

toxic stratus
#
if (res.data.hasField('_insertedId')) {
  res.data.field('id', res.data.field('_insertedId'));
}```
simple workaround, just seemed like an oversight
velvet lodge
#

well, the problem is knowing its "id"

toxic stratus
#

i think it should be okay

#

raw should, for the most part be considered "you're on your own"

velvet lodge
#

i think if you use raw, you cant expect db-core to have any idea what you did

toxic stratus
#

I would agree

#

can be just "nice" to post some things to look out for, but it should be considered anti db-core

#

and i don't think it should be considered as part of "core's inner workings"

#

at most just some note somewhere in the readme

#

I must say tho

#

having raw around is very comforting x)

velvet lodge
toxic stratus
#

Hmm, when we do a delete operation

#

is the record we pass to it meant to be used as a kind of where operation

#

or are we meant to supply the full row?

#

ahah

#

okay, i think we have a bit of an unintuitive bug with delete then

#

If the operation fails, there's no clear way to figure out that the operation failed in the response data

#

for example, i purposely supplied a mismatching author_id here, so nothing got deleted from the table

#

but the response is the same as if something did get deleted

velvet lodge
#

yeah, sounds like an oversight, ill check it tomorrow... dunno whats better though, returning null result or rejecting (throwing an error)

#

i feel like null result is the best idea, maybe with the property for throwing an exception

toxic stratus
#

null or some bool sucess: true, success: false

#

i think error would be somewhat misleading

uncut phoenix
#

With core-http's server, is there a way to get the remote IP Address from the request?

toxic stratus
#

there may be some way to check the ip address via checking the source of the socket request

uncut phoenix
velvet lodge
velvet lodge
#

fyi @toxic stratus - im just writing the unit tests, but ive changed the DatabaseResult to include an "itemsAffected" var

#

(rather than success / failure prop)

toxic stratus
#

ah neat

#

that's a nice level of granularity

velvet lodge
#

yeah, it makes more sense really... so tests like this make sense:

#
    function testBasicDelete_All(async:Async) {
        db.table("Person").then(result -> {
            return result.table.all();
        }).then(result -> {
            Assert.equals(4, result.data.length);
            return result.table.findOne(query($personId = 1));
        }).then(result -> {
            Assert.equals(1, result.data.field("personId"));
            Assert.equals("Ian", result.data.field("firstName"));
            Assert.equals("Harrigan", result.data.field("lastName"));
            Assert.equals(1, result.data.field("iconId"));
            return result.table.deleteAll();
        }).then(result -> {
            Assert.equals(4, result.itemsAffected);
            return result.table.findOne(query($personId = 1));
        }).then(result -> {
            Assert.isNull(result.data);
            return result.table.all();
        }).then(result -> {
            Assert.equals(0, result.data.length);
            async.done();
        }, error -> {
            trace("error", error);
        });
    }

    function testBasicDelete_None(async:Async) {
        db.table("Person").then(result -> {
            return result.table.all();
        }).then(result -> {
            Assert.equals(4, result.data.length);
            return result.table.deleteAll(query($personId = 1111));
        }).then(result -> {
            Assert.equals(0, result.itemsAffected);
            return result.table.all();
        }).then(result -> {
            Assert.equals(4, result.data.length);
            async.done();
        }, error -> {
            trace("error", error);
        });
    }
toxic stratus
#

its quite a strong test validation tool in itself

velvet lodge
toxic stratus
#

i poke in there when looking to see if there's a feature i want to use now and then ๐Ÿ˜„

velvet lodge
#

PITA is now i have to populate that itemsAffected in all the different routes possible - in just db-sqlite there are 3 routes (npm sqlite3, c++ libsqite3, shitty sys.db)

toxic stratus
#

lol you should have a dbcore script that can just update the tables ๐Ÿ˜‚

velvet lodge
#

not sure it would work... its more like "add "changes" to SqliteResult", "expose sqlite3_changes call in libsqlite3", "populate chanages from extern call"...

#

not complex, but just alot of places

#

the unit tests help alot ofc.... let me know when ive missed something... which is often ๐Ÿ™ˆ

velvet lodge
#

alright, thats in now... you'll need to pull pretty much everything

#

@uncut phoenix - httpRequest now contains remoteAddress property

#

eg:

        httpServer.onRequest = (httpRequest, httpResponse) -> {
            return new Promise((resolve, reject) -> {
                trace(httpRequest.remoteAddress);
                httpResponse.write("this is the response");
                resolve(httpResponse);
            });
        };
toxic stratus
#

hell yeah

uncut phoenix
#

^ Ah sorry forgot to respond, thanks so much!

velvet lodge
#

by [ab]using the OpNegBits unary operator in haxe, we can now have "similar" (aka "LIKE" in sql) queries in the query ast in db-core, eg (from the unit tests):

    function testBasicSimilar_WildCard_Multiple_Or_Nested(async:Async) {
        db.table("Person").then(result -> {
            return result.table.find(query(($firstName =~ "i*" || $firstName =~ "*b") || $firstName = "Jim"));
        }).then(result -> {
            Assert.equals(3, result.data.length);
            Assert.equals("Ian", result.data[0].field("firstName"));
            Assert.equals("Bob", result.data[1].field("firstName"));
            Assert.equals("Jim", result.data[2].field("firstName"));
            async.done();
        }, error -> {
            trace("error", error);
        });
    }
#

this will generate (assuming you are using a sql db-core db plugin):

(`Person`.`firstName` LIKE 'i%' OR `Person`.`firstName` LIKE '%b') OR `Person`.`firstName` = 'Jim'
velvet lodge
#

@toxic stratus - what haxe target do you use mysql with?

toxic stratus
#

I think one of core haxe's libs doesn't work on cpp so I'm mostly just using node

velvet lodge
#

should all work, i have unit tests

#

but im going to migrate hxcpp to not use sys.db and use libmysqlclient externs (which past me wrote somehow)

toxic stratus
#

๐Ÿคฃ

velvet lodge
#

heh, thats the core-haxe version, right?

#

but also, thats nothing to do with mysql

#

thats web sockets

toxic stratus
#

yeah, but i said one of core-haxe libs doesn't work ๐Ÿ˜‚

velvet lodge
#

right, but it does work under nodejs?

toxic stratus
#

yeah

velvet lodge
#

good to know

toxic stratus
#

it is a bit weird tho

#

it has a unit test saying passing on github for hxcpp

velvet lodge
#

need to look at core-haxe/ws soon actually as i need it

velvet lodge
toxic stratus
#

ahhh

toxic stratus
#

i'd like both nodejs/js and cpp available

velvet lodge
#

they should all be available now (mysql)

#

but im going to remove the sys.db dep for hxcpp

toxic stratus
#

nice, will I need to add any lib for cpp to work?

velvet lodge
#

libmysqlclient (which i thought i would have to create, but ive actually already created it)

velvet lodge
#

sorry, just reread, currently you wont have to, but after i remove the sys.db dep you will

toxic stratus
#

that's cool

toxic stratus
#

can't seem to find Mysql after updating db core stuff

#

I installed libmysqlclient

#

oooh

#

i thought libmysqlclient was a complete replacement for hx4compat

#

that fixed it ๐Ÿ‘

#

lol

#

i'll post a pr I guess ๐Ÿ˜‚

toxic stratus
#

message : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'keys
WHERE (? = ?) LIMIT 1' at line 1,
call : findOne
}

#

query is:

db.table(table).then((result) -> {
  return result.table.findOne(query('aid' == 'idgoeshere'));
})
#

query($aid == 'idgoeshere')) has the same issue

#
SELECT * FROM keys
WHERE (`keys`.`aid` = ?) LIMIT 1;
#

hmm..

#

i wonder if its cause it is "just" keys

toxic stratus
#

changing

var sql = 'SELECT ${fieldList} FROM ${table.name}';

to

var sql = 'SELECT ${fieldList} FROM `${table.name}`';

in SqlUtils.hx:53, makes it work but that might breaks things else where

#

lemme know if you're cool with a PR for this change

velvet lodge
#

thanks for this btw, merged - accidently left the import in (prolly testing something... no idea)... and so it pulled into the sys.db dep... nice catch ๐Ÿ™‚

So is libmysql work for you?

velvet lodge
velvet lodge
#

mebbe thats reserved in mysql... no idea

#

but yeah, if your fix fixes it, then defo PR please ๐Ÿ™‚

toxic stratus
#

cools

#

i'm just out of sql for so long no idea if no quoting is relied on behaviour anywhere

velvet lodge
#

back ticks is defo the rightway to go

#

every field / table should be backticked

velvet lodge
toxic stratus
#

i'll add those in

velvet lodge
#

nice one

toxic stratus
#

how should the back ticking be done here?

#

discords markdown is getting in the way here x)

velvet lodge
#
`table`.`column`
toxic stratus
#

this exists, should that be separated?

velvet lodge
#

might want to runt he UTs just to be sure, but pretty sure thats not the best way to handle these things

#

where is that code?

toxic stratus
#

will see what the tests come back as

velvet lodge
#

they may fail in general though...

toxic stratus
#

ah ๐Ÿ˜„

velvet lodge
#

nodejs and neko should pass though by the looks of it

#

yup

#

can you change this one... this one was fine actually, i didnt understand the context... its an "AS"

toxic stratus
#

ahhh okay

velvet lodge
#

and this one: AS ${joinName}.${tableColumn.name}');

#

any of the "AS"'s

#

just two

#

rest seem fine... quite alot of them... nice catches

toxic stratus
#

nice

velvet lodge
#

tiny change, but ill make... it will take me longer to explain ๐Ÿ˜„

#

uh, wait, all the UTs broke locally, might be because of that change i wanted to make, two secs

#

nope, nothing to do with that change, was also backtick issues on db-core/mysql

#

unless you also fixed those?

toxic stratus
#

lol what did I fix

#

i thought i undid all the AS'

velvet lodge
#

nothing, dont worry... found some other issues

toxic stratus
#

ahhh

velvet lodge
#

should be fixed now... pull latest db-core / db-mysql to be sure

old juniper
toxic stratus
#

oh my bad

#

i didn't remove the ticks from the first half

velvet lodge
#

yeah, i fixed those now, but found some issues specific to mysql in the "addColumn" test

#

not sure if they just went under the radar or broke recently... no idea... sorted now and UTs pass locally

old juniper
velvet lodge
#

sqlite?

toxic stratus
velvet lodge
#

TestAddColumn also fails for me (sqlite)

old juniper
#

yeah using sqlite.
I'm nearly sure for some reasons you can't have the backticks in the first part ${table.name}.${tableColumn.name} will try without backticks and see if it works

velvet lodge
#

uts pass, just realised you had already made the same change i needed locally (i just hadnt pulled ๐Ÿ™‚ )

#

so are you saying with latest db-core, db-sqlite, everything, that exception occurs?

#

(latest as in "3 mins ago")

toxic stratus
#

๐Ÿƒโ€โ™‚๏ธ

velvet lodge
#

i feel like something else is up then... or are you saying if you go back some commits then everything works?

old juniper
velvet lodge
#

right, would be good at some point to isolate that... core-db should "just work"... if its a logic error (or whatever) in one of the job consumers... thats a totally seperate thing

#

the UTs certainly pass, but they are only as good as the coverage added by the author (me in this case)

#

lemme check entities real quick, but again, coverage is only as good as "it is" (though coverage on all these libs is pretty good i think)

#

(entities UTs pass - sqlite)

old juniper
#

No it doesn't work ( suddenly I thought it didn't work in old versions but it was because of rabbit queues that I forgot to empty) .
Now I'll try with pseudo fix.

velvet lodge
#

doesnt work if you go back some commits you mean?

#

rabbit queues that I forgot to empty
this is interesting in its own right, how did you poison your rabbitmq queues? (jeez, had to google how to spell "poison"... :/ )

long agate
#

what dbs do u support atm?

velvet lodge
#

sqlite / mysql... postgres coming "soon" and "IndexedDB" as a "test of the abstraction"

long agate
#

cool i have a custom native sys.db.Postgres impl somewhere, maybe i could butcher that and contribute some code

velvet lodge
#

sounds good, for sure... first we need a libpostgres (for hxcpp) but iirc i found it and it looks significantly more sane than libmysqlclient

#

the idea of core-db (not core-haxe in general), is we just stop thinking about "oh, which db"... i guess like haxeui, with the backends and such... im a masochist it seems ๐Ÿ˜„

long agate
#

i used the official dynamic libs via hxcpp i think

old juniper
velvet lodge
long agate
#

sounds weird

velvet lodge
velvet lodge
# long agate sounds weird

its really odd... like you cant just extract "a dozen" cpp files and be done with it... you need the whole mysql source to get anything to work... which is a cluster fuck

#

so i went with the "precompiled lib" route

#

still need some macro magic on linux tbh to get where headers are etc... but its, effectively, "there"

#

which reminds me that i need to revist that... i set up a VM specifically for it, then went "all done!" (once the VM was setup)... ๐Ÿคฆโ€โ™‚๏ธ

velvet lodge
#

just about to start the "walk the doggos marathon" but, "everything" is working? Or just core-db (unrelated, but interestingly, i worked it out the other day and i walk 15-18km a day with the 5 dogs in their "groups")

old juniper
velvet lodge
#

core-db works. There's a bug in migrator, when you have migrator in the db that don't exist.
fixable i assume / presume?

Wow, that's plenty. how many walks do you do a day?
3 "groups" (of two), twice a day, about 2-3km a walk

old juniper
old juniper
#

3 "groups" (of two), twice a day, about 2-3km a walk
So 3 to 4 hours of walk ?

velvet lodge
#

each walk about 30-45 mins i would say, multiplied by 6 (per day)

#

speed varies on who were taking, if its the two 35kg ones, i cover more distance since they take me for a walk ๐Ÿ˜„

#

if its the 25kg ones, we tend to amble...

#

when its the tiny one... meh, maybe we dont make it 1km... not sure

old juniper
velvet lodge
#

You must be quite healthy, even with the smoking
it offsets my smoking quite nicely, for sure

And you still have room for another dog in your groups
๐Ÿคซ divorces start this way ๐Ÿ˜„

old juniper
velvet lodge
#

(in fact we havent taken him for a while because of that, and the fact he was crazy ill a while back so cant have any vaccinations etc)

toxic stratus
#

hmmmm

#

for json field types in db-core

#

hm, nvm, i'm still not actually sure what's going on

#

lemme keep messing aronud

#

I think dce is killing a field but i'm explicitly mentioning it so i'm not sure why ๐Ÿค”

toxic stratus
#

quality of life suggestion

#

when adding an internal id to a record, eg _insertedId, remove them so that I don't have to in my local code ๐Ÿ˜„

velvet lodge
#

i think technically _insertedId isnt needed now... DatabaseResult has properties now for lastInsertedId and affectedRows that dont need to be in the data

toxic stratus
#

ohhh nicee

velvet lodge
#

yeah, i just need to update a few libs that are dependant on those data level props and get them to use the new result level property

toxic stratus
#

hmm, for the websocket api

#

it would be nice that we have a unified state variable

#

I keep getting caught out by trying to send stuff down a connecting socket x)

#

i'm not sure what's going on because my connected var is true from the callback onOpen

#

maybe i've got a bug ๐Ÿค”

#

yes nvm, was a simple bug that was hidden away x)

toxic stratus
#

Hmm, i get weird behaviour with websockets and the websocket server

#

instead of places where a string is expected, I am recieving a UInt8Array

#

socket server I guess I can understand as its still a pure nodejs api

#

but when I send out a string and parse it with a client WebSocket, StrMessage(content) is receiving a UInt8Array

velvet lodge
#

@toxic stratus - i think you are using the auto reconnect / replay queries part of db-mysql, right?

#

Im thinking about making couple of tiny changes:

  1. reconnect will be true by default
  2. replay will be true by default
  3. when disconnection detected, it will immediately try and reconnect, not wait for autoReconnectIntervalMS and then try - autoReconnectIntervalMS will come into play if the first reconnection attempt failed
toxic stratus
#

I see no obvious issues that would occur

velvet lodge
#

ive already made the changes and tested locally, all fine

toxic stratus
#

I just posted this to db-core

#

only issue is, i've literally never messed with custom iterators

#

so i'm not sure if there's a "better" way to implement it

#

@velvet lodge

#

but it works either way

velvet lodge
#

whats the idea? To get the index and record out?

toxic stratus
#

ya

#

key value iterator

#
for (index => value in set)
#

currently you can't get index

velvet lodge
#

seems fine to me... not sure why you would need the index exactly, but no doubt very app specific

toxic stratus
#

just needed the index for debugging purposes tbh

uncut phoenix
#

Does core http have a default timeout? Is there a way to turn this off?

toxic stratus
#

I'm pretty sure there is

#

ahh I think I'm remembering delay rather than timeout

uncut phoenix
#

I am trying to download a file, but it seems to be closing before it gets the file

velvet lodge
#

i dont think it does, unless the underlying impl does... where are you running this? Browser? Got an example url?

uncut phoenix
#

i am just doing

client.get(variant.tff).then(r -> {
  sys.io.File.saveBytes(fileName, r.body);
});
toxic stratus
#

that's a nice url

uncut phoenix
#

thanks, found it myself :p

#

oh and I am using interp target

toxic stratus
toxic stratus
#

@uncut phoenix its for debugging sake

uncut phoenix
#

Doesn't work with the python target

#

same with js, but I am getting the error:

/home/logo4poopers/Projects/haxe/CeramicFontGrabber/main.js:116
                                request.method = "GET";
                                               ^

TypeError: Cannot set properties of undefined (setting 'method')```
velvet lodge
#
package;

import http.HttpClient;

class Main {
    static function main() {
        trace("started");

        var client = new HttpClient();
        var url = "https://fonts.gstatic.com/s/opensans/v40/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsiH0B4gaVc.ttf";
        client.get(url).then(r -> {
            trace("got bytes");
            sys.io.File.saveBytes("something.ttf", r.body);
        });
    }
}
#
--class-path src
--main Main

--js bin/main.js

--library hxnodejs
--library http

-D no-deprecation-warnings

--cmd node bin\main.js
uncut phoenix
velvet lodge
#

doubtful, you'll have to send a failing sample app - its all fine this end

uncut phoenix
#

alright

velvet lodge
#

i can repro... its a kinda weird way of using promises tbh (i would chain them), but it doesnt really explain the error

toxic stratus
#

the url is different, would that matter?

velvet lodge
#

could be a redirect that is causing issues - http lib follows redirects, but maybe something is borked there

toxic stratus
#

reminds me of an issue i've had before

#

could be a header issue

#

or lack of

velvet lodge
#

its not a redirect... its an http, so it should be fine

#

its such a weird error

#

something to do with the HttpRequest abstract

uncut phoenix
velvet lodge
#

ok, its because variant.tff isnt a string (i think) so it doesnt hit the abstracts "fromString" function

uncut phoenix
#

oh, do i need to cast it first?

velvet lodge
#

i mean, if you do "" + variant.tff it works, but i dont like it...

#

also, it is a string apparently

#
trace("----------------------------------", variant.ttf, Type.typeof(variant.ttf));
#
src/GrabCommand.hx:26: ----------------------------------, https://fonts.gstatic.com/s/roboto/v32/KFOkCnqEu92Fr1MmgVxIIzc.ttf, TClass({
                __name__ : String
        })
#

i think its a GC issue... i think the variant.tff is being cleaned up super fast... at least, thats all i cant think of

#

because this loop is going exit pretty fast, and "its done" (as i mentioned, its quite weird way to use promises)

uncut phoenix
#

would cleaning up the promises fix that?

#

i am not really that familiar with promises (obviously)

velvet lodge
#

i just mean that this loop is firing off promises "into the wind"... and maybe by the time the request actually gets round to executing its cleared the mem... its a hunch but its defo possible with this nested promises is loops...

#

gimme a sec, ill show you how i would have chained it (and if the issue persists, ignore all of the above ๐Ÿ˜„ )

#

well, it wasnt what i thought ;/

#

if i do var s:String = variant.ttf; and the use "s" its all fine

#

but even though variant.ttf is apparently a string, the abstract doesnt think so

#

ah, hang on, ofc it wouldnt... abstracts are compile time

toxic stratus
#

is .ttf an abstract over string or a straight string?

velvet lodge
#

HttpRequest is an abstract

#
@:forward
@:forward.new
abstract HttpRequest(HttpRequestObject) {
    @:from public static function fromString(s:String):HttpRequest {
        return new HttpRequest(s);
    }
}
#

but it makes perfect sense now... variant.tff is dynamic (at compile time), no way for the compiler to know its a string

toxic stratus
#

ahh, yeah that makes sense

velvet lodge
#

so yeah, you will need a cast or something like that to let the abstract know its a string

toxic stratus
#

if its expected to be a string it should just be typed as one before hand

velvet lodge
#

well, it can either be a string, or a HttpRequestObject so you can set headers, etc, etc (hence the abstract)

#

but yeah, it makes perfect sense now i think

#

so yeah @uncut phoenix - you'll need a cast to a Std.string... etc... but fwiw, this is the chaining code (that i dont think you technically need, but its better than firing promises off into the wind an not wait from them to complete):

#
var client = new http.HttpClient();
client.get(API_URL).then(r -> {
    trace("GOT API RESULT");
    var filtered = Fuzzaldrin.filter(r.bodyAsJson, values["family"], {key: "family", maxResults: 1});
    if (filtered.length <= 0) {
        Sys.println("Font family not found: " + values["family"]);
        Sys.exit(-1);
    }

    sys.FileSystem.createDirectory(".tmp");

    return client.get(API_URL + '/${filtered[0].id}');
}).then(r -> {
    trace("GOT FILTERED LIST");
    var promises = [];
    for (variant in (r.bodyAsJson.variants : Array<Dynamic>)) {
        var family = (variant.fontFamily : String).replace(" ", "").replace("'", "");
        var fileName = '.tmp/${family}_${variant.fontWeight}_${styleFormat(variant.fontStyle)}.ttf';
        trace("ADDING FONT TO LIST", variant.ttf + " => " + fileName);
        promises.push(saveFont.bind(client, variant, fileName));
    }

    return PromiseUtils.runAll(promises);
}).then(_ -> {
    trace("ALL DONE!");
}, error -> {
    trace("error", error);
});

...
...

    private function saveFont(client:http.HttpClient, variant:Dynamic, fileName:String):Promise<Bool> {
        return new Promise((resolve, reject) -> {
            trace("MAKING REQUEST", variant.ttf);
            client.get((variant.ttf:String)).then(r -> {
                trace("SAVED BYTES ", fileName, r.body.length);
                sys.io.File.saveBytes(fileName, r.body);
                resolve(true);
            }, error -> {
                reject(error);
            });
        });
    }
toxic stratus
#

is there a syntax in Query.query() for limit eg: table.query($uid == 'uid' limit 5)

#

i couldn't find a test for it

#

just seems like findOne exists etc

toxic stratus
#

probably not, i just woke up not sure if the concept makes sense anymore lol

velvet lodge
#

table.page(0, 5, query($uid == 'uid')) will create a limit query

toxic stratus
#

ahhh, i was looking at count and was a bit confused lol

#

thanks!

velvet lodge
#

.count will create a count(...) query

#

i also think a different name could be nice, well, another call that is a little clearer... "findFixed" or something

#

(but i dont like "fixed")

toxic stratus
#

what's wrong with .limit?

velvet lodge
#

table.limt(someQuery) doesnt make sense

toxic stratus
#

table.results(query, 5) perhaps?

velvet lodge
#

also, doesnt seem obvious

#

although, looking at "find" it could have a "maxResults:Null<Int> = null"... ... ?

toxic stratus
#

page makes sense now that I look at it fully, but i just scanned the function names and didn't look at the params

velvet lodge
#

i think im going to add maxResults also, i think its a useful function param

#

semantically, im not sure "page" always makes sense

toxic stratus
#

yeah

#

i skipped it because i just didn't want any "paging"

velvet lodge
#

yeah, other times is certainly useful, like when you are actually paging... so the "pageIndex" is nice there

#

but other times, i just want to find(someQuery, 5)

toxic stratus
#

yeah, exactly

velvet lodge
#

yeah, ill add it as an optional param to "find", and maybe "all"

toxic stratus
velvet lodge
#

np - its nice for my enitites2 lib also

#

MyEntity.findAll(10) for example

#

anoter thing i need to sort out is is sorting

#

possibly another param on find / all

uncut phoenix
#

i thought it might be smth to do with saveBytes, but commenting that out does the same thing

#

i am assuming it is smth on the core-http level then?

toxic stratus
uncut phoenix
#

everything seems to be properly cast tho

velvet lodge
#

what does your new code look like?

uncut phoenix
#

same as yours

velvet lodge
#

is it trace "SAVED BYTES" or... ...

uncut phoenix
#

Yeah, but only for one

velvet lodge
#

try return PromiseUtils.runSequentially(promises); , see if that makes a diff

uncut phoenix
#

it saves more now

#

like four

#

but still gets stuck on some threads dying

velvet lodge
#

this is a sys target, right? Smells like problems with http's internal thread handler

uncut phoenix
#

yeah, just interp target

#

guess i should try a different one huh

#

ah yeah, js works

velvet lodge
#

i also get the same errors on interp

#

almost certainly an issue with the threading

uncut phoenix
#

tbf i might be the only interp user outside of macros lmao

velvet lodge
#

yeah, i dont use interp... not sure if there are threading issues there in general

#

lemme try hxcpp just to be sure

#

HL is fine

#

hxcpp also fine

#

ive added a -D http_no_threads flag...

#

which will override even if the target is threaded

#

it does mean that it makes the http lib synchronous though ofc (even though the interface will still be promise based)

#

i actually think it might be that the default http impl in interp is not supposed to be threaded

toxic stratus
#

just an idea

#

query(expr, limit, sort)

#

i don't think that's too much of an imposition on the abstraction api, is it?

#

and they could just just be ignored paramaters

velvet lodge
#

i dont think sort and limit should be part of the query

#

they arent in other db systems (like solr, etc)

#

it also means, if things dont have a sort in them (like, dunno, maybe browser db thing), you can just implement it as a post processing step

#

sort, limit and query should defo be seperate "things"

toxic stratus
#

makes sense

toxic stratus
#

if not, mind if i expose reverse on recordset?

#

as a temp solution

uncut phoenix
velvet lodge
weak talon
wide solstice
#

Hello, I'm relying heavily on https://github.com/core-haxe/promises for my amqp library to reduce the callback hell necessary for establishing a connection, opening a channel and consuming a queue. I would love to push that library to haxelib but for that I would need promises pushed to haxelib. Is that possible? Also wasn't sure about it, so I created an issue for that

#

Asking because there were bugfixes made and thenshim has been archived in the meantime

velvet lodge
#

i do wonder if there is a better way to handle it though... maybe you could just add its a git module or something and somehow package it with your haxelib? It doesnt change very often at all

wide solstice
#

At the moment I am referencing to the library via readme. Packaging it directly via submodule would be another possibility. But I am currently also investigating whether it is possible to add Support for void promises within the typedef

#

Problem with void is that the resolve callback ist typed as Void->Void which makes it Impossible to call it then since Haxe then expects a void Parameter

toxic stratus
#

I don't think its intuitive

#

but I think you can do

#
function (_) {}
``` It'll pass
#

i could be remembering wrong there

#

but there was some trick you could do with tink promises for that

wide solstice
#

Then the typing would get lost

#

Have to see once I have a bit more time

toxic stratus
#

I am thankful we have raw queries in db-core x)

velvet lodge
toxic stratus
velvet lodge
#

right, so sort

toxic stratus
#

yeah

#

its just nice that we can continue on

velvet lodge
#

yeah, fair enough - i'd actually totally forgotten about all that sort and max results stuff above...

toxic stratus
#

completely fine

velvet lodge
#

useful additions though, for sure - as you say - raw is "alright" as a stop gap... but if you are using raw, as in this case, it indicates an api hole

wide solstice
#

Question about queries, is there a possibility to escape values like you do in PHP with mysqli_real_escape_string?

#

I am planning to use db-core or at least libmysqlclient for my private Project to get rid of libffi

velvet lodge
#

if you are using the lower level libs, like libmysqlclient for example, then you probably need to escape things yourself (not sure if there is an exposed function for it in the externs, easy to add if not), if you are using the higher level libs, like db-core, then everything should be auto escaped for you automatically... when the sql is built care is taken for that type of stuff, even identifiers are backticked - and where possible, prepapred statements will be used

wide solstice
#

Ah good to know. Have to take a look at libmysqlclient to get it Work on Linux. At the moment the workflows are at least failing

velvet lodge
#

ah, would defo be good to know if there are issues - it could just be that the UTs are failing because it can connect to a mysql instance (all that stuff is a PITA)...

#

in fact, actually, i know there arent issues - i know someone who is using it on linux without issues

toxic stratus
#

I think the failing might be for a haxe version

velvet lodge
#

possibly

toxic stratus
#

haxebot uses db core and is running on Linux

wide solstice
#

Ah okay, then I have to take a deeper look

velvet lodge
#

i would, ofc, suggest you use db-core (ie, the top level abstractions) as, imo (and ofc, im biased) they can save you alot of time, and you can flip db backends at will, etc... and depending on your use case, i would also possibly suggest entities2 (which is, i think, my fav lib, ever)

toxic stratus
#

if I recall it might have to be with haxe < 4.3

wide solstice
#

Last time I tried libmysqlclient I had compile issues since it couldn't find mysql.h

toxic stratus
#

hmm, haxebot runs on nodejs

#

completely forgot that ๐Ÿ˜…

velvet lodge
#

so yeah, there still might be issues on *nix

wide solstice
#

Also tried to build a Haxe only MySQL connector but failed since it needs Public Key encryption which I didn't want to Dive into ๐Ÿ˜„

velvet lodge
#

so yeah, will defo need some rejiggling

wide solstice
#

Will have a look at it. Want to get rid of the libffi connector I am using at the moment xD

velvet lodge
#

yeah, externs ftw for sure

old juniper
velvet lodge
#

๐Ÿค”

#

did you maybe make changes and then not commit them?

old juniper
velvet lodge
#

yeah, i seem to remember that, and i think i remember a convo about needing a macro that builds the buildxml like hxwidgets does

#

ie, runs some processes to get bits that should be included etc

toxic stratus
#

@velvet lodge what's the kind of api you'd want for sorting? something like this find(query:QueryExpr, sort:Direction, allowRelationships:Bool = true)?

#

I can take a shot at implementing it

#

at least for mysql backend

#

oh maybe its more involved than that, we'd need an option to specify a query expression i think ๐Ÿค”

velvet lodge
#

yeah, dont worry, ill do it, i want "maxResults" also

toxic stratus
#

no worries, just thought it was low hanging contribution fruit x)

#

thought about it for a bit and realised the abstraction adds quite a few things to consider

wide solstice
velvet lodge
#

in the case of core-db, yeah, its handled internally since it builds the sql queries (you dont write sql in core-db)

wide solstice
#

that's what I understood

#

But nevertheless strings need to be escaped by mysql real escape string to prevent sql injections

#

or am I missing something?

velvet lodge
#

so, if memory serves, db-core builds up prepared type statements (select from x where field=?) then, it passes that down the stack, some plugins handle it natively (ie, using actual prepared staments) and others (like sys.db which doesnt support prepared statements) builds up the actual sql string and that escapes the values

#

it will replace the ?s with escaped version (_nativeConnection.escape)

#

nodejs uses the (official?) npm lib, which presumably handles the prepared statement automatically

#

i was looking for the hxcpp version, but it doesnt use prepared statements... though the commit is: remove sys.db dep for hxcpp (1st iteration - not using prepared stmts)

#

and indeed, that is not escaping things, but once it uses prepared statments it shouldnt matter

wide solstice
#

ok

#

will have a look at libmysqlclient to get it built with linux. Are you preferring to package the libraries with the repository or would it be okay to depend on installed libmysqlclient?

velvet lodge
#

i think you'll need to use whats in the system, the locations can vary so i think we'll need a macro that will build up the @:buildXml dynamically based on system paths (hxWidgets does something similar, but its not a 5 min job)

wide solstice
#

Oh, found a way to compile it with linux

#

Extended the build.xml by following:
<section if="linux">
<files id="haxe">
<compilerflag value="-I${include_folder}" />
<compilerflag value="-I${include_folder}/include" />
</files>

    <target id="haxe" tool="linker" toolid="exe">
        <lib name="-lmysqlclient"/>
    </target>
</section>
#

That works at least for haxe tests/common.hxml --class-path tests -cpp target/cpp

#

question is right now, why is the windows build also failing in github workflow

#

sadly I don't have a running windows instance

velvet lodge
wide solstice
#

ah okay

#

then I'll prepare a pull request to extend build.xml by linux and rename it to Build.xml ๐Ÿ™‚

velvet lodge
#

alot simpler than i thought... might be good to get, dunno, @old juniper to also test

old juniper
wide solstice
#

Good evening, took some time to create the pull request but finally I created it and is ready to merge ๐Ÿ™‚

#

build worked on my local machine, don't know whether the github workflows are also executed on pull requests

wide solstice
velvet lodge
#

yeah, saw both... will merge shortly.. thanks gents! ๐Ÿ™‚

uncut phoenix
#

in db-core and friends, could we remove dependencies from haxelib.json? I might be using it wrong, but haxelib freaks out when a package that doesn't' exist is added there

uncut phoenix
# toxic stratus wdym
You already have db-core version git installed.
Updating db-core version git ...
db-core was updated
Library db-core current version is now git
Error: Failed with error: No such Project : promises
#

i'm using it through hmm, so maybe it is fine with normal haxelib

toxic stratus
#

otherwise it would fail with no error

velvet lodge
#

do you have promises installed?

#

i mean, is the error valid?

uncut phoenix
toxic stratus
#

could try putting promises before db-core

uncut phoenix
#

yeah, but i think it gets reset each time you add something new to it

#

not sure if it is intended to be manually edited

#

it sorts alphabetically by default

velvet lodge
#

is that an "hmm problem"? I mean, surely dependency resolution is important? I dont think the solution is "remove the depenendancy marker"

#

like, other haxelib.json's have dependencies, surely?

uncut phoenix
#

yeah, but they aren't git dependencies

velvet lodge
#

ah

uncut phoenix
#

anything in dependencies is assumed to be on the haxelib repo

velvet lodge
#

the problem is if you remove it form there, you have to manually -lib it in your hxml

#

or maybe you have to anyway ๐Ÿค”

uncut phoenix
#

could you toss them in extraparams?

#

i dont have to right now

velvet lodge
#

because, yeah, it pulls them in automatically in vscode, which is useful (not just for building)

#

ie, no promises anywhere explicitly included

uncut phoenix
#

Lol, I forgot about your haxeui vscode theme. I can send a PR for extraparams later if it doesn't break anything

velvet lodge
#

haxeui vscode theme?

uncut phoenix
#

isn't that the haxeui colorscheme?

velvet lodge
#

dont think so... i built my own icon pack, thats about it

uncut phoenix
#

ah k, i was just looking at the icons

velvet lodge
#

yeah, those are intellij icons... i just copy and pasted some icon pack and dropped those icons over the top for choice files

toxic stratus
velvet lodge
#

no but you can do --library ...

#

so you'll still get an error etc... but, if it doesnt show up in vscode (as above) then its not good imo

#

i think it should / will

toxic stratus
#

--L promises:git:https://github.com/core-haxe/promises

#

You can even specify a commit hash if you'd like

velvet lodge
toxic stratus
#

Yea

velvet lodge
#

pretty nice

uncut phoenix
#

... can you do that in a haxelib.json

velvet lodge
#

but haxelib.json doesnt recognise that?

toxic stratus
#

not in the json (at least afaik)

#

but this might solve @wide solstice issue

velvet lodge
#

i didnt even know that was a thing... sounds useful for core-haxe, for sure

uncut phoenix
#

tried to move all of the libs into extraParams, but I am getting .haxelib/sqlite3/git/src/sqlite/impl/cpp/SqliteDatabase.hx:4: characters 8-21 : Type not found : sqlite.Sqlite

toxic stratus
#

you'd need to specify the connector in your project - right?

velvet lodge
uncut phoenix
#

no, i am just doing the stuff in my project rn. which worked fine before. here is the entire diff for that package

diff --git a/extraParams.hxml b/extraParams.hxml
new file mode 100644
index 0000000..d474ee8
--- /dev/null
+++ b/extraParams.hxml
@@ -0,0 +1,4 @@
+# Since core-haxe libraries aren't available on the haxelib repo, we import them here
+-L libsqlite3
+-L promises
+-L logging
diff --git a/haxelib.json b/haxelib.json
index 98f2811..5f402c3 100644
--- a/haxelib.json
+++ b/haxelib.json
@@ -8,13 +8,8 @@
     "tags": [
     ],
     "releasenote": "0.0.0",
-    "dependencies": {
-        "libsqlite3": "",
-        "promises": "",
-        "logging": ""
-    },
     "classPath": "src",
     "name": "sqlite3",
     "description": "",
     "url": ""
-}
\ No newline at end of file
+}
toxic stratus
#

i think you're missing a lib

#

sqllite3

#

don't you need that?

uncut phoenix
#

this is the sqlite3 lib

toxic stratus
#

oh right

velvet lodge
#

because of "classPath" i think

uncut phoenix
#

oh, how does that affect things?

velvet lodge
#

actually, no, nvm, it should be fine... haxelib.json is still there, right?

uncut phoenix
#

ye

velvet lodge
#

so yeah, ignore me

#

do you have libsqlite3 installed?

uncut phoenix
#

yep

velvet lodge
#

weird, no idea

uncut phoenix
#

i wonder if haxelib does smth fancy

#

looks like libsqlite3 is where sqlite.Sqlite and what not are defined

velvet lodge
#

yup

uncut phoenix
#

are haxelibs just an abstraction over -cp or do they have their own compilation step?

uncut phoenix
#

@frosty locust sorry for pinging, would you happen to have any knowledge in this domain of haxelib?

weak talon
frosty locust
#

Yeah, it's just -cp with a couple more compilation flags if the haxelib needs them

wide solstice
#

Some question about libmysqlclient: I would like to call real_escape_string, how do I do that / what do I've to do to add a wrapper

velvet lodge
#

are you using libmysqlclient directly?

wide solstice
#

ok, will have a look at it.

#

I'm using libmysqlclient directly, yes

#

replaced my libffi library by libmysqlclient

#

just some question: Shouldn't to:RawPointer<cpp.Char> of type ConstCharStar?

#

In case it's correct, how do I pass a string variable in there

velvet lodge
wide solstice
#

ah okay

wide solstice
#

found something in the haxe channel from you regarding the real_escape_string ๐Ÿ˜„

#

Will play a bit around with that

wide solstice
#

What do you think about following code for exposing real_escape_string? Another question shall I also expose real_escape_string_quote?

public function real_escape_string(value:String):String {
    if (_handle == null) {
        throw new Exception("internal handle is null");
    }
    var len = NativeString.utf8Length(value) * 2 + 1;
    var na = NativeArray.create(len);
    var p = Pointer.arrayElem(na, 0);
    RawMySqlClient.real_escape_string(_handle, p.raw, value, value.length);
    return untyped __cpp__("{0}", p.raw);
}
velvet lodge
wide solstice
#

looks like it works, still testing around

velvet lodge
#

might want to try return new String(untyped cpp("{0}", p.raw)) or something like that, feels safer (could be wrong ofc)

wide solstice
#

I put it already into MySqlClientConnection, but will rename it to escapeString

#

will try it with return new string ๐Ÿ™‚

velvet lodge
#

i could be being over cautious, just not sure what is going to happen to that buffer, might get reclaimed or something

wide solstice
#

what about escape string quote?

#

shall I expose that also?

velvet lodge
#

could do, wont hurt for it to be there

wide solstice
#

ok

#

ahm what about the return of real_escape_string and the quote one? In cpp it returns unsigned long, so shouldn't the return be Int64?

velvet lodge
#

probably int will be fine? I mean, technically its not "right" but i doubt anyone is going to be using strings of that size

wide solstice
#

ok, just asking because of error handling

#

so how to check for error, when the api states Because mysql_real_escape_string() returns an unsigned value, you can check for -1 by comparing the return value to (unsigned long)-1 (or to (unsigned long)~0, which is equivalent).

#

would uint max value be fine

#

damn arch linux ๐Ÿ˜„
It's not finding mysql_real_escape_string_quote since the package is mariadb ๐Ÿ˜’

#

humm... have to see whether a check for existance of mysql_real_escape_string_quote is possible since it's mysql only ๐Ÿ˜e

#

at least the mysql_escape_string expose is working ๐Ÿ™‚

#

do you want to stick to mysql or mariadb? Seems that linux distributions switched from mysql to mariadb which has a drop in replacement for libmysqlclient but removed a bunch of functions like mysql_real_escape_string_quote

velvet lodge
#

i think the lowest common denominator, so imo, just drop mysql_real_escape_string_quote, it was a "nice to have" anyway, mysql_real_escape_string is probably enough... ?

wide solstice
#

okay, then I would go and remove the mysql_real_escape_string_quote in favor of mysql_real_escape_string

#

So, I made following modifications:

  • Change return value of real_escape_string to cpp.Uint64 to be able to check for error
  • Added escapeString function which exposes real_escape_string
  • Removed real_escape_string_quote from RawMySqlClient
#

Will do a bunch of further tests with my project and then submit a pull request

#

Translated cpp code looks at the moment like this:

::String MySqlClientConnection_obj::escapeString(::String value){
HX_GC_STACKFRAME(&_hx_pos_63a675c029f1cf5e_88_escapeString)
HXLINE( 89) if (::hx::IsNull( this->_handle )) {
HXLINE( 90) HX_STACK_DO_THROW( :haxe:Exception_obj::_alloc( HX_CTX ,HX("internal handle is null",88,4f,70,9c),null(),null()));
}
HXLINE( 93) int len = ((_hx_utf8_length(value) * 2) + 1);
HXLINE( 95) ::Array< char > na = ::Array_obj< char >::__new(len);
HXLINE( 97) ::cpp::Pointer< char > p = ( (::cpp::Pointer< char >)(::cpp::Pointer_obj::arrayElem(na,0)) );
HXLINE( 99) MYSQL* result = this->_handle;
HXDLIN( 99) char* result1 = p->get_raw();
HXDLIN( 99) ::cpp::UInt64 result2 = ::mysql_real_escape_string(result,result1,value.utf8_str(),value.length);
HXLINE( 101) if ((result2 == ::hx::TCast< ::cpp::UInt64 >::cast(-1))) {
HXLINE( 102) HX_STACK_DO_THROW( :haxe:Exception_obj::_alloc( HX_CTX ,HX("mysql_real_escape_string failed!",0f,53,c1,d0),null(),null()));
}
HXLINE( 105) return ::String(p->get_constRaw());
}

#

which looks valid to me

velvet lodge
#

yeah, me too

wide solstice
#

only thing which might be incompatible is uint64, because real_escape_string uses normally unsigned long

#

Have to see whether I can reflect that one

#

but generally it seems to work

wide solstice
#

got it ๐Ÿ˜„

#

Used UnsignedLong as return type ๐Ÿ˜„

#

have to test whether following c++ construct works:
unsigned long result2 = ::mysql_real_escape_string(result,result1,value.utf8_str(),value.length);
if (::hx::IsInstanceEq( result2,::hx::TCast< unsigned long >::cast(-1) )) {
HX_STACK_DO_THROW( :haxe:Exception_obj::_alloc( HX_CTX ,HX("mysql_real_escape_string failed!",0f,53,c1,d0),null(),null()));
}

wide solstice
#

looks much better with UnsignedLong return for real_escape_string and untyped __cpp__("unsigned long errorReturn = (unsigned long)-1"); ๐Ÿ˜„

#

First time working with exposing c++ externs, so sorry for the questions ๐Ÿ˜„

velvet lodge
#

no bother, i didnt actually know about the UnsignedLong type on hxcpp tbh ๐Ÿ™‚

wide solstice
#

the UnsignedLong was existing in RawMysqlClient.hx
@:native("unsigned long")
extern class UnsignedLong {

}

#

it was used already for some other extern

velvet lodge
#

oh, lol, i made it ๐Ÿ˜„

#

thought it was an hxcpp thing

wide solstice
#

hxcpp uses uint64 types which are cross platform

#

sadly libmysqlclient uses unsigned long, so I had to work around that a bit ๐Ÿ˜„

#

funny, now the github workflows are executing automatically

velvet lodge
#

i think they will fail anyway because of mysql not being setup, its a todo list somewhere to sort

wide solstice
#

or would that be the wrong place within prepareSQL

#

within sys there is an escape call for strings

velvet lodge
#

seems sensible, eventually that file will move to prepared statements, but in the meantime, certainly seems safer / apprporiate

wide solstice
#

okay, then I'll fork and adjust it ๐Ÿ™‚

velvet lodge
wide solstice
#

do you have any possibility to test the new escape within mysql?

#

Since I'm using libmysqlclient directly and there are no tests I cannot test it

velvet lodge
#

yeah, i should be able write UTs for it, the UTs work locally , just not as github actions

wide solstice
#

created a pull request that for cpp escapeString of _nativeConnection is used

#

sadly crypto of HaxeFoundation doesn't have a publicEncrypt method. In case it would be there I could have continued my haxe only mysql client ๐Ÿ˜„

velvet lodge
#

tbh, i kinda feel like, for things like this, its usually better to delegate to an external lib... otherwise i think you are always playing catch up

wide solstice
#

I guess it depends

#

but yes a cpp mysql extension which is exactly what I need is much easier ๐Ÿ˜„

toxic stratus
#

@velvet lodge @uncut phoenix @wide solstice We CAN add github dependencies via haxelib.json!

uncut phoenix
#

ooooo

toxic stratus
#
"dependencies": {
  "promises": "git:https://github.com/core-haxe/promises"
}
wide solstice
#

Also when I want to publish my package to haxelib? That is why I added promises as submodule with macro as source extending the class-path

velvet lodge
toxic stratus
#

I haven't tried it with a uploading directly to haxelib

velvet lodge
#

these libs arent on haxelib so thats wont be an issue

frosty locust
#

Also when I want to publish my package to haxelib?
no, for uploading to haxelib all dependencies need to be on haxelib too

velvet lodge
#

ah, sorry, got what NB meant now, thought that was to me

#

so right, Barbaric-Tofu will still need his "copy" solution in place ๐Ÿ‘Œ

toxic stratus
#

still useful for core haxe I guess tho

velvet lodge
#

yeah, be interesting to know if that sorts logo's HMM issue

uncut phoenix
#

I am guessing it would. Iโ€™ll test it later

toxic stratus
#

Does db-core have a syntax for is null or is not null ?

#

oh lol

#

literally the last commit (for tests)

toxic stratus
#

I added promises via git to the dependencies here

uncut phoenix
toxic stratus
uncut phoenix
#

lol

toxic stratus
#

would be quite nice to be able to never need to manually type that url out again tho

velvet lodge
#

yeah, i think if this works (as in vscode shows it correctly - which it probably will) then all core-haxe haxelib.jsons should do the same (which ill do at some point)

toxic stratus
#

@velvet lodge mysql doesn't work on hxcpp

#

trying to run an application gives the following errors

#

libssl-3-x64.dll was not found
libcrypto-3-x64.dll was not found

#

test case is simple

#
import db.DatabaseFactory;
import db.IDatabase;

class Main {
    static function main() {
        var db:IDatabase = DatabaseFactory.instance.createDatabase(DatabaseFactory.MYSQL, {
            database: "test",
            host: "localhost",
            user: "admin",
            pass: "pass"
        });

        db.connect().then(function(resp) {
            trace('connected');
        }, (err) -> trace(err));
    }
}
velvet lodge
#

works fine this end

#

do the UTs also fail for you?

#

might need openssl?

toxic stratus
#

i thought it would just work

#

i do have it somewhere but maybe not installed ๐Ÿค”

toxic stratus
velvet lodge
#

i didnt actually know about the dep, but it makes sense its using ssl... just had it installed so never knew about it

#

i guess that means you'd need to distribute the .dlls with any app shipped? Not sure how i feel about that... would prefer to statically link it

toxic stratus
#

yeah it's not very ideal

velvet lodge
#

im sure openssl can be used from source and included in with libmysql

#

also not sure how to tell libmysql to not use dlls... but there is probably a call spec in the header file somewhere

uncut phoenix
#

i wouldn't statically link it on linux

velvet lodge
#

its arguably not a great idea to statically link anything "security" like on any system

uncut phoenix
#

yeah, hashlink has faced issues with that

velvet lodge
#

generally, i prefer statically link (on all OS's) but i think in this case, its a valid exception

uncut phoenix
#

for sure

#

plus openssl is huge

velvet lodge
#

it is big, defo... and, mysqlclientlib is precompiled too (ie, .lib, not source)

#

might be able to finagle a way to use a statically linked version of openssl, but given the context, i dont think its the right way to go

#

so better to just make the dependency known in the readme or something (i didnt even know about the dep, but makes perfect sense)

uncut phoenix
#

you could probably check for it at compile time and give a more in depth error

#

readme good enough for now lol

velvet lodge
#

libssl-3-x64.dll was not found
libcrypto-3-x64.dll was not found

uncut phoenix
#

yeah

toxic stratus
#

cause i saw the tests passing ๐Ÿ˜‚

velvet lodge
#
--------------------------------------------------------------------------------
build: glint::analytics::client
--------------------------------------------------------------------------------
 - executing haxe (html5.hxml)
Error: Error: Library promises version git is not installed
     Error: Error: Library promises version git is not installed
#

yup, confirmed, its fine without it... sorry, reverting ๐Ÿ™‚

#

issue is that the dep specifies git and i use them as dev, so change is a no-go for me im afraid

toxic stratus
#

it's no big deal

#

a gap with haxelib x)

velvet lodge
#

yeah, i might look at (but not any time soon) publishing everything to haxelib but under things like core-haxe.http... it would mean -lib would have to change, but actually, -lib core-haxe.http is probably nicer really

knotty vortex
#

I'm using

-lib haxeui-blank
--macro haxe.ui.macros.ExternGenerator.generate('src-externs')
--macro include('haxe.ui.components')
--macro include('haxe.ui.containers')
--macro include('haxe.ui.containers.dialogs')
--macro include('haxe.ui.containers.menus')
--macro include('haxe.ui.containers.properties')```
But when compiling against those externs I receive
```src-externs/haxe/ui/backend/ComponentBase.hx:8: characters 124-153 : Not enough type parameters for haxe.ui.core.IEventDispatcher```
Any thoughts?
velvet lodge
#

might be a bug in the generator, i defo remember "hand fixing" a few little things

knotty vortex
#

ah, thanks

knotty vortex
#

For the record to fix after compile:

  1. change haxe.ui.backend.ComponentBase.hx line 8 by changing
    extern class ComponentBase extends haxe.ui.backend.ComponentSurface implements haxe.ui.core.IComponentContainer implements haxe.ui.core.IEventDispatcher implements haxe.ui.core.IClonable<haxe.ui.backend.ComponentBase> {
    to
    extern class ComponentBase extends haxe.ui.backend.ComponentSurface implements haxe.ui.core.IComponentContainer implements haxe.ui.core.IEventDispatcher<haxe.ui.events.UIEvent> implements haxe.ui.core.IClonable<haxe.ui.backend.ComponentBase> {
  2. copied haxe.ui.util.Color from git over extern
  3. copied haxe.ui.validators.Validators.hx from git over extern

Seems to work. Since I copied Color and Validators over extern there may be some file size increase but it was easiest

knotty vortex
#

Nope. IDK. Stopping for now with
haxe.ui.containers.TabView is not a constructor ButtonsView ComponentMacros.hx:900
Sorry for the noise

knotty vortex
uncut phoenix
#

just with a hxml?

#

i might just use crobes' haxe gsm

toxic stratus
#

i just read gsm as gasm ๐Ÿ˜„

velvet lodge
#

actually, im using a haven.xml file, but really that just generates an .hxml

velvet lodge
knotty vortex
#

Below is the extern creator
https://github.com/haxeuitest/TestApp/blob/main/html5.GenerateExterns.hxml
This is the Host. Not sure I need the macros in that (tested locally it looks like I do). The DCE that is in here, add/removing had no effect besides smaller.
https://github.com/haxeuitest/TestApp/blob/main/html5.host.hxml
This is the Client. I just converted the box with layout vertical into vbox for now
https://github.com/haxeuitest/TestApp/blob/main/html5.hxml

GitHub

Contribute to haxeuitest/TestApp development by creating an account on GitHub.

GitHub

Contribute to haxeuitest/TestApp development by creating an account on GitHub.

GitHub

Contribute to haxeuitest/TestApp development by creating an account on GitHub.

old juniper
knotty vortex
velvet lodge
#

So yeah, if you include all of haxeui in the modular host (https://github.com/haxeuitest/TestApp/blob/main/html5.host.hxml#L11-L15), then you wont see any particular size decrease - in fact, as you noticed, you may see a since increase since you are including everything. The idea would be to only include the classes you want in the modular host... I have some other ideas about including the externs in host and the concrete impls in modules (that would be loaded dynamically), i already do that for the "entities" in the glint application im writing, ie, the host has no clue about the the "enitites", and other modules use them via externs, but once the entities module is loaded, it provides the impls at runtime

#

(there is no reason why haxeui component impls - or anything really - couldnt work the same way)

knotty vortex
#

makes sense. My main goal was to allow compile times to decrease. Reducing host would likely mean more compile times? Sounds good though. Defs nice for release.

toxic stratus
#

Yo Ian, I have some info regarding websockets

#

i've managed to connect to a socket via wss

#

on native/hxcpp

#

it was completely blocking my app

#

that's the "only" thing I had to do really, so i'm not sure how valid that change is or complete, but for some reason ws isn't working and errors out with an error SSL - An invalid SSL record was received

#

even though it's meant to just be a local socket connection

velvet lodge
#

its probably a valid change, but i think that stuff need work anyway, this is still "half ported"

toxic stratus
#

just thought i'd mention it because i think this was on your todo list

velvet lodge
#

not sure about the wss though, i would have expected it to "just fail"

toxic stratus
# velvet lodge not sure about the wss though, i would have expected it to "just fail"
import haxe.Json;
import ws.WebSocket;

class Main {
    static function main() {
        trace("Hello, world!");
        var ws = new WebSocket('wss://stream.bybit.com/v5/public/spot');
        ws.onopen = () -> {
            trace('opened');
            ws.send(Json.stringify({
                req_id: "test", // optional
                op: "subscribe",
                args: ["kline.1.BTCUSDT"]
            }));
        }

        ws.onerror = (errr) -> {
            trace(errr);
        }

        ws.onmessage = (message) -> {
            trace(message);
        }
        ws.onclose = () -> {
            trace('socket closed');
        }
    }
}
``` here's a testcase if you want to visit it at some point
#

might require git hxcpp i'm not sure

#

it's also interesting to note, i only need to adjust the sleep for ceramic

toxic stratus
velvet lodge
toxic stratus
#

here's my modded websockets file

velvet lodge
#

ah, you removed the throw

toxic stratus
#

makes one other change (removes the throw for not implemented)

velvet lodge
#

but the throw was there because its not implemented / tested - so im not surprised it didnt work ๐Ÿ™‚

toxic stratus
#

but it does work!

velvet lodge
#

except it didnt right? It failed the SSL handshake

toxic stratus
#

for ws

#

not wss

velvet lodge
#

so, hang on, wss worked and ws failed an SSL handshake?

toxic stratus
#

it's backwards ๐Ÿ˜„

velvet lodge
#

very odd

toxic stratus
#

i've got a local websocket server websockets one

#

afaik that requires a ws connection

velvet lodge
#

right, ill have to play with this and get some UTs going

toxic stratus
#

works on nodejs but fails with SSL - An invalid SSL record was received

#

on cpp

velvet lodge
#

and this is ws, not wss?

toxic stratus
#
        try {
            client = new WebSocket("ws://localhost:8124");

            client.onopen = onOpen;
            client.onerror = onError;
            client.onmessage = onMessage;
        } catch (e) {
            trace(e);
        }
#

yep!

velvet lodge
#

very weird - maybe i screwed something up when i moved the file over, not sure

toxic stratus
velvet lodge
#

well, good that wss works i guess, thats one less thing...

toxic stratus
#

maybe, the whole situation seems odd to begin with ๐Ÿ˜„

velvet lodge
#

what lib are you using for your server?

toxic stratus
#

same lib

uncut phoenix
#

Wait you are actually using core-haxe/websockets?

uncut phoenix
#

i am still using the one on ian's github

#

should i move lol?

velvet lodge
#

oh, hang on so you are using core-haxe/ws for server too... right...

toxic stratus
uncut phoenix
#

tbf i would probably just use http if I knew better a few weeks ago

toxic stratus
#

core-haxe one is still incomplete, i moved for a reason but i've been running it for so long i can't recall what it is now

velvet lodge
toxic stratus
#

๐Ÿ˜„

#

oh lmao

velvet lodge
#

yeah

toxic stratus
#

i may have done this myself then

velvet lodge
#

ah, you are using the node server

#

still think there is something weird going on though... i still would have expected that to work with ws i think

uncut phoenix
#

Ah, for this specific project an http server would have made more sense compared to a websocket one

velvet lodge
#

right

uncut phoenix
#

it has just complicated things, nothing wrong with websockets for other stuff though

toxic stratus
velvet lodge
#

not sure, maybe... thought i use it in unit tests and its ws ther

#

i just ran the unit tests for hxcpp and they pass

#

and they use ws

#

actually all those haxe targets UTs pass (which is pretty cool actually)

toxic stratus
#

very odd

velvet lodge
#

i wonder if git hxcpp has broken something?

toxic stratus
#

how does the server unit test work when there's no implementation

#

i've shadow'd the module locally so that's why it works for me

#

oh no i haven't

#

the package structure is misleading x)

#

nodejs implementation is under ws/extern/nodejs

#

and your unit tests references the externs file instead of the impl file

#

lol

#

i never saw that

#

@velvet lodge could you run the tests there, i'd like to see if those pass ๐Ÿ‘€

#

Oh! I understand why normal ws fails

#

I'm trying to connect to through the ssl server

#

that pr will have the same issue i suspect

velvet lodge
toxic stratus
#

yes, all makes sense now

#

and i've got ws and wss running locally

#

now i need to figure out why db isn't working

#

i should really test things out more often on native ๐Ÿ˜…

#

debugging stuff over here is a pita

velvet lodge
#
Memory exhausted.
 try HXCPP_GC_BIG_BLOCKS.

this was a fun one