From bfbc5e386390f0a44413c16603335f6a3ac33477 Mon Sep 17 00:00:00 2001 From: qiaoyuang Date: Tue, 7 Nov 2023 19:56:19 +0800 Subject: [PATCH] Fix the bug for sqllin-procrssor; Update version to 1.2.2 --- CHANGELOG.md | 3 ++- gradle.properties | 2 +- sqllin-dsl/doc/getting-start-cn.md | 2 +- sqllin-dsl/doc/getting-start.md | 2 +- .../com/ctrip/sqllin/dsl/AndroidTest.kt | 3 +++ .../com/ctrip/sqllin/dsl/CommonBasicTest.kt | 20 +++++++++++++++++ .../sqllin/dsl/TestPrimitiveTypeForKSP.kt | 22 +++++++++++++++++++ .../kotlin/com/ctrip/sqllin/dsl/JvmTest.kt | 5 ++++- .../kotlin/com/ctrip/sqllin/dsl/NativeTest.kt | 3 +++ .../ctrip/sqllin/processor/ClauseProcessor.kt | 16 +++++++------- 10 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 546e3ea..6f9596b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ - Date format: YYYY-MM-dd -## v1.2.2 / 2023-xx-xx +## v1.2.2 / 2023-11-08 ### All @@ -22,6 +22,7 @@ ### sqllin-processor * Update `KSP`'s version to `1.9.20-1.0.13` +* Fix the bug for when the code that is generated by `sqllin-processor` can't be compiled([#58](https://github.com/ctripcorp/SQLlin/pull/58)) ## v1.2.1 / 2023-10-18 diff --git a/gradle.properties b/gradle.properties index cd1a8ff..f83be9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION=1.2.1 +VERSION=1.2.2 GROUP=com.ctrip.kotlin kotlinVersion=1.9.20 diff --git a/sqllin-dsl/doc/getting-start-cn.md b/sqllin-dsl/doc/getting-start-cn.md index 8a3673c..b82cef9 100644 --- a/sqllin-dsl/doc/getting-start-cn.md +++ b/sqllin-dsl/doc/getting-start-cn.md @@ -14,7 +14,7 @@ plugins { id("com.google.devtools.ksp") } -val sqllinVersion = "1.2.1" +val sqllinVersion = "1.2.2" kotlin { // ...... diff --git a/sqllin-dsl/doc/getting-start.md b/sqllin-dsl/doc/getting-start.md index 0ca7b35..bccfaed 100644 --- a/sqllin-dsl/doc/getting-start.md +++ b/sqllin-dsl/doc/getting-start.md @@ -16,7 +16,7 @@ plugins { id("com.google.devtools.ksp") } -val sqllinVersion = "1.2.1" +val sqllinVersion = "1.2.2" kotlin { // ...... diff --git a/sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt b/sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt index ff61651..a5ec336 100644 --- a/sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt +++ b/sqllin-dsl/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/dsl/AndroidTest.kt @@ -71,6 +71,9 @@ class AndroidTest { @Test fun testConcurrency() = commonTest.testConcurrency() + @Test + fun testPrimitiveTypeForKSP() = commonTest.testPrimitiveTypeForKSP() + @Before fun setUp() { val context = InstrumentationRegistry.getInstrumentation().targetContext diff --git a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt b/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt index 7679623..5fbd036 100644 --- a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt +++ b/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt @@ -384,6 +384,26 @@ class CommonBasicTest(private val path: DatabasePath) { Unit } + fun testPrimitiveTypeForKSP() { + TestPrimitiveTypeForKSPTable { + SET { + assertEquals(0, testInt) + assertEquals(0L, testLong) + assertEquals(0, testShort) + assertEquals(0, testByte) + assertEquals(0F, testFloat) + assertEquals(0.0, testDouble) + assertEquals(0U, testUInt) + assertEquals(0UL, testULong) + assertEquals(0U, testUShort) + assertEquals(0U, testUByte) + assertEquals(false, testBoolean) + assertEquals('0', testChar) + assertEquals("", testString) + } + } + } + private fun getDefaultDBConfig(): DatabaseConfiguration = DatabaseConfiguration( name = DATABASE_NAME, diff --git a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt b/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt new file mode 100644 index 0000000..154f405 --- /dev/null +++ b/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt @@ -0,0 +1,22 @@ +package com.ctrip.sqllin.dsl + +import com.ctrip.sqllin.dsl.annotation.DBRow +import kotlinx.serialization.Serializable + +@DBRow +@Serializable +data class TestPrimitiveTypeForKSP( + val testInt: Int, + val testLong: Long, + val testShort: Short, + val testByte: Byte, + val testFloat: Float, + val testDouble: Double, + val testUInt: UInt, + val testULong: ULong, + val testUShort: UShort, + val testUByte: UByte, + val testBoolean: Boolean, + val testChar: Char, + val testString: String, +) \ No newline at end of file diff --git a/sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt b/sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt index bf3f9da..803bc0a 100644 --- a/sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt +++ b/sqllin-dsl/src/jvmTest/kotlin/com/ctrip/sqllin/dsl/JvmTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Ctrip.com. + * Copyright (C) 2023 Ctrip.com. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +62,9 @@ class JvmTest { @Test fun testJoinClause() = commonTest.testJoinClause() + @Test + fun testPrimitiveTypeForKSP() = commonTest.testPrimitiveTypeForKSP() + @BeforeTest fun setUp() { deleteDatabase(path, CommonBasicTest.DATABASE_NAME) diff --git a/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt b/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt index 0d3b82a..bf06a11 100644 --- a/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt +++ b/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt @@ -65,6 +65,9 @@ class NativeTest { @Test fun testConcurrency() = commonTest.testConcurrency() + @Test + fun testPrimitiveTypeForKSP() = commonTest.testPrimitiveTypeForKSP() + @BeforeTest fun setUp() { deleteDatabase(path, CommonBasicTest.DATABASE_NAME) 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 5a10d85..addb65f 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 @@ -129,15 +129,15 @@ class ClauseProcessor( property.typeName ) { Int::class.qualifiedName -> "0" - Long::class.qualifiedName -> "0l" - Short::class.qualifiedName -> "0s" - Byte::class.qualifiedName -> "0b" - Float::class.qualifiedName -> "0f" + Long::class.qualifiedName -> "0L" + Short::class.qualifiedName -> "0" + Byte::class.qualifiedName -> "0" + Float::class.qualifiedName -> "0F" Double::class.qualifiedName -> "0.0" - UInt::class.qualifiedName -> "0u" - ULong::class.qualifiedName -> "0ul" - UShort::class.qualifiedName -> "0us" - UByte::class.qualifiedName -> "0ub" + UInt::class.qualifiedName -> "0U" + ULong::class.qualifiedName -> "0UL" + UShort::class.qualifiedName -> "0U" + UByte::class.qualifiedName -> "0U" Boolean::class.qualifiedName -> "false" Char::class.qualifiedName -> "'0'"