Skip to content

Commit

Permalink
Fix the behavior of Cursor's columnNames that SELECT the columns thos…
Browse files Browse the repository at this point in the history
…e have same name in two tables at JOIN clause
  • Loading branch information
qiaoyuang committed Dec 13, 2022
1 parent c80bc7a commit 05e8ea5
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@ class NativeCursor(override val statement: NativeStatement) : Cursor {
override val columnNames: Map<String, Int> by lazy {
val map = HashMap<String, Int>(this.columnCount)
for (i in 0 until columnCount) {
map.put(columnName(i), i)
val key = columnName(i)
if (map.containsKey(key)) {
var index = 1
val basicKey = "$key&JOIN"
var finalKey = basicKey + index
while (map.containsKey(finalKey)) {
finalKey = basicKey + ++index
}
map[finalKey] = i
} else {
map[key] = i
}
}
map
}
Expand Down

0 comments on commit 05e8ea5

Please sign in to comment.