Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL: TINYINT should be a number, not a boolean #116

Open
seraph0x opened this issue Mar 14, 2020 · 1 comment
Open

MySQL: TINYINT should be a number, not a boolean #116

seraph0x opened this issue Mar 14, 2020 · 1 comment

Comments

@seraph0x
Copy link

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.

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-casting

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.

@naseemkullah
Copy link

Dear maintainers: Would a PR be merged in if created?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants