Skip to content

Commit db3d704

Browse files
authored
Merge pull request #112 from touchlab/qiaoyuang-main
Qiaoyuang main
2 parents ba4ff02 + 8968474 commit db3d704

File tree

1 file changed

+12
-1
lines changed
  • sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/native

1 file changed

+12
-1
lines changed

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/native/NativeCursor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,18 @@ class NativeCursor(override val statement: NativeStatement) : Cursor {
3737
override val columnNames: Map<String, Int> by lazy {
3838
val map = HashMap<String, Int>(this.columnCount)
3939
for (i in 0 until columnCount) {
40-
map.put(columnName(i), i)
40+
val key = columnName(i)
41+
if (map.containsKey(key)) {
42+
var index = 1
43+
val basicKey = "$key&JOIN"
44+
var finalKey = basicKey + index
45+
while (map.containsKey(finalKey)) {
46+
finalKey = basicKey + ++index
47+
}
48+
map[finalKey] = i
49+
} else {
50+
map[key] = i
51+
}
4152
}
4253
map
4354
}

0 commit comments

Comments
 (0)