-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add morphs helper to blueprint #228
Add morphs helper to blueprint #228
Conversation
@josephmancuso ready for review with some questions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
src/masoniteorm/schema/Blueprint.py
Outdated
""" | ||
self._last_column = self.table.add_column( | ||
"{}_id".format(column), "unsigned_integer", nullable=nullable | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. What about in the case someone does:
table.morphs('record').nullable()
? We might have to add self._last_column as a list or tuple and then nullable will act on all the elements in the list? Same actually goes for table.timestamps()
too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not thought about that, I'll look into it
@josephmancuso and what about this part :
|
I don't see why not. Maybe have that as a parameter. |
|
||
Returns: | ||
self | ||
""" | ||
self._last_column.nullable() | ||
_columns = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josephmancuso Here I deal with multiple columns locally in nullable() method but we could also have done it globally in the Blueprint class by always using self._last_column as a list.
Don't know what's best
Added
morphs
to ease polymorphism relationships creation.Still following Like,Article,Comment example we can now do: