diff --git a/sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/native/NativeCursor.kt b/sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/native/NativeCursor.kt index f13a6120..cabbe6b8 100644 --- a/sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/native/NativeCursor.kt +++ b/sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/native/NativeCursor.kt @@ -37,7 +37,18 @@ class NativeCursor(override val statement: NativeStatement) : Cursor { override val columnNames: Map by lazy { val map = HashMap(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 }