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
4 changes: 3 additions & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ jobs:
sudo dpkg -i libicu71_71.1-3ubuntu1_amd64.deb
rm libicu71_71.1-3ubuntu1_amd64.deb
- name: Run tests
run: ./gradlew check
# Only run linuxX64Test for now, JVM tests are crashing on Linux
# https://www.couchbase.com/forums/t/java-sdk-native-crash-on-linux/41006
run: ./gradlew linuxX64Test #./gradlew check
- name: Upload test results
uses: actions/upload-artifact@v4
if: failure()
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ standalone client database, or paired with [Couchbase Server](https://www.couchb
Gateway](https://www.couchbase.com/products/sync-gateway/) or [Capella App Services](
https://www.couchbase.com/products/capella/app-services/) for cloud to edge data synchronization. Features include:

* [SQL++](https://www.couchbase.com/products/n1ql/), key/value, and full-text search queries
* [SQL++](https://www.couchbase.com/products/n1ql/), key/value, full-text search, and vector search queries
* Observable queries, documents, databases, and replicators
* Binary document attachments (blobs)
* Peer-to-peer and cloud-to-edge data sync

Kotbase provides full Enterprise and Community Edition API support for Android and JVM ([via Java SDK](
https://github.com/couchbase/couchbase-lite-java-ce-root)), native iOS and macOS ([via Objective-C SDK](
https://github.com/couchbase/couchbase-lite-ios)), and experimental support for available APIs in native Linux and
Windows ([via C SDK](https://github.com/couchbase/couchbase-lite-C)).
https://github.com/couchbase/couchbase-lite-ios)), and experimental support for native Linux and Windows ([via C SDK](
https://github.com/couchbase/couchbase-lite-C)).

## Installation

Expand Down Expand Up @@ -89,8 +89,7 @@ as straightforward as changing the import package from `com.couchbase.lite` to `

* Java callback functional interfaces are implemented as Kotlin function types.
* `File`, `URL`, and `URI` APIs are represented as strings.
* `Date` APIs use [kotlinx-datetime's `Instant`](
https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/-instant/).
* `Date` APIs use Kotlin's `Instant`.
* `InputStream` APIs use [kotlinx-io's `Source`](
https://kotlinlang.org/api/kotlinx-io/kotlinx-io-core/kotlinx.io/-source/).
* `Executor` APIs use Kotlin's `CoroutineContext`.
Expand All @@ -106,6 +105,8 @@ https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/-i
https://docs.couchbase.com/mobile/3.1.10/couchbase-lite-swift/Classes/Fragment.html), [Objective-C](
https://docs.couchbase.com/mobile/3.1.10/couchbase-lite-objc/Protocols/CBLFragment.html), and [.NET](
https://docs.couchbase.com/mobile/3.1.10/couchbase-lite-net/api/Couchbase.Lite.IFragment.html).
* Configuration factory APIs from the Android KTX SDK have been deprecated in favor of using constructors directly,
which support Kotlin named arguments themselves.

## Extension Libraries

Expand Down Expand Up @@ -169,8 +170,10 @@ implementation("dev.kotbase:couchbase-lite-ee-paging:3.1.11-1.1.2")
* [ ] SwiftUI for Kotbase Notes
* [x] Couchbase Lite [3.1 API](https://docs.couchbase.com/couchbase-lite/3.1/cbl-whatsnew.html) - Scopes and Collections
* [x] Versioned docs
* [ ] Couchbase Lite [3.2 API](https://docs.couchbase.com/couchbase-lite/3.2/cbl-whatsnew.html) - [Vector Search](
* [x] Couchbase Lite [3.2 API](https://docs.couchbase.com/couchbase-lite/3.2/cbl-whatsnew.html) - [Vector Search](
https://www.couchbase.com/products/vector-search/)
* [ ] Couchbase Lite [3.3 API](https://docs.couchbase.com/couchbase-lite/3.3/cbl-whatsnew.html) - Multipeer Replicator
* [ ] URLEndpointListener on Linux & MinGW platforms
* [ ] Improve Swift API alignment with Couchbase Lite using [Swift
export](https://youtrack.jetbrains.com/issue/KT-64572), `@ObjCName`, and/or `@ShouldRefineInSwift`
* [ ] Async coroutines API
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/base-convention.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ kotlin {
optIn("kotlinx.cinterop.BetaInteropApi")
optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
if (name.endsWith("Test")) {
enableLanguageFeature("MultiDollarInterpolation")
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions couchbase-lite-ee/api/couchbase-lite-ee.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -3308,8 +3308,6 @@ open class kotbase/DataSource { // kotbase/DataSource|null[0]

// Targets: [linux, mingwX64]
open class kotbase/Dictionary : kotbase/DictionaryInterface, kotlin.collections/Iterable<kotlin/String> { // kotbase/Dictionary|null[0]
final val release // kotbase/Dictionary.release|{}release[0]
final fun <get-release>(): kotlin/Boolean // kotbase/Dictionary.release.<get-release>|<get-release>(){}[0]
open val count // kotbase/Dictionary.count|{}count[0]
open fun <get-count>(): kotlin/Int // kotbase/Dictionary.count.<get-count>|<get-count>(){}[0]
open val keys // kotbase/Dictionary.keys|{}keys[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ abstract class BaseVectorSearchTest : BaseDbTest() {
val expr = vectorExpression ?: wordsQueryDefaultExpression()

if (metric != null) {
append("ORDER BY APPROX_VECTOR_DISTANCE($expr, \$vector, \"$metric\") ")
append($$"""ORDER BY APPROX_VECTOR_DISTANCE($$expr, $vector, "$$metric") """)
} else {
append("ORDER BY APPROX_VECTOR_DISTANCE($expr, \$vector) ")
append($$"ORDER BY APPROX_VECTOR_DISTANCE($$expr, $vector) ")
}

append("LIMIT $limit")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package kotbase
import kotbase.ext.nowMillis
import kotbase.ext.toStringMillis
import kotbase.test.IgnoreLinuxMingw
import kotbase.test.IgnoreMingw
import kotbase.test.assertIntContentEquals
import kotlin.time.Clock
import kotlin.test.*
Expand Down Expand Up @@ -74,6 +75,8 @@ class PredictiveQueryTest : BaseQueryTest() {
}
}

// TODO: frequently crashes during second query in mingw
@IgnoreMingw
@Test
fun testRegisterMultipleModelsWithSameName() {
createDocument(listOf(1, 2, 3, 4, 5))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ class VectorSearchTestMain : BaseVectorSearchTest() {
createWordsIndex(config)

assertThrowsCBLException(CBLError.Domain.CBLITE, CBLError.Code.INVALID_QUERY) {
executeWordsQuery(limit = 300, whereExpression = "APPROX_VECTOR_DISTANCE(vector, \$vector) < 0.5 OR catid = 'cat1'")
executeWordsQuery(limit = 300, whereExpression = $$"APPROX_VECTOR_DISTANCE(vector, $vector) < 0.5 OR catid = 'cat1'")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ internal fun PredictiveModel.convert(): CValue<CBLPredictiveModel> {
prediction = staticCFunction { ref, input ->
with(ref.to<PredictiveModel>()) {
val output = predict(Dictionary(input!!, null, release = false))
// output FLDict should not be released by the Dictionary object
FLDict_Retain(output?.actual)
output?.actual
output?.actual?.also {
if (output.release) {
// output FLDict should not be released by the Dictionary object
FLDict_Retain(it)
}
}
}
}
unregistered = staticCFunction { ref ->
Expand Down
2 changes: 0 additions & 2 deletions couchbase-lite/api/couchbase-lite.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -2754,8 +2754,6 @@ open class kotbase/DataSource { // kotbase/DataSource|null[0]

// Targets: [linux, mingwX64]
open class kotbase/Dictionary : kotbase/DictionaryInterface, kotlin.collections/Iterable<kotlin/String> { // kotbase/Dictionary|null[0]
final val release // kotbase/Dictionary.release|{}release[0]
final fun <get-release>(): kotlin/Boolean // kotbase/Dictionary.release.<get-release>|<get-release>(){}[0]
open val count // kotbase/Dictionary.count|{}count[0]
open fun <get-count>(): kotlin/Int // kotbase/Dictionary.count.<get-count>|<get-count>(){}[0]
open val keys // kotbase/Dictionary.keys|{}keys[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class LegacyLogTest : BaseDbTest(useLegacyLogging = true) {
// @Test
// fun testFileLoggingLogFilename() {
// testWithConfiguration(LogLevel.DEBUG, LogFileConfiguration(scratchDirPath!!)) {
// Log.e(LogDomain.DATABASE, "$$\$TEST MESSAGE")
// Log.e(LogDomain.DATABASE, $$$$"$$$TEST MESSAGE")
//
// val files = logFiles
// assertTrue(files.size >= 4)
Expand Down
27 changes: 15 additions & 12 deletions couchbase-lite/src/commonTest/kotlin/kotbase/ParameterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ class ParameterTest : BaseDbTest() {
val params = Parameters()
params.setString("param", "value")

val query = testDatabase.createQuery(
"SELECT meta().id"
+ " FROM _default._default"
+ " WHERE test = \$param"
val query = testDatabase.createQuery($$"""
SELECT meta().id
FROM _default._default
WHERE test = $param
""".trimIndent()
)

query.parameters = params
Expand All @@ -47,10 +48,11 @@ class ParameterTest : BaseDbTest() {
val params = Parameters()
params.setString("param", "value")

val query = testDatabase.createQuery(
"SELECT meta().id"
+ " FROM _default._default"
+ " WHERE test = \$param"
val query = testDatabase.createQuery($$"""
SELECT meta().id
FROM _default._default
WHERE test = $param
""".trimIndent()
)

query.parameters = params
Expand All @@ -63,10 +65,11 @@ class ParameterTest : BaseDbTest() {
fun testParamContents() {
val params = makeParams()

val query = testDatabase.createQuery(
"SELECT meta().id"
+ " FROM _default._default"
+ " WHERE test = \$param"
val query = testDatabase.createQuery($$"""
SELECT meta().id
FROM _default._default
WHERE test = $param
""".trimIndent()
)

query.parameters = params
Expand Down
26 changes: 13 additions & 13 deletions couchbase-lite/src/commonTest/kotlin/kotbase/QueryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3141,36 +3141,36 @@ class QueryTest : BaseQueryTest() {
@Test
fun testQueryDocumentWithDollarSign() {
saveDocInCollection(MutableDocument()
.setString("\$type", "book")
.setString("\$description", "about cats")
.setString("\$price", "$100")
.setString($$"$type", "book")
.setString($$"$description", "about cats")
.setString($$"$price", "$100")
)
saveDocInCollection(MutableDocument()
.setString("\$type", "book")
.setString("\$description", "about dogs")
.setString("\$price", "$95")
.setString($$"$type", "book")
.setString($$"$description", "about dogs")
.setString($$"$price", "$95")
)
saveDocInCollection(MutableDocument()
.setString("\$type", "animal")
.setString("\$description", "puppy")
.setString("\$price", "$195")
.setString($$"$type", "animal")
.setString($$"$description", "puppy")
.setString($$"$price", "$195")
)

var cheapBooks = 0
var books = 0

val q = QueryBuilder.select(
SelectResult.expression(Meta.id),
SelectResult.expression(Expression.property("\$type")),
SelectResult.expression(Expression.property("\$price"))
SelectResult.expression(Expression.property($$"$type")),
SelectResult.expression(Expression.property($$"$price"))
)
.from(DataSource.collection(testCollection))
.where(Expression.property("\$type").equalTo(Expression.string("book")))
.where(Expression.property($$"$type").equalTo(Expression.string("book")))

q.execute().use { res ->
for (r in res) {
books++
val p = r.getString("\$price")!!
val p = r.getString($$"$price")!!
if (p.substring(1).toInt() < 100) { cheapBooks++ }
}
assertEquals(2, books)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal constructor(
internal val actual: FLDict
get() = memory.actual

protected val release: Boolean
internal val release: Boolean
get() = memory.release

internal open var dbContext: DbContext? = dbContext
Expand Down
Loading