Skip to content
This repository was archived by the owner on Feb 8, 2022. It is now read-only.

Commit 02bae89

Browse files
committed
Merge pull request #18 from florent37/dev
Dev
2 parents ff3029d + a8ee8f5 commit 02bae89

File tree

6 files changed

+1056
-995
lines changed

6 files changed

+1056
-995
lines changed

README.md

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,24 @@ buildscript {
1717
apply plugin: 'com.neenbedankt.android-apt'
1818

1919
dependencies {
20-
compile 'fr.xebia.android.freezer:freezer:1.0.6'
21-
provided 'fr.xebia.android.freezer:freezer-annotations:1.0.6'
22-
apt 'fr.xebia.android.freezer:freezer-compiler:1.0.6'
20+
compile 'fr.xebia.android.freezer:freezer:2.0.1'
21+
provided 'fr.xebia.android.freezer:freezer-annotations:2.0.1'
22+
apt 'fr.xebia.android.freezer:freezer-compiler:2.0.1'
23+
}
24+
```
25+
26+
#It's always better with a context
27+
28+
Don't forget to initialise Freezer in your application:
29+
30+
```java
31+
public class MyApplication extends Application {
32+
33+
@Override public void onCreate() {
34+
super.onCreate();
35+
Freezer.onCreate(this);
36+
}
37+
2338
}
2439
```
2540

@@ -127,6 +142,16 @@ float ageMax = userEntityManager.select().max(UserColumns.age);
127142
int count = userEntityManager.select().count();
128143
```
129144

145+
## Limit
146+
147+
The `QueryBuilder` offers a limitation method, for example, getting 10 users, starting from the 5th:
148+
149+
```java
150+
ist<User> someUsers = userEntityManager.select()
151+
.limit(5, 10) //start, count
152+
.asList();
153+
```
154+
130155
#Asynchronous
131156

132157
Freezer offers various asynchronous methods:
@@ -246,21 +271,6 @@ You can log all SQL queries from entities managers:
246271
userEntityManager.logQueries((query, datas) -> Log.d(TAG, query) }
247272
```
248273

249-
#It's always better with a context
250-
251-
Don't forget to initialise Freezer in your application:
252-
253-
```java
254-
public class MyApplication extends Application {
255-
256-
@Override public void onCreate() {
257-
super.onCreate();
258-
Freezer.onCreate(this);
259-
}
260-
261-
}
262-
```
263-
264274
#Migration
265275

266276
To handle schema migration, just add `@Migration(newVersion)` in a static method,
@@ -296,11 +306,6 @@ Migration isn't yet capable of:
296306
- adding/modifying One To One
297307
- adding/modifying One To Many
298308
- handling collections/arrays
299-
300-
#TODO
301-
302-
- Improve migration
303-
- Add Observable support
304309
305310
#Changelog
306311
@@ -329,12 +334,16 @@ Introduced Migration Engine.
329334
330335
- Model update
331336
332-
##1.0.6
337+
##2.0.0
333338
334339
- Async API
335340
- Support Observables
336341
- Added @DatabaseName
337342
343+
##2.0.1
344+
345+
- Limit
346+
338347
#A project initiated by Xebia
339348
340349
This project was first developed by Xebia and has been open-sourced since. We will continue working on it.

app/src/test/java/com/github/florent37/dao/UserQueryBuilderTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,35 @@ public void onError(List<User> data) {
509509
assertThat(numberOfUsers.get()).isEqualTo(3);
510510
}
511511

512+
@Test
513+
public void testSelectUsers_limit() {
514+
//given
515+
List<User> users = Arrays.asList(
516+
new User(21, "a", null, null, true),
517+
new User(21, "b", null, null, true),
518+
new User(21, "c", null, null, true),
519+
new User(21, "d", null, null, true),
520+
new User(21, "e", null, null, true),//4
521+
new User(21, "f", null, null, true),
522+
new User(21, "g", null, null, true),
523+
new User(21, "h", null, null, true),
524+
new User(21, "i", null, null, true),
525+
new User(21, "j", null, null, true),
526+
new User(21, "k", null, null, true),
527+
new User(21, "l", null, null, true),
528+
new User(21, "m", null, null, true)
529+
);
530+
userEntityManager.add(users);
531+
532+
//when
533+
List<User> usersFromBase = userEntityManager
534+
.select()
535+
.limit(4,5)
536+
.asList();
537+
538+
//then
539+
assertThat(usersFromBase.size()).isEqualTo(5);
540+
assertThat(usersFromBase.get(0).getName()).isEqualTo("e");
541+
}
542+
512543
}

build.gradle

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
mavenCentral()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:1.5.0'
9+
classpath 'com.android.tools.build:gradle:2.0.0'
1010
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
1111
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
1212
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
@@ -23,7 +23,7 @@ ext{
2323
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
2424
targetCompatibilityVersion = JavaVersion.VERSION_1_7
2525

26-
libraryVersion="1.0.6"
26+
libraryVersion="2.0.1"
2727
}
2828

2929
allprojects {
@@ -34,8 +34,4 @@ allprojects {
3434
url "http://dl.bintray.com/florent37/maven"
3535
}
3636
}
37-
}
38-
39-
task clean(type: Delete) {
40-
delete rootProject.buildDir
41-
}
37+
}

0 commit comments

Comments
 (0)