Skip to content

Commit

Permalink
fix #220 & #222
Browse files Browse the repository at this point in the history
  • Loading branch information
anidotnet committed Jun 2, 2020
1 parent 36aa3a6 commit 520b4c5
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ deploy:

env:
global:
- NITRITE_VERSION=3.5.0-SNAPSHOT
- NITRITE_VERSION=3.4.2
- PGP_KEY_FILE=~/secring.gpg
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
org.gradle.jvmargs=-Xmx1024m

# artifact version
nitriteVersion=3.5.0-SNAPSHOT
nitriteVersion=3.4.2

# nitrite dependency
asciidoctorVersion=1.5.6
Expand Down
4 changes: 2 additions & 2 deletions nitrite/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Nitrite
Anindya Chatterjee <anindya@dizitart.com>
v3.5.0, {docdate} {doctime}
v3.4.2, {docdate} {doctime}
:description: Nitrite database is an open source Nosql embedded persistent document store written in Java. It has MongoDB like API. It supports both in-memory and single file based persistent store powered by MVStore engine of h2 database. Nitrite can be used in desktop as well as mobile applications like android.
:keywords: nitrite, nosql, embedded, embedded document store, android, android nosql database, java, key value store, document store, object store, persistent store, index, indexing, fulltext search, embedded mongo,
:page-layout: docs
Expand All @@ -12,7 +12,7 @@ v3.5.0, {docdate} {doctime}
:toclevels: 4
:title-logo-image: image:images/nitrite-logo.svg[pdfwidth=4.25in,align=center]
:homepage: http://nitrite.dizitart.org
:version: 3.5.0
:version: 3.4.2
:source-highlighter: pygments
:pygments-style: tango
:linkattrs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void refreshIndexEntry(Document oldDocument, Document newDocument, NitriteId nit

if (indexType == IndexType.Fulltext && newValue instanceof String) {
// update text index
textIndexingService.deleteIndex(nitriteId, field, (String) oldValue);
textIndexingService.updateIndex(nitriteId, field, (String) newValue);
} else {
NitriteMap<Comparable, ConcurrentSkipListSet<NitriteId>> indexMap
Expand Down
12 changes: 6 additions & 6 deletions nitrite/src/main/java/org/dizitart/no2/util/ObjectUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ public static ObjectFilter createUniqueFilter(Object object, Field idField) {
public static boolean isObjectStore(String collectionName) {
try {
if (isNullOrEmpty(collectionName)) return false;
Class clazz = Class.forName(collectionName);
return clazz != null;
} catch (ClassNotFoundException e) {
Class.forName(collectionName);
return true;
} catch (ClassNotFoundException | NoClassDefFoundError e) {
return isKeyedObjectStore(collectionName);
}
}
Expand All @@ -209,9 +209,9 @@ public static boolean isKeyedObjectStore(String collectionName) {
return false;
}
String storeName = split[0];
Class clazz = Class.forName(storeName);
return clazz != null;
} catch (ClassNotFoundException e) {
Class.forName(storeName);
return true;
} catch (ClassNotFoundException | NoClassDefFoundError e) {
return false;
}
}
Expand Down
22 changes: 22 additions & 0 deletions nitrite/src/test/java/org/dizitart/no2/NitriteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,28 @@ public void testIssue212() {
}
}

@Test
public void testIssue220() {
NitriteCollection collection = db.getCollection("object");
collection.drop();
collection = db.getCollection("object");
Document doc1 = createDocument("key", "key").put("second_key", "second_key").put("third_key", "third_key");
Document doc2 = createDocument("key", "key").put("second_key", "second_key").put("fourth_key", "fourth_key");
Document doc = createDocument("fifth_key", "fifth_key");

collection.insert(doc1, doc2, doc);
db.close();

db = new NitriteBuilder()
.filePath(fileName)
.compressed()
.openOrCreate("test-user", "test-password");
collection = db.getCollection("object");
Cursor documents = collection.find(Filters.eq("fifth_key", "fifth_key"));
assertEquals(1, documents.size());
assertEquals(doc, documents.firstOrDefault());
}


@Data
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.dizitart.kno2

import org.dizitart.no2.IndexOptions
import org.dizitart.no2.IndexType
import org.dizitart.no2.NullOrder
import org.dizitart.no2.SortOrder
Expand All @@ -26,6 +27,7 @@ import org.dizitart.no2.objects.Id
import org.dizitart.no2.objects.Index
import org.dizitart.no2.objects.Indices
import org.dizitart.no2.objects.InheritIndices
import org.dizitart.no2.objects.filters.ObjectFilters
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
Expand Down Expand Up @@ -161,6 +163,26 @@ class NitriteTest : BaseTest() {
repository.insert(ClassWithLocalDateTime("test", LocalDateTime.now()))
assertNotNull(repository.find())
}

@Test
fun testIssue222() {
val first = NestedObjects("value1", "1", listOf(TempObject("name-1", 42,LevelUnder("street", 12))))
val repository = db?.getRepository<NestedObjects>()!!
repository.insert(first)

repository.createIndex("ob1", IndexOptions.indexOptions(IndexType.Fulltext));
var found = repository.find(ObjectFilters.text("ob1", "value1"))
assertTrue(found.idSet().isNotEmpty())

first.ob1 = "value2"
repository.update(first)

found = repository.find(ObjectFilters.text("ob1", "value2"))
assertTrue(found.idSet().isNotEmpty())

found = repository.find(ObjectFilters.text("ob1", "value1"))
assertTrue(found.idSet().isEmpty())
}
}

interface MyInterface {
Expand Down Expand Up @@ -198,4 +220,9 @@ data class CaObject(
data class ClassWithLocalDateTime (
val name: String,
val time: LocalDateTime
)
)

data class NestedObjects(var ob1:String, @Id val id: String, val list: List<TempObject>)

data class TempObject(val name:String, val aga:Int, val add:LevelUnder)
data class LevelUnder(val street:String, val number:Int)

0 comments on commit 520b4c5

Please sign in to comment.