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

Change postgresql boolean column type to BOOLEAN #767

Closed
wants to merge 2 commits into from
Closed

Change postgresql boolean column type to BOOLEAN #767

wants to merge 2 commits into from

Conversation

kbanman
Copy link
Contributor

@kbanman kbanman commented Jun 5, 2012

Creating a boolean column with Schema under postgreSQL results in a SMALLINT 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?

Signed-off-by: Kelly Banman <kelly.banman@gmail.com>
Signed-off-by: Kelly Banman <kelly.banman@gmail.com>
@vpetrov
Copy link

vpetrov commented Jun 7, 2012

same for mysql.

@mark-poulsen
Copy link

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.

@vpetrov
Copy link

vpetrov commented Jun 8, 2012

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?

@Furgas
Copy link

Furgas commented Jun 11, 2012

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.

@taylorotwell
Copy link
Member

Don't want to change this in Laravel 3.x as it could break people's applications. Will consider for Laravel 4.

@JoshZA
Copy link

JoshZA commented Sep 14, 2012

@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

@ar45
Copy link

ar45 commented Oct 17, 2013

TINYINT(4) does not take up more space, it just changes how many digits to display.

flap152 pushed a commit to flap152/laravel that referenced this pull request Nov 24, 2017
flap152 pushed a commit to flap152/laravel that referenced this pull request Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants