Skip to content

Commit

Permalink
Merge pull request #102 from qiaoyuang/main
Browse files Browse the repository at this point in the history
Update version to 1.4.1
  • Loading branch information
qiaoyuang authored Feb 5, 2025
2 parents 8c5f2e7 + 67679b3 commit 24217ed
Show file tree
Hide file tree
Showing 22 changed files with 198 additions and 16 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

- Date format: YYYY-MM-dd

## v1.4.1 / 2025-02-04

### All

* Update `Kotlin`'s version to `2.1.10`

### sqllin-dsl

* Update `kotlinx.coroutines`'s version to `1.10.1`
* Update `kotlinx.serialization`'s version to `1.8.0`
* Add some DslMaker annotations, make the DSL apis be more readable

### sqllin-driver

* Update the `sqlite-jdbc`'s version to `3.48.0.0`

### sqllin-processor

* Update `KSP`'s version to `2.1.10-1.0.29`

## v1.4.0 / 2024-12-04

### All
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=1.4.0
VERSION=1.4.1
GROUP=com.ctrip.kotlin

#Maven Publish Information
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[versions]

kotlin = "2.1.0"
kotlin = "2.1.10"
agp = "8.7.3"
ksp = "2.1.0-1.0.29"
serialization = "1.7.3"
coroutines = "1.9.0"
ksp = "2.1.10-1.0.29"
serialization = "1.8.0"
coroutines = "1.10.1"
androidx-annotation = "1.9.1"
androidx-test = "1.6.1"
androidx-test-runner = "1.6.2"
sqlite-jdbc = "3.47.1.0"
sqlite-jdbc = "3.48.0.0"

[libraries]

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Mar 08 15:11:46 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
6 changes: 3 additions & 3 deletions sqllin-dsl/doc/getting-start-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
id("com.google.devtools.ksp")
}

val sqllinVersion = "1.4.0"
val sqllinVersion = "1.4.1"

kotlin {
// ......
Expand All @@ -28,10 +28,10 @@ kotlin {
implementation("com.ctrip.kotlin:sqllin-driver:$sqllinVersion")

// The sqllin-dsl serialization and deserialization depends on kotlinx-serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.8.0")

// Since 1.2.2, sqllin-dsl depends on kotlinx.coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
}
}
// ......
Expand Down
6 changes: 3 additions & 3 deletions sqllin-dsl/doc/getting-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
id("com.google.devtools.ksp")
}

val sqllinVersion = "1.4.0"
val sqllinVersion = "1.4.1"

kotlin {
// ......
Expand All @@ -30,10 +30,10 @@ kotlin {
implementation("com.ctrip.kotlin:sqllin-driver:$sqllinVersion")

// The sqllin-dsl serialization and deserialization depends on kotlinx-serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.8.0")

// Since 1.2.2, sqllin-dsl depends on kotlinx.coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
}
}
// ......
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.ctrip.sqllin.dsl

import com.ctrip.sqllin.driver.DatabaseConnection
import com.ctrip.sqllin.dsl.annotation.StatementDslMaker
import com.ctrip.sqllin.dsl.sql.Table
import com.ctrip.sqllin.dsl.sql.X
import com.ctrip.sqllin.dsl.sql.clause.*
Expand Down Expand Up @@ -98,18 +99,21 @@ public class DatabaseScope internal constructor(
* Insert.
*/

@StatementDslMaker
public infix fun <T> Table<T>.INSERT(entities: Iterable<T>) {
val statement = Insert.insert(this, databaseConnection, entities)
addStatement(statement)
}

@StatementDslMaker
public infix fun <T> Table<T>.INSERT(entity: T): Unit =
INSERT(listOf(entity))

/**
* Update.
*/

@StatementDslMaker
public infix fun <T> Table<T>.UPDATE(clause: SetClause<T>): UpdateStatementWithoutWhereClause<T> =
transactionStatementsGroup?.let {
val statement = Update.update(this, databaseConnection, it, clause)
Expand All @@ -123,11 +127,13 @@ public class DatabaseScope internal constructor(
* Delete.
*/

@StatementDslMaker
public infix fun Table<*>.DELETE(x: X) {
val statement = Delete.deleteAllEntities(this, databaseConnection)
addStatement(statement)
}

@StatementDslMaker
public infix fun <T> Table<T>.DELETE(clause: WhereClause<T>) {
val statement = Delete.delete(this, databaseConnection, clause)
addStatement(statement)
Expand All @@ -140,12 +146,16 @@ public class DatabaseScope internal constructor(
/**
* Select with no any clause.
*/

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT(x: X): FinalSelectStatement<T> =
select(kSerializer(), false)

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT_DISTINCT(x: X): FinalSelectStatement<T> =
select(kSerializer(), true)

@StatementDslMaker
public fun <T> Table<T>.select(serializer: KSerializer<T>, isDistinct: Boolean): FinalSelectStatement<T> {
val container = getSelectStatementGroup()
val statement = Select.select(this, isDistinct, serializer, databaseConnection, container)
Expand All @@ -156,9 +166,12 @@ public class DatabaseScope internal constructor(
/**
* Receive the 'WHERE' clause.
*/

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT(clause: WhereClause<T>): WhereSelectStatement<T> =
select(kSerializer(), clause, false)

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT_DISTINCT(clause: WhereClause<T>): WhereSelectStatement<T> =
select(kSerializer(), clause, true)

Expand All @@ -172,9 +185,12 @@ public class DatabaseScope internal constructor(
/**
* Receive the 'ORDER BY' clause.
*/

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT(clause: OrderByClause<T>): OrderBySelectStatement<T> =
select(kSerializer(), clause, false)

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT_DISTINCT(clause: OrderByClause<T>): OrderBySelectStatement<T> =
select(kSerializer(), clause, true)

Expand All @@ -188,9 +204,12 @@ public class DatabaseScope internal constructor(
/**
* Receive the 'LIMIT' clause.
*/

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT(clause: LimitClause<T>): LimitSelectStatement<T> =
select(kSerializer(), clause, false)

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT_DISTINCT(clause: LimitClause<T>): LimitSelectStatement<T> =
select(kSerializer(), clause, true)

Expand All @@ -204,9 +223,12 @@ public class DatabaseScope internal constructor(
/**
* Receive the 'GROUP BY' clause.
*/

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT(clause: GroupByClause<T>): GroupBySelectStatement<T> =
select(kSerializer(), clause, false)

@StatementDslMaker
public inline infix fun <reified T> Table<T>.SELECT_DISTINCT(clause: GroupByClause<T>): GroupBySelectStatement<T> =
select(kSerializer(), clause, true)

Expand Down Expand Up @@ -239,6 +261,7 @@ public class DatabaseScope internal constructor(
}
}

@StatementDslMaker
public inline fun <T> Table<T>.UNION_ALL(block: Table<T>.(Table<T>) -> Unit): FinalSelectStatement<T> {
beginUnion<T>()
var selectStatement: SelectStatement<T>? = null
Expand Down Expand Up @@ -269,9 +292,11 @@ public class DatabaseScope internal constructor(
* Receive the 'JOIN' clause.
*/

@StatementDslMaker
public inline infix fun <T, reified R> Table<T>.SELECT(clause: JoinClause<R>): JoinStatementWithoutCondition<R> =
select(getKSerializer(), clause, false)

@StatementDslMaker
public inline infix fun <T, reified R> Table<T>.SELECT_DISTINCT(clause: JoinClause<R>): JoinStatementWithoutCondition<R> =
select(getKSerializer(), clause, true)

Expand All @@ -284,9 +309,11 @@ public class DatabaseScope internal constructor(
* Receive the natural join clause(includes 'NATURAL LEFT OUTER JOIN' and 'NATURAL INNER JOIN').
*/

@StatementDslMaker
public inline infix fun <T, reified R> Table<T>.SELECT(clause: NaturalJoinClause<R>): JoinSelectStatement<R> =
select(getKSerializer(), clause, false)

@StatementDslMaker
public inline infix fun <T, reified R> Table<T>.SELECT_DISTINCT(clause: NaturalJoinClause<R>): JoinSelectStatement<R> =
select(getKSerializer(), clause, true)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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

/**
* Dsl maker annotations
* @author yaqiao
*/

@DslMarker
public annotation class StatementDslMaker

@DslMarker
public annotation class KeyWordDslMaker

@DslMarker
public annotation class FunctionDslMaker

@DslMarker
public annotation class ColumnNameDslMaker
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

package com.ctrip.sqllin.dsl.sql

import com.ctrip.sqllin.dsl.annotation.KeyWordDslMaker

/**
* Express "*" in SQL
* @author yaqiao
*/

@KeyWordDslMaker
public expect object X
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.ctrip.sqllin.dsl.sql.clause

import com.ctrip.sqllin.dsl.annotation.StatementDslMaker
import com.ctrip.sqllin.dsl.sql.Table
import com.ctrip.sqllin.dsl.sql.statement.JoinSelectStatement
import com.ctrip.sqllin.dsl.sql.statement.JoinStatementWithoutCondition
Expand Down Expand Up @@ -44,11 +45,14 @@ public sealed class NaturalJoinClause<R>(vararg tables: Table<*>) : BaseJoinClau

public sealed class JoinClause<R>(vararg tables: Table<*>) : BaseJoinClause<R>(*tables)

@StatementDslMaker
public infix fun <R> JoinStatementWithoutCondition<R>.ON(condition: SelectCondition): JoinSelectStatement<R> =
convertToJoinSelectStatement(condition)

@StatementDslMaker
public inline infix fun <R> JoinStatementWithoutCondition<R>.USING(clauseElement: ClauseElement): JoinSelectStatement<R> =
USING(listOf(clauseElement))

@StatementDslMaker
public infix fun <R> JoinStatementWithoutCondition<R>.USING(clauseElements: Iterable<ClauseElement>): JoinSelectStatement<R> =
convertToJoinSelectStatement(clauseElements)
Loading

0 comments on commit 24217ed

Please sign in to comment.