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

[BUG]: if model has field source ,it cannot be assigned by assign #16617

Open
itknight opened this issue Jun 28, 2024 · 2 comments
Open

[BUG]: if model has field source ,it cannot be assigned by assign #16617

itknight opened this issue Jun 28, 2024 · 2 comments
Labels
bug A bug report status: unverified Unverified

Comments

@itknight
Copy link

itknight commented Jun 28, 2024

Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord

Describe the bug
A clear and concise description of what the bug is.

I have a model CharmingU and it has a field source, when i update charming_u record by assgin ,it cannot be updated,
just like below:
image

i've printed the value with line numbers, and its query result ,just like belows:

image

so , i tried update it manually ,it works.,just like below:

image

i don't if it is a bug or my mistake, if you wanna reproduce it ,just like below:

To Reproduce

Provide output if related. Provide coredump if any. Use https://docs.phalcon.io/latest/generating-backtrace as reference.

1.make a model any name ,
2. make sure it has a field called source.
3. update it by using assign
4. check it out.

PHP version :
image

Phalcon Version:
image

@itknight itknight added bug A bug report status: unverified Unverified labels Jun 28, 2024
@noone-silent
Copy link
Contributor

I think this is happening, because of the setSource() method. The assign() method is calling setters if the exist, but setSource() has a special meaning.

A workaround of this problem is to use a MetaData Strategy (like Annotations) to rewrite the field source to something else without changing your database.

Also you could rename your database field.

@yahveh
Copy link

yahveh commented Aug 10, 2024

Is it possible to consider the internal properties of the Model, refer to cphalcon 3.x and add an underscore prefix, and some built-in methods also do some adjustment convention rules for easy identification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: unverified Unverified
Projects
None yet
Development

No branches or pull requests

3 participants