Wrong return type in BitColumnSchema::phpTypecast
| Q | A |
|---|---|
| Version | current develop |
| PHP version | 8.3 |
| Operating system |
Good afternoon. In BitColumnSchema::phpTypecast there is an error in the returned type. As you can see from the documentation, the bindec function can return int|float, while phpTypecast int|null.
In my case, it is a field of type bit varying with the following content for exaple 1100000100011100100110001011000010100000001011001101111011100000 (p-hash images to find duplicates). And on the output I need a string in the same form. Maybe for this type it is not necessary to convert the type to a decimal number. Thanks
Need to add another column class for big bit types BigBitColumnSchema, where the typecasting will be to a string number using base_convert($value, 2, 10) or returning the string as is.
Need to add another column class for big
bittypesBigBitColumnSchema, where the typecasting will be to a string number usingbase_convert($value, 2, 10)or returning the string as is.
It's no problem with float - just add right return type int|float|null https://onlinephp.io/c/89d1d example
If simply add float, the result may be incorrect since precision is lost.
Need to add another column class for big
bittypesBigBitColumnSchema, where the typecasting will be to a string number usingbase_convert($value, 2, 10)or returning the string as is.
Should bigbit be added in yiisoft/db as new abstract column type?
Should
bigbitbe added inyiisoft/dbas new abstract column type?
I don't think it's necessary. There is no problem if we know only bit abstract type and its size.
Fixed