mysql_fdw icon indicating copy to clipboard operation
mysql_fdw copied to clipboard

Import Schema should convert/map MySQL tinyint(1) to PG boolean.

Open aadrian opened this issue 9 months ago • 2 comments

Hi,

Import Schema should convert/map MySQL tinyint(1) to PG boolean (instead of the current smallint).

https://www.mysqltutorial.org/mysql-basics/mysql-boolean/

Thanks in advance.

aadrian avatar May 08 '24 07:05 aadrian

That's NOT correct.

MySQL just offers a way to represent a boolean using tinyint(1). They are NOT equivalent.

How will you differentiate between actual tinyint(1) contents and boolean?

jeevanchalke avatar May 08 '24 08:05 jeevanchalke

@jeevanchalke

MySQL just offers a way to represent a boolean using tinyint(1). They are NOT equivalent.

Since to this day MySQL does not have a "native" boolean type, tinyint(1) is the convention of the last ~20 years for boolean.

Misusing tinyint(1) for something else is a bad practice (I've yet to see a real project where this would be used otherwise).

Also most ORMs and reverse tools will map it directly to boolean too, or even tools like e.g. PGLoader https://github.com/dimitri/pgloader .

How will you differentiate between actual tinyint(1) contents and boolean?

It's a convention, no need to differentiate.
(If one really wants to differentiate than a flag for the import command would do it, but as default behavior please make it boolean.)

Thank you.

aadrian avatar May 08 '24 10:05 aadrian