Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ target
tmp
.clover
atlassian-ide-plugin.xml
.idea
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>

</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/codeslap/persistence/DatabaseSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,13 @@ public String toString() {
", mAfterImporters=" + mAfterImporters +
'}';
}

/**
* Returns the List of classes that have been added to the DatabaseSpec, useful for
* operations like Database truncate.
* @return List<Class?>
*/
public List<Class<?>> getMatches(){
return mSqliteList;
}
}
10 changes: 6 additions & 4 deletions src/main/java/com/codeslap/persistence/SqliteAdapterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

/**
* This is a persistence adapter that uses sqlite database as persistence engine.
Expand All @@ -40,6 +39,7 @@ public class SqliteAdapterImpl implements SqlAdapter {
// this expression is used when inserting rows in the many-to-many relation tables. It will basically
// prevent a row from being inserted when the values already exist.
private static final String HACK_INSERT_FORMAT = "CASE WHEN (SELECT COUNT(*) FROM %s WHERE %s = %s AND %s = %s) == 0 THEN %s ELSE NULL END";
private static final DateFormat dateFormat = new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
private static final String TAG = "sqliteImpl";

private final DatabaseSpec mDatabaseSpec;
Expand Down Expand Up @@ -739,6 +739,8 @@ private Object getValueFromCursor(Class<?> type, String name, Cursor query) {
value = query.getString(columnIndex);
} else if (type == byte[].class || type == Byte[].class) {
value = query.getBlob(columnIndex);
} else if (type == Date.class){
value = dateFormat.parse(query.getString(columnIndex));
}
return value;
} catch (Exception e) {
Expand Down