Skip to content

Commit

Permalink
Change .star to .__star__
Browse files Browse the repository at this point in the history
Fixes #2796
  • Loading branch information
coleifer committed Oct 20, 2023
1 parent c8d666c commit f400b68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ https://github.com/coleifer/peewee/releases

## master

* The new `star` attribute was causing issues for users who had a field named
star on their models. This attribute is now renamed to `__star__`. #2796.

[View commits](https://github.com/coleifer/peewee/compare/3.17.0...master)

## 3.17.0
Expand Down
2 changes: 1 addition & 1 deletion peewee.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def select(self, *columns):
return Select((self,), columns)

@property
def star(self):
def __star__(self):
return NodeList((QualifiedNames(self), SQL('.*')), glue='')

def join(self, dest, join_type=JOIN.INNER, on=None):
Expand Down
6 changes: 3 additions & 3 deletions tests/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,19 @@ def test_subquery_in_select_expression_sql(self):
'ORDER BY "t1"."x", "t1"."y"'), [])

def test_star(self):
query = User.select(User.star)
query = User.select(User.__star__)
self.assertSQL(query, ('SELECT "t1".* FROM "users" AS "t1"'), [])

query = (Tweet
.select(Tweet.star, User.star)
.select(Tweet.__star__, User.__star__)
.join(User, on=(Tweet.c.user_id == User.c.id)))
self.assertSQL(query, (
'SELECT "t1".*, "t2".* '
'FROM "tweets" AS "t1" '
'INNER JOIN "users" AS "t2" ON ("t1"."user_id" = "t2"."id")'), [])

query = (Tweet
.select(Tweet.star, User.c.id)
.select(Tweet.__star__, User.c.id)
.join(User, on=(Tweet.c.user_id == User.c.id)))
self.assertSQL(query, (
'SELECT "t1".*, "t2"."id" '
Expand Down

0 comments on commit f400b68

Please sign in to comment.