Navigation Menu

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

Fixes #554 representation of new model instances #555

Merged
merged 4 commits into from Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion flask_sqlalchemy/model.py
Expand Up @@ -120,7 +120,7 @@ class Model(object):
def __repr__(self):
identity = inspect(self).identity
if identity is None:
pk = "(transient) {0}".format(id(self))
pk = "(transient {0})".format(id(self))
else:
pk = ', '.join(to_str(value) for value in identity)
return '<{0} {1}>'.format(type(self).__name__, pk)
1 change: 1 addition & 0 deletions tests/test_model_class.py
Expand Up @@ -43,6 +43,7 @@ class Report(db.Model):
db.create_all()

u = User(name='test')
assert repr(u).startswith("<User (transient ") is True
Copy link
Member

Choose a reason for hiding this comment

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

remove is True, it's redundant

db.session.add(u)
db.session.flush()
assert repr(u) == '<User test>'
Expand Down