mithrandyr / SimplySql

PowerShell module for querying various SQL databases
MIT License
197 stars 31 forks source link

TinyINT is not a TRUE\FALSE column #130

Closed tomerikko closed 6 months ago

tomerikko commented 6 months ago

Hey team, thanks for this great product. I have an issue (and i might be getting it all wrong as i dont touch DBs a lot) We have a MySQL DB which has a field set as TINYINT. when i query it from a random MySQL UI SW, that field value may be 0 or 1 or 2. but when i query it via: SimplySql using: Invoke-SqlQuery the value of that field is either TRUE or FALSE. From google searching it seems its quite common and i somehow support to make it stop being treated as a boolean, and i found this flag: TreatTinyAsBoolean=false but i have no idea where should i place it to make my query return the right values.

ANy help would be gratly appreciated.

mithrandyr commented 6 months ago

@tomerikko -- I added new functionality in version2 to allow passing arbitrary additional parameters when opening a connection. It is the -additional parameter (takes a hashtable). So in this case, you want to pass "TreatTinyAsBoolean" as the key and $false as the value.

Open-MySqlConnection -Credential (Get-Credential) -Additional @{"TreatTinyAsBoolean" = $false}

this will force all TINYINT(1) columns to be returned as sbyte instead of boolean.

mithrandyr commented 6 months ago

@tomerikko -- closing this issue, but feel free to reopen if the above doesn't work.