You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sqllin-driver/README.md
+13-14Lines changed: 13 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,25 +4,24 @@
4
4
5
5
## Design
6
6
7
-
Initially, we need a multiplatform available low-level Kotlin API to call SQLite. Because we think_sqllin-dsl_
8
-
should be platformindependent. So, we need the _sqllin-driver_, and _sqllin-dsl_based on it. Our goal is
7
+
Initially, we needed a multiplatform available low-level Kotlin APIs to call SQLite. Because we thought_sqllin-dsl_
8
+
should be platform-independent. So, we needed _sqllin-driver_, and _sqllin-dsl_ on top of it. Our goal was
9
9
writing the common APIs in Kotlin Multiplatform common source set and they have different implementations on
10
10
different platforms.
11
11
12
-
In Android, not many ways to choose from. If we use the Android Framework SQLite Java APIs, everything will be simple,
13
-
but defect is many SQLite parameters cannot take effect on systems below Android P. If we writing JNI code
12
+
On Android, there are no many ways to choose from. If we use Android Framework SQLite Java APIs, everything will be simple,
13
+
but defect is many SQLite parameters cannot take effect on systems below Android P. If we write JNI code
14
14
to call SQLite C functions by ourselves, above problem will be resolved, but this will lead to a bigger problem:
15
-
In systems above Android N, Google doesn't allow developers call system built-in SQLite C functions in NDK. If
15
+
On systems above Android N, Google doesn't allow developers call system built-in SQLite C functions in NDK. If
16
16
we firmly choose this plan, we have to compile the SQLite source code into _sqllin-driver_, this will complicate
17
-
our project. Finally, we still choose based on Android Framework Java API.
18
-
19
-
In Native platforms, things look different. We can call SQLite C API directly, this is a most intuitive plan.
20
-
The interoperability of Kotlin/Native with C is very perfect, but in Kotlin/Native you must use some APIs that
21
-
very difficult to understanding to interop with C, like: `memScoped`, `CPointer`, `CPointerVarOf`, `toKString`, etc..
22
-
So, at the beginning, I chose the [SQLiter](https://github.com/touchlab/SQLiter), that's a Kotlin/Native multiplatform
23
-
library. If I use it, I can put the Kotlin-C interop translate to Kotlin language-internal calls. It is very
24
-
convenient. [SQLiter](https://github.com/touchlab/SQLiter) also is the driver that
25
-
[SQLDelight](https://github.com/cashapp/sqldelight) to call SQLite C library on native platforms. It is not only
17
+
our project. Finally, we still choose to use Android Framework Java API.
18
+
19
+
On Native platforms, things look different. We can call SQLite C APIs directly, this is a most intuitive plan.
20
+
The interoperability of Kotlin/Native with C is perfect, but in Kotlin/Native you must use some APIs to interop with C
21
+
that very difficult to understand, like: `memScoped`, `CPointer`, `CPointerVarOf`, `toKString`, etc..
22
+
So, at the beginning, I chose the [SQLiter](https://github.com/touchlab/SQLiter), it is a Kotlin/Native multiplatform
23
+
library. If I use it, I can put the Kotlin-C interop translate to Kotlin language-internal calling. It is very
24
+
convenient. [SQLiter](https://github.com/touchlab/SQLiter) also is the driver of [SQLDelight](https://github.com/cashapp/sqldelight) calling SQLite C library on native platforms. It not only
26
25
supports iOS, but also supports all the operating systems of Apple, Linux(x64) and Windows(mingwX86, mingwX64).
27
26
28
27
But a few months later. I found using [SQLiter](https://github.com/touchlab/SQLiter) also has some disadvantages. For
Copy file name to clipboardExpand all lines: sqllin-dsl/doc/advanced-query.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,13 @@
2
2
3
3
中文版请见[这里](advanced-query-cn.md)
4
4
5
-
We have learned basic query and using SQL functions in query condition. Let's learn some query’s advanced skills.
5
+
We have learned basic querying and using SQL functions in querying conditions. Let's learn some advanced skills of querying.
6
6
7
7
## Unions
8
8
9
-
The _UNION_ operator used for merge two _SELECT_ statements' results and these results must be of the same type.
9
+
The _UNION_ operator is used for merge two _SELECT_ statements' results and these results must be of the same type.
10
10
11
-
In SQL, _UNION_ operator between with the two _SELECT_ statements, but in SQLlin, we use a higher-order function to
11
+
In SQL, the _UNION_ operator between with the two _SELECT_ statements, but in SQLlin, we use a higher-order function to
12
12
implement _UNION_:
13
13
14
14
```kotlin
@@ -25,8 +25,8 @@ fun sample() {
25
25
}
26
26
```
27
27
28
-
You just need to write your _SELECT_ statements in `UNION {...}` block. There must be at least two _SELECT_ statements
29
-
inside the `UNION {...}` block, if not, you will get a `IllegalStateException`when runtime.
28
+
You just need to write your _SELECT_ statements in the `UNION {...}` block. There must be at least two _SELECT_ statements
29
+
inside the `UNION {...}` block, if not, you will get a `IllegalStateException`at runtime.
30
30
31
31
If you want to use _UNION_ and _UNION ALL_ interchangeably, just use `UNION {...}` or `UNION_ALL {...}` block nesting:
32
32
@@ -59,7 +59,7 @@ SELECT * FROM person WHERE name = "Tom"
59
59
60
60
## Subqueries
61
61
62
-
SQLlin doesn't yet support subqueries, we will develop as soon as possible.
62
+
SQLlin doesn't support subqueries yet, we will develop as soon as possible.
63
63
64
64
## Join
65
65
@@ -92,7 +92,7 @@ data class CrossJoinStudent(
92
92
)
93
93
```
94
94
95
-
The `Transcript` represents a other table. And the `Student` represents the join query results' type(so `Student`
95
+
The `Transcript` represents an other table. And the `Student` represents the join querying results' type(so `Student`
96
96
doesn't need to be annotated `@DBRow`), it owns all column names that belong to `Person` and `Transcript`.
97
97
98
98
### Cross Join
@@ -111,8 +111,8 @@ The `CROSS_JOIN` function receives one or multiple `Table`s as parameters. In no
111
111
depended on the `Table` that be generated by _sqllin-processor_, but _JOIN_ operator will change it to specific type. In above sample, `CROSS_JOIN` changes
112
112
the type to `CrossJoinStudent`.
113
113
114
-
Note, because of _CROSS JOIN_ owns feature in SQL. If the columns that be queried by _SELECT_ statement that with _CROSS JOIN_ clause include the same
115
-
name column in the two tables, this will causing the query to fail. Because of a class isn't allowed to have multiple properties those have same name, _sqllin-dsl_
114
+
Note, because _CROSS JOIN_ owns feature in SQL. If the columns that be queried by a_SELECT_ statement that with _CROSS JOIN_ clause include the same
115
+
name columns in the two tables, this will cause the querying to fail. Because a class isn't allowed to have multiple properties those have same names, _sqllin-dsl_
116
116
doesn't support the _CROSS JOIN_ with columns of the same name.
117
117
118
118
### Inner Join
@@ -130,15 +130,15 @@ fun joinSample() {
130
130
```
131
131
132
132
The `INNER_JOIN` is similar to `CROSS_JOIN`, the deference is `INNER_JOIN` need to connect a `USING` or `ON` clause. If a _INNER JOIN_ statement
133
-
without the `USING` or `ON` clause, it is incomplete, but your code still be compiled and will do nothing in runtime.
133
+
without the `USING` or `ON` clause, it is incomplete, but your code still be compiled and will do nothing at runtime.
134
134
135
-
The `NATURAL_INNER_JOIN` will produce a complete _SELECT_ statement(the same with `CROSS_JOIN`). So, you can't add `USING` or `ON` clause behind it, this is
135
+
The `NATURAL_INNER_JOIN` will produce a complete _SELECT_ statement (same with `CROSS_JOIN`). So, you can't add a`USING` or `ON` clause behind it, this is
136
136
guaranteed by Kotlin compiler.
137
137
138
-
Note, the behavior of `INNER_JOIN` clause with `ON` clause is same to`CROSS_JOIN`, you can't select the column that has same name in two tables.
138
+
Note, the behavior of a `INNER_JOIN` clause with a `ON` clause is same with`CROSS_JOIN`, you can't select a column that has same name in two tables.
139
139
140
-
The `INNER_JOIN` have an alias that named `JOIN`, and `NATURAL_INNER_JOIN` also have an alias that named `NATURAL_JOIN`. That's liked you can
141
-
bypass the`INNER` keyword in SQL's inner join query.
140
+
The `INNER_JOIN` have an alias that named `JOIN`, and `NATURAL_INNER_JOIN` also have an alias that named `NATURAL_JOIN`. This is just like you can
141
+
bypass a`INNER` keyword in SQL's inner join querying.
142
142
143
143
144
144
### Left Outer Join
@@ -155,8 +155,8 @@ fun joinSample() {
155
155
}
156
156
```
157
157
158
-
The `LEFT_OUTER_JOIN`'s usage is very similar to`INNER_JOIN`, the difference just is their API names.
158
+
The `LEFT_OUTER_JOIN`'s usage is very similar with`INNER_JOIN`, the difference just is their API names.
159
159
160
160
## Finally
161
161
162
-
You have learned all usage with SQLlin, enjoy it and stay concerned about SQLlin's update :)
162
+
You have learned all usages with SQLlin, enjoy it and stay Stay tuned for SQLlin's updates :)
Copy file name to clipboardExpand all lines: sqllin-dsl/doc/getting-start.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
## Installation via Maven with Gradle
8
8
9
-
Add the _sqllin-dsl_, _sqllin-driver_ and _sqllin-processor_ dependencies into your `build.gradle.kts`:
9
+
Add the dependencies of _sqllin-dsl_, _sqllin-driver_ and _sqllin-processor_ into your `build.gradle.kts`:
10
10
11
11
```kotlin
12
12
plugins {
@@ -47,7 +47,7 @@ dependencies {
47
47
}
48
48
```
49
49
50
-
> Note: If you want to add dependiences of SQLlin into your Kotlin/Native exectable program project, sometimes you need to add the `linkerOpts`
50
+
> Note: If you want to add dependencies of SQLlin into your Kotlin/Native executable program projects, sometimes you need to add the `linkerOpts`
51
51
> of SQLite into your `build.gradle.kts` correctly. You can refer to [issue #48](https://github.com/ctripcorp/SQLlin/issues/48) to get more information.
52
52
53
53
## Creating the Database
@@ -61,7 +61,7 @@ val database = Database(name = "Person.db", path = getGlobalPath(), version = 1)
61
61
```
62
62
63
63
The `DatabasePath` is the second parameter `path`'s type, it is represented differently on different platforms.
64
-
In Android, you can get it through [`Context`](https://developer.android.com/reference/android/content/Context), and you can get it through string in native platforms.
64
+
On Android, you can get it through [`Context`](https://developer.android.com/reference/android/content/Context), and you can get it through string on native platforms.
65
65
For example, you can define a expect function in your common source set:
66
66
67
67
```kotlin
@@ -86,7 +86,7 @@ val applicationContext: Context
86
86
}
87
87
```
88
88
89
-
In your iOS source set(similar in other Apple platforms), you can implement it by:
89
+
In your iOS source set(similar with other Apple platforms), you can implement it by:
90
90
91
91
```kotlin
92
92
importcom.ctrip.sqllin.driver.DatabasePath
@@ -100,7 +100,7 @@ actual fun getGlobalDatabasePath(): DatabasePath =
100
100
101
101
```
102
102
103
-
You can config more SQLite arguments when you creating the `Database` instance:
103
+
You can config more SQLite arguments when you create the `Database` instance:
Note, because of limitation by Android Framework, the `inMemory`, `busyTimeout`, `lookasideSlotSize`, `lookasideSlotCount`
130
-
only work on Android 9 and higher. And, because of [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc)(SQLlin base on it on JVM) doesn't support
130
+
only work on Android 9 and higher. And, because [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc)(SQLlin is based on it on JVM) doesn't support
131
131
`sqlite3_config()`, the `lookasideSlotSize` and `lookasideSlotCount` don't work on JVM target.
132
132
133
-
Now, the operations that change database structure have not supported by DSL yet. So, you need to write these SQL statements by string
133
+
Now, the operations that change database structure haven't been supported by DSL yet. So, you need to write these SQL statements by string
134
134
as in `create` and `upgrade` parameters.
135
135
136
136
Usually, you just need to create one `Database` instance in your component lifecycle. So, you need to close database manually when the lifecycle ended:
@@ -143,7 +143,7 @@ override fun onDestroy() {
143
143
144
144
## Defining Your database entity
145
145
146
-
In _sqllin-dsl_, you can insert and query objects directly. So, you need to use the correct way to define your data class. For example:
146
+
In _sqllin-dsl_, you can insert and query objects directly. So, you need to use the correct way to define your data classes. For example:
147
147
148
148
```kotlin
149
149
importcom.ctrip.sqllin.dsl.annotation.DBRow
@@ -157,14 +157,14 @@ data class Person(
157
157
)
158
158
```
159
159
160
-
Your database entity's property names should same with the database table's column names. The database entity cannot have properties with names different from all
161
-
column names in the table. But the count of your database entity's properties can less than the count of columns.
160
+
Your database entities' property names should be same with the database table's column names. The database entities cannot have properties with names different from all
161
+
column names in the table. But the count of your database entities' properties can less than the count of columns.
162
162
163
163
The `@DBRow`'s param `tableName` represents the table name in Database, please ensure pass
164
164
the correct value. If you don't pass the parameter manually, _sqllin-processor_ will use the class
165
165
name as table name, for example, `Person`'s default table name is "Person".
166
166
167
-
In _sqllin-dsl_, objects serialization to SQL and deserialization from cursor depend on _kotlinx.serialization_. So, you also need to add the `@Serializable` onto your data class.
167
+
In _sqllin-dsl_, objects are serialized to SQL and deserialized from cursor depend on _kotlinx.serialization_. So, you also need to add the `@Serializable` onto your data classes.
0 commit comments