Skip to content

Commit 17536c8

Browse files
authored
Merge pull request #83 from qiaoyuang/main
Some optimization
2 parents 6da726a + 8ecac3a commit 17536c8

File tree

15 files changed

+67
-53
lines changed

15 files changed

+67
-53
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ jobs:
7373
path: |
7474
~/.android/avd/*
7575
~/.android/adb*
76-
key: avd-33
76+
key: avd-34
7777

7878
- name: Create AVD and Generate Snapshot for Caching
7979
if: steps.avd-cache.outputs.cache-hit != 'true'
8080
uses: reactivecircus/android-emulator-runner@v2
8181
with:
82-
api-level: 33
82+
api-level: 34
8383
target: google_apis
8484
arch: x86_64
8585
profile: pixel_6
@@ -88,10 +88,10 @@ jobs:
8888
disable-animations: false
8989
script: echo "Generated AVD snapshot for caching."
9090

91-
- name: Run Android 13 Instrumented Tests
91+
- name: Run Android 14 Instrumented Tests
9292
uses: reactivecircus/android-emulator-runner@v2
9393
with:
94-
api-level: 33
94+
api-level: 34
9595
target: google_apis
9696
arch: x86_64
9797
profile: pixel_6

.github/workflows/publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ jobs:
6868
path: |
6969
~/.android/avd/*
7070
~/.android/adb*
71-
key: avd-33
71+
key: avd-34
7272

7373
- name: Create AVD and Generate Snapshot for Caching
7474
if: steps.avd-cache.outputs.cache-hit != 'true'
7575
uses: reactivecircus/android-emulator-runner@v2
7676
with:
77-
api-level: 33
77+
api-level: 34
7878
target: google_apis
7979
arch: x86_64
8080
profile: pixel_6
@@ -83,10 +83,10 @@ jobs:
8383
disable-animations: false
8484
script: echo "Generated AVD snapshot for caching."
8585

86-
- name: Run Android 13 Instrumented Tests
86+
- name: Run Android 14 Instrumented Tests
8787
uses: reactivecircus/android-emulator-runner@v2
8888
with:
89-
api-level: 33
89+
api-level: 34
9090
target: google_apis
9191
arch: x86_64
9292
profile: pixel_6

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- Date format: YYYY-MM-dd
44

5-
## v1.3.0 / 2024-04-16
5+
## v1.3.0 / 2024-04-21
66

77
### All
88

@@ -13,7 +13,8 @@
1313
* Update `kotlinx.coroutines`'s version to `1.8.0`
1414
* Update `kotlinx.serialization`'s version to `1.6.3`
1515
* Modify the SQL statements' splicing method, that fixed the [issue#77](https://github.com/ctripcorp/SQLlin/issues/77) that users can't read/write special symbols as the values in SQL statements.
16-
* Performance optimization, use `ArrayDeque` to replace the LinkedList for SQL statements management (self-implemented)
16+
* Performance optimization, use `ArrayDeque` to replace the LinkedList for SQL statements management (self-implemented).
17+
* The parameter `enableSimpleSQLLog` of the `Database`'s constructors of is `false` by default.
1718

1819
### sqllin-driver
1920

sample/src/commonMain/kotlin/com/ctrip/sqllin/sample/Sample.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ object Sample {
4949
upgrade = { _, _, _ ->
5050
// You must write SQL to String when the database is created or upgraded
5151
}
52-
)
52+
),
53+
enableSimpleSQLLog = true,
5354
)
5455
}
5556

sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/Database.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ import kotlinx.coroutines.sync.withLock
2929

3030
public class Database(
3131
configuration: DatabaseConfiguration,
32-
private val enableSimpleSQLLog: Boolean = true,
32+
private val enableSimpleSQLLog: Boolean = false,
3333
) {
3434

3535
public constructor(
3636
name: String,
3737
path: DatabasePath,
3838
version: Int,
39-
enableSimpleSQLLog: Boolean = true,
39+
enableSimpleSQLLog: Boolean = false,
4040
) : this(
4141
DatabaseConfiguration(
4242
name = name,

sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/ClauseBoolean.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public class ClauseBoolean(
3737
}
3838
append(valueName)
3939
if (bool)
40-
append(" > ")
40+
append('>')
4141
else
42-
append(" <= ")
42+
append("<=")
4343
append(0)
4444
}
4545
return SelectCondition(sql, null)

sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/ClauseNumber.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ public class ClauseNumber(
106106
append('.')
107107
}
108108
append(valueName)
109-
append(' ')
110109
append(symbol)
111-
append(' ')
112110
append(number)
113111
}
114112
return SelectCondition(sql, null)
@@ -121,10 +119,14 @@ public class ClauseNumber(
121119
append('.')
122120
}
123121
append(valueName)
124-
append(' ')
125-
append(if (number == null) nullSymbol else notNullSymbol)
126-
append(' ')
127-
append(number ?: "NULL")
122+
if (number == null){
123+
append(nullSymbol)
124+
append(" NULL")
125+
126+
} else {
127+
append(notNullSymbol)
128+
append(number)
129+
}
128130
}
129131
return SelectCondition(sql, null)
130132
}
@@ -134,9 +136,7 @@ public class ClauseNumber(
134136
append(table.tableName)
135137
append('.')
136138
append(valueName)
137-
append(' ')
138139
append(symbol)
139-
append(' ')
140140
append(clauseNumber.table.tableName)
141141
append('.')
142142
append(clauseNumber.valueName)

sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/ClauseString.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ public class ClauseString(
5252
append('.')
5353
}
5454
append(valueName)
55-
append(' ')
5655
append(symbol)
57-
append(" ?")
56+
append('?')
5857
}
5958
return SelectCondition(sql, mutableListOf(regex))
6059
}
@@ -66,14 +65,13 @@ public class ClauseString(
6665
append('.')
6766
}
6867
append(valueName)
69-
append(' ')
7068
val isNull = str == null
7169
val symbol = if (isNull) nullSymbol else notNullSymbol
7270
append(symbol)
7371
if (str == null)
7472
append(" NULL")
7573
else
76-
append(" ?")
74+
append('?')
7775
}
7876
return SelectCondition(sql, if (str == null) null else mutableListOf(str))
7977
}

sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/clause/OrderByClause.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ internal class CompleteOrderByClause<T>(private val column2WayMap: Map<ClauseEle
3939
append(' ')
4040
append(way.str)
4141
val hasNext = iterator.hasNext()
42-
val symbol = if (hasNext) ',' else ' '
43-
append(symbol)
42+
if (hasNext)
43+
append(',')
4444
} while (hasNext)
4545
}
4646
}
@@ -99,14 +99,12 @@ internal class SimpleOrderByClause<T>(private val columns: Iterable<ClauseElemen
9999
append(',')
100100
append(iterator.next().valueName)
101101
}
102-
append(' ')
103102
}
104103
}
105104
}
106105
public fun <T> ORDER_BY(vararg elements: ClauseElement): OrderByClause<T> =
107106
SimpleOrderByClause(elements.toList())
108107

109-
@Suppress("NOTHING_TO_INLINE")
110108
public inline infix fun <T> WhereSelectStatement<T>.ORDER_BY(column: ClauseElement): OrderBySelectStatement<T> =
111109
ORDER_BY(listOf(column))
112110

@@ -115,7 +113,6 @@ public infix fun <T> WhereSelectStatement<T>.ORDER_BY(columns: Iterable<ClauseEl
115113
container changeLastStatement it
116114
}
117115

118-
@Suppress("NOTHING_TO_INLINE")
119116
public inline infix fun <T> HavingSelectStatement<T>.ORDER_BY(column: ClauseElement): OrderBySelectStatement<T> =
120117
ORDER_BY(listOf(column))
121118

@@ -124,7 +121,6 @@ public infix fun <T> HavingSelectStatement<T>.ORDER_BY(columns: Iterable<ClauseE
124121
container changeLastStatement it
125122
}
126123

127-
@Suppress("NOTHING_TO_INLINE")
128124
public inline infix fun <T> GroupBySelectStatement<T>.ORDER_BY(column: ClauseElement): OrderBySelectStatement<T> =
129125
ORDER_BY(listOf(column))
130126

@@ -133,7 +129,6 @@ public infix fun <T> GroupBySelectStatement<T>.ORDER_BY(columns: Iterable<Clause
133129
container changeLastStatement it
134130
}
135131

136-
@Suppress("NOTHING_TO_INLINE")
137132
public inline infix fun <T> JoinSelectStatement<T>.ORDER_BY(column: ClauseElement): OrderBySelectStatement<T> =
138133
ORDER_BY(listOf(column))
139134

sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/sql/operation/Select.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal object Select : Operation {
5151
connection: DatabaseConnection,
5252
container: StatementContainer,
5353
): OrderBySelectStatement<T> =
54-
OrderBySelectStatement(buildSQL(table, clause, isDistinct, deserializer), deserializer, connection, container, mutableListOf())
54+
OrderBySelectStatement(buildSQL(table, clause, isDistinct, deserializer), deserializer, connection, container, null)
5555

5656
fun <T> select(
5757
table: Table<T>,

0 commit comments

Comments
 (0)