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

Wrong return type in BitColumnSchema::phpTypecast #369

Open
Gerych1984 opened this issue Nov 4, 2024 · 5 comments
Open

Wrong return type in BitColumnSchema::phpTypecast #369

Gerych1984 opened this issue Nov 4, 2024 · 5 comments
Labels

Comments

@Gerych1984
Copy link

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

@Tigrov
Copy link
Member

Tigrov commented Nov 5, 2024

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.

@Tigrov Tigrov added the type:bug Bug label Nov 5, 2024
@Gerych1984
Copy link
Author

Gerych1984 commented Nov 5, 2024

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.

It's no problem with float - just add right return type int|float|null https://onlinephp.io/c/89d1d example

@Tigrov
Copy link
Member

Tigrov commented Nov 7, 2024

If simply add float, the result may be incorrect since precision is lost.

@vjik
Copy link
Member

vjik commented Nov 14, 2024

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.

Should bigbit be added in yiisoft/db as new abstract column type?

@Tigrov
Copy link
Member

Tigrov commented Nov 15, 2024

Should bigbit be added in yiisoft/db as 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants