Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### sqllin-dsl

* Optimized performance for SQL assembly
* New API for creating Database: `DSLDBConfiguration`
* New experimental API: `DatabaseScope#CREATE`
* New experimental API: `DatabaseScope#DROP`
* New experimental API: `DatabaseSceop#ALERT`
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android.enableJetifier=true
kotlin.code.style=official
kotlin.mpp.stability.nowarn=true
kotlin.mpp.enableCInteropCommonization=true
kotlin.natvie.increment=true
kotlin.native.increment=true
kotlin.jvm.target.validation.mode=warning
kotlin.native.binary.pagedAllocator=false
kotlin.native.binary.latin1Strings=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.ctrip.sqllin.driver.DatabaseConfiguration
import com.ctrip.sqllin.driver.DatabasePath
import com.ctrip.sqllin.driver.JournalMode
import com.ctrip.sqllin.driver.SynchronousMode
import com.ctrip.sqllin.dsl.annotation.ExperimentalDSLDatabaseAPI

/**
* DSL-level database configuration with [DatabaseScope] callbacks.
Expand All @@ -42,6 +43,7 @@ import com.ctrip.sqllin.driver.SynchronousMode
*
* @author Yuang Qiao
*/
@ExperimentalDSLDatabaseAPI
public data class DSLDBConfiguration(
val name: String,
val path: DatabasePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.ctrip.sqllin.dsl
import com.ctrip.sqllin.driver.DatabaseConfiguration
import com.ctrip.sqllin.driver.DatabasePath
import com.ctrip.sqllin.driver.openDatabase
import com.ctrip.sqllin.dsl.annotation.ExperimentalDSLDatabaseAPI

/**
* Factory functions for creating [Database] instances.
Expand Down Expand Up @@ -73,6 +74,7 @@ public fun Database(
* @param enableSimpleSQLLog Whether to enable simple SQL logging for debugging
* @return A new database instance
*/
@ExperimentalDSLDatabaseAPI
public fun Database(
dsldbConfiguration: DSLDBConfiguration,
enableSimpleSQLLog: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.ctrip.sqllin.dsl

import com.ctrip.sqllin.driver.DatabaseConnection
import com.ctrip.sqllin.dsl.annotation.AdvancedInsertAPI
import com.ctrip.sqllin.dsl.annotation.ExperimentalDSLDatabaseAPI
import com.ctrip.sqllin.dsl.annotation.StatementDslMaker
import com.ctrip.sqllin.dsl.sql.Table
import com.ctrip.sqllin.dsl.sql.X
Expand Down Expand Up @@ -544,6 +545,7 @@ public class DatabaseScope internal constructor(
* PersonTable.CREATE()
* ```
*/
@ExperimentalDSLDatabaseAPI
@StatementDslMaker
public infix fun <T> CREATE(table: Table<T>) {
val statement = Create.create(table, databaseConnection)
Expand All @@ -553,6 +555,7 @@ public class DatabaseScope internal constructor(
/**
* Creates this table from its definition (extension function variant).
*/
@ExperimentalDSLDatabaseAPI
@StatementDslMaker
@JvmName("create")
public fun <T> Table<T>.CREATE(): Unit = CREATE(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.annotation

/**
* Marks declarations that are **experimental** in SQLlin DSL database API.
*
* This annotation indicates that the API is still being refined and may undergo changes
* in future releases. These APIs include experimental features that provide additional
* functionality but may not be as stable as the core APIs.
*
* Any usage of a declaration annotated with `@ExperimentalDSLDatabaseAPI` must be accepted either by
* annotating that usage with the [OptIn] annotation, e.g. `@OptIn(ExperimentalDSLDatabaseAPI::class)`,
* or by using the compiler argument `-opt-in=com.ctrip.sqllin.dsl.annotation.ExperimentalDSLDatabaseAPI`.
*
* @see OptIn
* @see RequiresOptIn
*/
@RequiresOptIn(
message = "This is an experimental API for SQLlin DSL database operations. " +
"It may be changed or removed in future releases. " +
"Use with caution and be prepared for potential breaking changes.",
level = RequiresOptIn.Level.WARNING
)
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY,
AnnotationTarget.TYPEALIAS
)
@Retention(AnnotationRetention.BINARY)
public annotation class ExperimentalDSLDatabaseAPI
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ internal object Create : Operation {
append(',')
}
}
table.primaryKeyInfo?.compositePrimaryKeys?.let {
table.primaryKeyInfo?.compositePrimaryKeys?.takeIf { it.isNotEmpty() }?.let {
append(", PRIMARY KEY (")
if (it.isEmpty())
return@let
append(it[0])
for (i in 1 ..< it.size) {
append(',')
Expand Down
Loading