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
Change postgresql boolean column type to BOOLEAN #767
Conversation
Signed-off-by: Kelly Banman <kelly.banman@gmail.com>
Signed-off-by: Kelly Banman <kelly.banman@gmail.com>
same for mysql. |
The problem with boolean columns in posgresql is that they appear as string 't' or string 'f' in php. That is really bad since they both equals to true when you do comparisons. So it is therefore good practice to use a bit or integer column instead. |
Is the PostgreSQL driver able to convert 't' and 'f' values for boolean columns to PHP true/false when results are returned? Or, is it able to change the SQL queries such that boolean columns are cast to integers, like so: "SELECT b::integer ..." ? In MySQL, BOOL is a synonym for TINYINT(1), which obviously works fine. However, Laravel currently generates TINYINT(4). Why waste 3 extra bytes for every row on every boolean column? |
I'm using PDO for PostgreSQL and boolean column values are converted to PHP true/false, not 't'/'f'. Since Laravel is using PDO for PostgreSQL I think that this change is very much needed. |
Don't want to change this in Laravel 3.x as it could break people's applications. Will consider for Laravel 4. |
@taylorotwell - If you choose to implement this, please be aware that it needs to be done using the following method when assigning false bools -> yiisoft/yii#779 |
TINYINT(4) does not take up more space, it just changes how many digits to display. |
Apply fixes from StyleCI
Apply fixes from StyleCI
Creating a boolean column with
Schema
under postgreSQL results in aSMALLINT
column type. Unlike MySQL, PostgreSQL has a real boolean type distinct from small integers.If you don't agree with this change, could you point out how one might use Schema to create proprietary column types such as the above?