You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MySQL type TINYINT is a number between -128 and 127 (signed) or 0 and 255 (unsigned) so the corresponding type in Typescript should be number, not boolean.
It is true that booleans in MySQL are TINYINTs but the converse is not true. TINYINT is the correct type to use in MySQL for any integer that will fit inside of one byte, not just booleans.
One more note: I thought it might be possible to look for TINYINT(1) to determine if a field is actually a boolean. Unfortunately, the 1 is merely a formatting hint and does not affect the values that the column can store. Even if it did, it refers to the decimal rather than binary length, so TINYINT(1) could still be any number between 0 and 9 and not a boolean.
The text was updated successfully, but these errors were encountered:
The MySQL type
TINYINT
is a number between -128 and 127 (signed) or 0 and 255 (unsigned) so the corresponding type in Typescript should benumber
, notboolean
.It is true that booleans in MySQL are
TINYINT
s but the converse is not true.TINYINT
is the correct type to use in MySQL for any integer that will fit inside of one byte, not just booleans.In
src/schemaMysql.ts
there is a comment which states that the goal is to mirror the types from github.com/mysqljs. That library correctly maps TINYINTs to a number: https://github.com/mysqljs/mysql#type-castingOne more note: I thought it might be possible to look for
TINYINT(1)
to determine if a field is actually a boolean. Unfortunately, the1
is merely a formatting hint and does not affect the values that the column can store. Even if it did, it refers to the decimal rather than binary length, soTINYINT(1)
could still be any number between 0 and 9 and not a boolean.The text was updated successfully, but these errors were encountered: