diff --git a/gradle.properties b/gradle.properties index ad301ec..8100610 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,6 +27,7 @@ kotlin.code.style=official kotlin.mpp.stability.nowarn=true kotlin.mpp.enableCInteropCommonization=true kotlin.native.increment=true +kotlin.native.ignoreDisabledTargets=true kotlin.jvm.target.validation.mode=warning kotlin.native.binary.pagedAllocator=false kotlin.native.binary.latin1Strings=true diff --git a/sqllin-driver/build.gradle.kts b/sqllin-driver/build.gradle.kts index b5184c4..d86b0b7 100644 --- a/sqllin-driver/build.gradle.kts +++ b/sqllin-driver/build.gradle.kts @@ -89,12 +89,12 @@ gradle.taskGraph.whenReady { return@whenReady tasks.forEach { when { - it.name.contains("linux", true) -> { - it.enabled = HostManager.hostIsLinux - } - it.name.contains("mingw", true) -> { - it.enabled = HostManager.hostIsMingw - } + it.name.contains("linux", true) -> it.enabled = HostManager.hostIsLinux + it.name.contains("mingw", true) -> it.enabled = HostManager.hostIsMingw + it.name.contains("ios", true) + || it.name.contains("macos", true) + || it.name.contains("watchos", true) + || it.name.contains("tvos", true) -> it.enabled = HostManager.hostIsMac } } } diff --git a/sqllin-driver/src/androidMain/AndroidManifest.xml b/sqllin-driver/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 7e1d321..0000000 --- a/sqllin-driver/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/sqllin-dsl/build.gradle.kts b/sqllin-dsl/build.gradle.kts index e3df36a..70ea846 100644 --- a/sqllin-dsl/build.gradle.kts +++ b/sqllin-dsl/build.gradle.kts @@ -63,34 +63,6 @@ kotlin { implementation(libs.kotlinx.serialization) implementation(libs.kotlinx.coroutines.core) } - val jvmAndNativeMain by creating { - dependsOn(commonMain.get()) - } - - jvmMain { dependsOn(jvmAndNativeMain) } - - // Configure all native targets to depend on jvmAndNativeMain - iosX64Main { dependsOn(jvmAndNativeMain) } - iosArm64Main { dependsOn(jvmAndNativeMain) } - iosSimulatorArm64Main { dependsOn(jvmAndNativeMain) } - - macosX64Main { dependsOn(jvmAndNativeMain) } - macosArm64Main { dependsOn(jvmAndNativeMain) } - - watchosArm32Main { dependsOn(jvmAndNativeMain) } - watchosArm64Main { dependsOn(jvmAndNativeMain) } - watchosX64Main { dependsOn(jvmAndNativeMain) } - watchosSimulatorArm64Main { dependsOn(jvmAndNativeMain) } - watchosDeviceArm64Main { dependsOn(jvmAndNativeMain) } - - tvosArm64Main { dependsOn(jvmAndNativeMain) } - tvosX64Main { dependsOn(jvmAndNativeMain) } - tvosSimulatorArm64Main { dependsOn(jvmAndNativeMain) } - - linuxX64Main { dependsOn(jvmAndNativeMain) } - linuxArm64Main { dependsOn(jvmAndNativeMain) } - - mingwX64Main { dependsOn(jvmAndNativeMain) } } } @@ -99,12 +71,12 @@ gradle.taskGraph.whenReady { return@whenReady tasks.forEach { when { - it.name.contains("linux", true) -> { - it.enabled = HostManager.hostIsLinux - } - it.name.contains("mingw", true) -> { - it.enabled = HostManager.hostIsMingw - } + it.name.contains("linux", true) -> it.enabled = HostManager.hostIsLinux + it.name.contains("mingw", true) -> it.enabled = HostManager.hostIsMingw + it.name.contains("ios", true) + || it.name.contains("macos", true) + || it.name.contains("watchos", true) + || it.name.contains("tvos", true) -> it.enabled = HostManager.hostIsMac } } } diff --git a/sqllin-dsl/src/androidMain/AndroidManifest.xml b/sqllin-dsl/src/androidMain/AndroidManifest.xml deleted file mode 100644 index feda084..0000000 --- a/sqllin-dsl/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/sqllin-dsl/src/androidMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/AndroidClauseBlob.kt b/sqllin-dsl/src/androidMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/AndroidClauseBlob.kt deleted file mode 100644 index 1362543..0000000 --- a/sqllin-dsl/src/androidMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/AndroidClauseBlob.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2025 Ctrip.com. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ctrip.sqllin.dsl.sql.clause - -import com.ctrip.sqllin.dsl.sql.Table - -/** - * Android-specific implementation of BLOB clause handling. - * - * On Android, SQLite BLOB literals use hexadecimal notation (X'...' format). - * This implementation converts ByteArray values to hex strings inline in the SQL, - * avoiding the need for parameterized binding for BLOB values on Android. - * - * For example, a ByteArray of [0x01, 0x02, 0xFF] becomes: X'0102FF' - * - * @author Yuang Qiao - */ -internal class AndroidClauseBlob( - valueName: String, - table: Table<*>, - isFunction: Boolean, -) : DefaultClauseBlob(valueName, table, isFunction) { - - /** - * Appends a BLOB value to the SQL condition using Android's hex literal format. - * - * Instead of using parameterized binding, this converts ByteArray to hex notation. - * Non-null values are encoded as X'hexstring' literals directly in the SQL. - * - * @param notNullSymbol The comparison operator (=, !=, etc.) - * @param nullSymbol The SQL clause to use when blob is null (IS NULL, IS NOT NULL) - * @param blob The ByteArray value to encode, or null - * @return SelectCondition with hex-encoded SQL and no parameters - */ - override fun appendBlob( - notNullSymbol: String, - nullSymbol: String, - blob: ByteArray? - ): SelectCondition { - val sql = buildString { - if (!isFunction) { - append(table.tableName) - append('.') - } - append(valueName) - if (blob == null) { - append(nullSymbol) - } else { - append(notNullSymbol) - append("X'") - append(blob.toHexString(HexFormat.UpperCase)) - append('\'') - } - } - return SelectCondition(sql, null) - } -} - -/** - * Platform-specific factory function for creating BLOB clause wrappers on Android. - * - * Returns an [AndroidClauseBlob] instance that uses hex literal encoding for BLOB values. - * - * @param valueName The column or function name - * @param table The table this clause belongs to - * @param isFunction True if this represents a SQL function result - * @return AndroidClauseBlob instance - */ -public actual fun ClauseBlob( - valueName: String, - table: Table<*>, - isFunction: Boolean, -): DefaultClauseBlob = AndroidClauseBlob(valueName, table, isFunction) \ No newline at end of file diff --git a/sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/ClauseBlob.kt b/sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/ClauseBlob.kt index f391d77..82e66e6 100644 --- a/sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/ClauseBlob.kt +++ b/sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/ClauseBlob.kt @@ -34,7 +34,7 @@ import com.ctrip.sqllin.dsl.sql.Table * * @author Yuang Qiao */ -public open class DefaultClauseBlob internal constructor( +public class ClauseBlob( valueName: String, table: Table<*>, isFunction: Boolean, @@ -58,7 +58,7 @@ public open class DefaultClauseBlob internal constructor( * @param clauseBlob The BLOB column/function to compare against * @return Condition expression comparing two BLOB columns */ - internal infix fun eq(clauseBlob: DefaultClauseBlob): SelectCondition = appendClauseBlob("=", clauseBlob) + internal infix fun eq(clauseBlob: ClauseBlob): SelectCondition = appendClauseBlob("=", clauseBlob) /** * Creates an inequality comparison condition (!=). @@ -78,9 +78,9 @@ public open class DefaultClauseBlob internal constructor( * @param clauseBlob The BLOB column/function to compare against * @return Condition expression comparing two BLOB columns */ - internal infix fun neq(clauseBlob: DefaultClauseBlob): SelectCondition = appendClauseBlob("!=", clauseBlob) + internal infix fun neq(clauseBlob: ClauseBlob): SelectCondition = appendClauseBlob("!=", clauseBlob) - protected open fun appendBlob(notNullSymbol: String, nullSymbol: String, blob: ByteArray?): SelectCondition { + private fun appendBlob(notNullSymbol: String, nullSymbol: String, blob: ByteArray?): SelectCondition { val sql = buildString { if (!isFunction) { append(table.tableName) @@ -97,7 +97,7 @@ public open class DefaultClauseBlob internal constructor( return SelectCondition(sql, if (blob == null) null else mutableListOf(blob)) } - private fun appendClauseBlob(symbol: String, clauseBlob: DefaultClauseBlob): SelectCondition { + private fun appendClauseBlob(symbol: String, clauseBlob: ClauseBlob): SelectCondition { val sql = buildString { append(table.tableName) append('.') @@ -113,13 +113,7 @@ public open class DefaultClauseBlob internal constructor( } override fun hashCode(): Int = valueName.hashCode() + table.tableName.hashCode() - override fun equals(other: Any?): Boolean = (other as? DefaultClauseBlob)?.let { + override fun equals(other: Any?): Boolean = (other as? ClauseBlob)?.let { it.valueName == valueName && it.table.tableName == table.tableName } ?: false -} - -public expect fun ClauseBlob( - valueName: String, - table: Table<*>, - isFunction: Boolean, -): DefaultClauseBlob \ No newline at end of file +} \ No newline at end of file diff --git a/sqllin-dsl/src/jvmAndNativeMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/OtherClauseBlob.kt b/sqllin-dsl/src/jvmAndNativeMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/OtherClauseBlob.kt deleted file mode 100644 index f92d915..0000000 --- a/sqllin-dsl/src/jvmAndNativeMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/OtherClauseBlob.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2025 Ctrip.com. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ctrip.sqllin.dsl.sql.clause - -import com.ctrip.sqllin.dsl.sql.Table - -/** - * Platform-specific factory function for creating BLOB clause wrappers on JVM and Native platforms. - * - * Returns the default [DefaultClauseBlob] implementation which uses parameterized binding - * for BLOB values. This approach passes ByteArray values as parameters rather than embedding - * them as literals in the SQL string. - * - * @param valueName The column or function name - * @param table The table this clause belongs to - * @param isFunction True if this represents a SQL function result - * @return DefaultClauseBlob instance using parameterized binding - */ -public actual fun ClauseBlob( - valueName: String, - table: Table<*>, - isFunction: Boolean, -): DefaultClauseBlob = DefaultClauseBlob(valueName, table, isFunction) \ No newline at end of file diff --git a/sqllin-processor/src/main/kotlin/com/ctrip/sqllin/processor/ClauseProcessor.kt b/sqllin-processor/src/main/kotlin/com/ctrip/sqllin/processor/ClauseProcessor.kt index 430f1bc..058a216 100644 --- a/sqllin-processor/src/main/kotlin/com/ctrip/sqllin/processor/ClauseProcessor.kt +++ b/sqllin-processor/src/main/kotlin/com/ctrip/sqllin/processor/ClauseProcessor.kt @@ -101,7 +101,6 @@ class ClauseProcessor( writer.write("import com.ctrip.sqllin.dsl.sql.clause.ClauseBoolean\n") writer.write("import com.ctrip.sqllin.dsl.sql.clause.ClauseNumber\n") writer.write("import com.ctrip.sqllin.dsl.sql.clause.ClauseString\n") - writer.write("import com.ctrip.sqllin.dsl.sql.clause.DefaultClauseBlob\n") writer.write("import com.ctrip.sqllin.dsl.sql.clause.SetClause\n") writer.write("import com.ctrip.sqllin.dsl.sql.PrimaryKeyInfo\n") writer.write("import com.ctrip.sqllin.dsl.sql.Table\n\n")