generated from MasoniteFramework/starter-package
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
Base Models overriding table name #380
Labels
bug
An existing feature is not working as intended
needs more info
This is a ticket that requires more information from the author
Comments
Cannot replicate this |
class BaseModel(Model):
pass
class Store(BaseModel):
__connection__ = "dev"
__fillable__ = ["name"]
__guarded__ = ["bob"]
@scope
def by_search(self, query, search, search_key='title'):
if not search:
return query
search_queries = search.split()
for search_query in search_queries:
if ':' in search_query:
key, value = search_query.split(':')
if value in ('true', 'false'):
query = query.where(key, 1 if value == 'true' else 0)
else:
query = query.where(key, 'like', f"%{value}%")
else:
query = query.where(search_key, 'like', f"%{search_query}%")
return query
print(Store.where("name", "Walmart").to_sql()) #== SELECT * FROM "stores" WHERE "stores"."name" = 'Walmart' |
maybe you imported the basemodel accidentally? can I see maybe where you imported this user model you were talking about? |
josephmancuso
added
the
needs more info
This is a ticket that requires more information from the author
label
Feb 10, 2021
Will close this issue until more context is given |
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
needs more info
This is a ticket that requires more information from the author
Describe the bug
If you have a base model it is overriding the table name of the child model.
To Reproduce
Steps to reproduce the behavior:
BaseModel
class.User
modelbase_models
table instead ofusers
tableThe text was updated successfully, but these errors were encountered: