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

Query is returning everything even if I used __selects__ in case of with_count. #572

Closed
yubarajshrestha opened this issue Jan 15, 2022 · 0 comments · Fixed by #575
Closed
Labels
bug An existing feature is not working as intended

Comments

@yubarajshrestha
Copy link
Contributor

When I use selects inside any model the query should only return the fields defined but query is returning everything including one added in selects. FYI this issues is only happening in when you use with_count.

To Reproduce

#  UserModel
class User(Model, SoftDeletesMixin, Authenticates, AuthenticatesTokens):
    """User Model."""

    __fillable__ = ["name", "email", "password"]
    __hidden__ = ["password"]
    __auth__ = "email"
    
    __selects__ = ["id", "name", "email as e"]

# Query
return User.with_count("categories").get() # categories can be any related table...

Current Output

{
            "id": 1,
            "name": "John Doe",
            "e": "john@doe.com",
            "email": "john@doe.com",
            "second_password": null,
            "remember_token": "e9341f44-ea4b-4624-a647-a26859653073",
            "phone": null,
            "verified_at": null,
            "created_at": "2022-01-07T20:11:16+05:45",
            "updated_at": "2022-01-14T23:48:20+05:45",
            "deleted_at": null,
            "api_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHBpcmVzIjpudWxsLCJ2ZXJzaW9uIjpudWxsfQ.4rmAFfanVKDeQXrpnfXfFipF8BaamDxWL4EWx0JwfLk6hDvlnAltyFLuD45B0NWnh6izkB2ZprPJwOM1Ak-h4g",
             "categories_count": 2
 }

Expected behavior

{
            "id": 1,
            "name": "John Doe",
            "e": "john@doe.com"
}
@yubarajshrestha yubarajshrestha added the bug An existing feature is not working as intended label Jan 15, 2022
@josephmancuso josephmancuso mentioned this issue Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An existing feature is not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant