Skip to content

Commit

Permalink
Use reference and not error-prone name
Browse files Browse the repository at this point in the history
  • Loading branch information
hfhbd committed Aug 4, 2023
1 parent 59bdbf9 commit f6a9b76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ internal abstract class ColumnNameMixin(
}

fun SqlColumnName.getColumnDefOrNull(): SqlColumnDef? {
val ref = reference?.resolve() ?: return null
val tables = tablesAvailable(this)
for (table in tables) {
val tableDef = table.tableName.parentOfType<SqlCreateTableStmt>() ?: continue
for (columnDef in tableDef.columnDefList) {
val name = columnDef.columnName.name
if (name == this.name) {
val columnRef = columnDef.columnName.reference
if (columnRef != null && columnRef.resolve() == ref) {
return columnDef
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fun SqlColumnDef.isForeignKey(): Boolean {
if (foreignTableClause != null) {
val columns = foreignTableClause.columnNameList
for (column in columns) {
if (column.name == columnName.name) {
if (column.reference?.resolve() == columnName) {
return true
}
}
Expand Down

0 comments on commit f6a9b76

Please sign in to comment.