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

Ticket #22210: Saving Model instance to Float Field #2404

Closed
wants to merge 6 commits into from

Conversation

PirosB3
Copy link
Contributor

@PirosB3 PirosB3 commented Mar 6, 2014

  • Added failing test case
  • Added fix
  • All tests passing

This is the first time I contribute to Django, please let me know if I need to adjust something :)

val = val.prepare_database_save(field)
else:
raise TypeError("Database is trying to update a relational field "
"with a value of type %s. Please check you are "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have an %s in the error message, but you aren't formatting the string with a parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will fix it now

@PirosB3
Copy link
Contributor Author

PirosB3 commented Mar 10, 2014

Hi guys, any update on this?

@jarshwah
Copy link
Member

Looks good to me, as long as all the tests pass. @PirosB3 you'll want to squash all the commits into a single commit to make it easier for the core team to merge.

There is one line that may raise some concerns:

if field.rel or isinstance(val, ExpressionNode)

There really isn't a better way of checking, IMO, and a similar check is done in other places (like sql/query and gis/query).

@PirosB3
Copy link
Contributor Author

PirosB3 commented Mar 10, 2014

@jarshwah thanks for the comments. I will look at sql/query to see if they can be improved!

@jarshwah
Copy link
Member

No problem. No need to look at sql/query, that was just a reference for others to see that isinstance(.., ExpressionNode) is used elsewhere also. isinstance checks are usually discouraged, which is why I described why I think it is necessary here.

@mjtamlyn
Copy link
Member

Thanks, fixed in 819e09b (with release notes)

@mjtamlyn mjtamlyn closed this Mar 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants