-
Notifications
You must be signed in to change notification settings - Fork 27
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 column helper #541
Add column helper #541
Conversation
@@ -32,3 +36,18 @@ internal abstract class ColumnNameMixin( | |||
return AllIcons.Nodes.DataColumn | |||
} | |||
} | |||
|
|||
fun SqlColumnName.getColumnDefOrNull(): SqlColumnDef? { |
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 think it's a little more nuanced then this, since columns can come from an alter table statement
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'm also pretty sure this is already done elsewhere in code quite a bit (going from column name to column def)
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.
Thanks, you are right. Also added a test for alter table.
f6a9b76
to
aea3f16
Compare
@@ -18,3 +21,26 @@ internal abstract class ForeignKeyClauseMixin( | |||
return super.queryAvailable(child) | |||
} | |||
} | |||
|
|||
fun SqlColumnDef.isForeignKey(): Boolean { |
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.
After thinking again, this won't work in sqldelight with the mysql dialect supporting ALTER TABLE DROP FOREIGN KEY
because this isn't a SqlColumnDef
... I guess the only option is to put the keys into the schema too 🤔
Related to sqldelight/sqldelight#4489