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

Add column helper #541

Closed
wants to merge 4 commits into from
Closed

Add column helper #541

wants to merge 4 commits into from

Conversation

hfhbd
Copy link
Collaborator

@hfhbd hfhbd commented Aug 4, 2023

@@ -32,3 +36,18 @@ internal abstract class ColumnNameMixin(
return AllIcons.Nodes.DataColumn
}
}

fun SqlColumnName.getColumnDefOrNull(): SqlColumnDef? {
Copy link
Collaborator

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

Copy link
Collaborator

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)

Copy link
Collaborator Author

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.

@@ -18,3 +21,26 @@ internal abstract class ForeignKeyClauseMixin(
return super.queryAvailable(child)
}
}

fun SqlColumnDef.isForeignKey(): Boolean {
Copy link
Collaborator Author

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 🤔

@hfhbd hfhbd closed this Nov 5, 2023
@hfhbd hfhbd deleted the hfhbd/columnHelper branch November 5, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants