Skip to content

Commit 520b4c5

Browse files
committed
fix #220 & #222
1 parent 36aa3a6 commit 520b4c5

File tree

7 files changed

+61
-11
lines changed

7 files changed

+61
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ deploy:
4949

5050
env:
5151
global:
52-
- NITRITE_VERSION=3.5.0-SNAPSHOT
52+
- NITRITE_VERSION=3.4.2
5353
- PGP_KEY_FILE=~/secring.gpg

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
org.gradle.jvmargs=-Xmx1024m
2525

2626
# artifact version
27-
nitriteVersion=3.5.0-SNAPSHOT
27+
nitriteVersion=3.4.2
2828

2929
# nitrite dependency
3030
asciidoctorVersion=1.5.6

nitrite/src/docs/asciidoc/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
= Nitrite
22
Anindya Chatterjee <anindya@dizitart.com>
3-
v3.5.0, {docdate} {doctime}
3+
v3.4.2, {docdate} {doctime}
44
: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.
55
: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,
66
:page-layout: docs
@@ -12,7 +12,7 @@ v3.5.0, {docdate} {doctime}
1212
:toclevels: 4
1313
:title-logo-image: image:images/nitrite-logo.svg[pdfwidth=4.25in,align=center]
1414
:homepage: http://nitrite.dizitart.org
15-
:version: 3.5.0
15+
:version: 3.4.2
1616
:source-highlighter: pygments
1717
:pygments-style: tango
1818
:linkattrs:

nitrite/src/main/java/org/dizitart/no2/internals/IndexingService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ void refreshIndexEntry(Document oldDocument, Document newDocument, NitriteId nit
203203

204204
if (indexType == IndexType.Fulltext && newValue instanceof String) {
205205
// update text index
206+
textIndexingService.deleteIndex(nitriteId, field, (String) oldValue);
206207
textIndexingService.updateIndex(nitriteId, field, (String) newValue);
207208
} else {
208209
NitriteMap<Comparable, ConcurrentSkipListSet<NitriteId>> indexMap

nitrite/src/main/java/org/dizitart/no2/util/ObjectUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ public static ObjectFilter createUniqueFilter(Object object, Field idField) {
186186
public static boolean isObjectStore(String collectionName) {
187187
try {
188188
if (isNullOrEmpty(collectionName)) return false;
189-
Class clazz = Class.forName(collectionName);
190-
return clazz != null;
191-
} catch (ClassNotFoundException e) {
189+
Class.forName(collectionName);
190+
return true;
191+
} catch (ClassNotFoundException | NoClassDefFoundError e) {
192192
return isKeyedObjectStore(collectionName);
193193
}
194194
}
@@ -209,9 +209,9 @@ public static boolean isKeyedObjectStore(String collectionName) {
209209
return false;
210210
}
211211
String storeName = split[0];
212-
Class clazz = Class.forName(storeName);
213-
return clazz != null;
214-
} catch (ClassNotFoundException e) {
212+
Class.forName(storeName);
213+
return true;
214+
} catch (ClassNotFoundException | NoClassDefFoundError e) {
215215
return false;
216216
}
217217
}

nitrite/src/test/java/org/dizitart/no2/NitriteTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,28 @@ public void testIssue212() {
383383
}
384384
}
385385

386+
@Test
387+
public void testIssue220() {
388+
NitriteCollection collection = db.getCollection("object");
389+
collection.drop();
390+
collection = db.getCollection("object");
391+
Document doc1 = createDocument("key", "key").put("second_key", "second_key").put("third_key", "third_key");
392+
Document doc2 = createDocument("key", "key").put("second_key", "second_key").put("fourth_key", "fourth_key");
393+
Document doc = createDocument("fifth_key", "fifth_key");
394+
395+
collection.insert(doc1, doc2, doc);
396+
db.close();
397+
398+
db = new NitriteBuilder()
399+
.filePath(fileName)
400+
.compressed()
401+
.openOrCreate("test-user", "test-password");
402+
collection = db.getCollection("object");
403+
Cursor documents = collection.find(Filters.eq("fifth_key", "fifth_key"));
404+
assertEquals(1, documents.size());
405+
assertEquals(doc, documents.firstOrDefault());
406+
}
407+
386408

387409
@Data
388410
@NoArgsConstructor

potassium-nitrite/src/test/kotlin/org/dizitart/kno2/NitriteTest.kt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.dizitart.kno2
2020

21+
import org.dizitart.no2.IndexOptions
2122
import org.dizitart.no2.IndexType
2223
import org.dizitart.no2.NullOrder
2324
import org.dizitart.no2.SortOrder
@@ -26,6 +27,7 @@ import org.dizitart.no2.objects.Id
2627
import org.dizitart.no2.objects.Index
2728
import org.dizitart.no2.objects.Indices
2829
import org.dizitart.no2.objects.InheritIndices
30+
import org.dizitart.no2.objects.filters.ObjectFilters
2931
import org.junit.Assert.*
3032
import org.junit.Before
3133
import org.junit.Test
@@ -161,6 +163,26 @@ class NitriteTest : BaseTest() {
161163
repository.insert(ClassWithLocalDateTime("test", LocalDateTime.now()))
162164
assertNotNull(repository.find())
163165
}
166+
167+
@Test
168+
fun testIssue222() {
169+
val first = NestedObjects("value1", "1", listOf(TempObject("name-1", 42,LevelUnder("street", 12))))
170+
val repository = db?.getRepository<NestedObjects>()!!
171+
repository.insert(first)
172+
173+
repository.createIndex("ob1", IndexOptions.indexOptions(IndexType.Fulltext));
174+
var found = repository.find(ObjectFilters.text("ob1", "value1"))
175+
assertTrue(found.idSet().isNotEmpty())
176+
177+
first.ob1 = "value2"
178+
repository.update(first)
179+
180+
found = repository.find(ObjectFilters.text("ob1", "value2"))
181+
assertTrue(found.idSet().isNotEmpty())
182+
183+
found = repository.find(ObjectFilters.text("ob1", "value1"))
184+
assertTrue(found.idSet().isEmpty())
185+
}
164186
}
165187

166188
interface MyInterface {
@@ -198,4 +220,9 @@ data class CaObject(
198220
data class ClassWithLocalDateTime (
199221
val name: String,
200222
val time: LocalDateTime
201-
)
223+
)
224+
225+
data class NestedObjects(var ob1:String, @Id val id: String, val list: List<TempObject>)
226+
227+
data class TempObject(val name:String, val aga:Int, val add:LevelUnder)
228+
data class LevelUnder(val street:String, val number:Int)

0 commit comments

Comments
 (0)