Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi guys πŸ™‚ we encountered the following problem: In the db (MariaDB) a boolean

Options
USPATDHK5
USPATDHK5 Posts: 60 πŸ§‘πŸ»β€πŸš€ - Cadet

Hi guys πŸ™‚
we encountered the following problem: In the db (MariaDB) a boolean is stored, represented as tiniInt -> 0 or 1. Whenever this value is queried using a select statement, e.g. in the SalesQuantityRepository this value is formatted and passed on as String.
After that whenever a comparison is done, e.g. $itemTransfer->getIsQuantitySplittable() === false; it evaluates to false, because '0' is not equal to false.

Does anyone encountered similar behaviour and do you know how to fix it?
changing === to == is not a valid solution in my opinion as this does not solve the actual problem.

Comments

  • Using non strict comparison (==) is actually the correct kind of comparison for such cases where the types can be inconsistent (also 1 vs '1' etc).
    Long term, of course, the underlying API should be cleaner in types and would enable full strict checking everyone.

  • Unknown
    edited April 2022
    Options

    If you want to be able to trust the documented types, check why those are not type casted before going into the transfer. Then that would be the source of the issue and where things need to be adjusted.

  • USPATDHK5
    USPATDHK5 Posts: 60 πŸ§‘πŸ»β€πŸš€ - Cadet
    Options

    All code I was referring to is located in the vendor namespace though πŸ˜•

  • Sure, but you can always make PRs to any vendor lib and push some useful changes with this.

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 πŸ§‘πŸ»β€πŸš€ - Cadet
    Options

    Its a bit strange since it feels no one ever changed the is_splittable option to false^^because then he would experience the same issue^^ … or may it just a mariadb related issue (saving bools as tinyint?)

  • Very much possible.

  • As soon as transfers are more strict this will become visible for sure πŸ™‚

  • USPATDHK5
    USPATDHK5 Posts: 60 πŸ§‘πŸ»β€πŸš€ - Cadet
    Options

    It is the same behaviour in the 'availability gui' for zed, there the availability is always 'false' πŸ˜•

  • I recommend an escalation through the normal channels.
    Speed up via PR (partial or full showcase/resolution) is of course highly recommended.

  • UP4C7GASJ
    UP4C7GASJ Posts: 19 πŸ§‘πŸ»β€πŸš€ - Cadet
    Options

    AFAIK, this is a Propel-MariaDB related thing that all return fields are now considered literals/strings and not numeric/boolean values anymore. We encountered that already on some custom queries that queried IDs and processed them internally with strict method types which broke due to hand over of string instead of int.

  • Unknown
    edited April 2022
    Options

    A PR to the repo would be most welcome
    Maybe we can fix this for the upcoming new beta release? More type safety is planned anyway.

  • UP4C7GASJ
    UP4C7GASJ Posts: 19 πŸ§‘πŸ»β€πŸš€ - Cadet
    Options

    Just a brief questions though, how was this not caught when proposing the switch of Postgres to MariaDB? πŸ€”