EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
532 stars 163 forks source link

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

Open aadrian opened 4 months ago

aadrian commented 4 months ago

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.

jeevanchalke commented 4 months ago

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?

aadrian commented 4 months ago

@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.