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

PostgreSQL: bad type conversion for bit type #7682

Closed
Tigrov opened this issue Mar 12, 2015 · 3 comments
Closed

PostgreSQL: bad type conversion for bit type #7682

Tigrov opened this issue Mar 12, 2015 · 3 comments
Labels
feature:db PostgreSQL status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@Tigrov
Copy link
Member

Tigrov commented Mar 12, 2015

Postgres returns bit as a string, e.g. '101'
but current type conversion makes integer 101, it's not correct.
The same problem with insert, integer is not correct for postgres bit type.

http://www.postgresql.org/docs/current/static/datatype-bit.html
http://www.postgresql.org/docs/current/static/datatype.html#DATATYPE-TABLE

I think it needs to add one more abstract type into Schema class

const TYPE_BIT = 'bit';

And then convert the type for php bindec() and for db decbin()

@Yiivgeny
Copy link

Yiivgeny commented Dec 4, 2015

This conversion also thrown String data, length mismatch: 7 ERROR: bit string length 4 does not match type bit(8), for data zero-leading ('00001111') values on bit columns write.

@Yiivgeny
Copy link

Yiivgeny commented Dec 4, 2015

May be using 'bit' => self::TYPE_STRING in typeMap as lightweight fix? Not ideal, but not cause error or read\write fully incorrect data?

Many (all?) GUI represent this type as 0|1 string without any conversion (what about over 64 bit digit or varbit without length?).

@Tigrov
Copy link
Member Author

Tigrov commented Jan 30, 2017

I made an extention to fix it
https://github.com/Tigrov/yii2-pgsql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:db PostgreSQL status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

4 participants