maskarade / android-orma Goto Github PK
View Code? Open in Web Editor NEWAn ORM for Android with type-safety and painless smart migrations
License: Other
An ORM for Android with type-safety and painless smart migrations
License: Other
There is document in migration/README.md
, but there is not working example yet.
Do not stop processing on errors before generating helper classes. Otherwise you see too many "Cannot find symbol OrmaDatabase" errors, which is useless to debug the code.
Currently JSqlParser can't parse SQLite-specific constraints, so column constraints requires a complete SQLite parser (#59)
Something like this?
interface AsyncTransactionTask<T> {
Single<T> execute();
}
public <T> Single<T> transactionAsync(@NonNull final AsyncTransactionTask task) {
return Single.create(new Single.OnSubscribe<Single<T>>() {
@Override
public void call(SingleSubscriber<? super Single<T>> subscriber) {
subscriber.onSuccess(task.execute());
}
}).flatMap(new Func1<Single<T>, Single<? extends T>>() {
@Override
public Single<? extends T> call(Single<T> single) {
return single;
}
});
}
with RxJava Subject
interface?
// getter
@Column("name")
public String getName() { ... }
@Column
String name;
@Getter("name")
public String getName() { ... }
// setter
@Setter("name")
public void setName(String value) { ... }
// for constructor
public Todo(@Setter("name") String name) { ... }
Anyone wants?
TypeHolder
hack not working on Android 4.2.2
How about Gson's TypeToken hacks?
https://github.com/google/gson/blob/master/gson/src/main/java/com/google/gson/reflect/TypeToken.java
keyword: org.apache.harmony.luni.lang.reflect.ImplForType
SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table.
ADD COLUMN
, CREATE TABLE
, CREATE INDEX
, and DROP INDEX
are automaticsee #131
There aren't the following classes in exaple directory.
com.github.gfx.android.orma.example.databinding.ActivityTodoBinding
com.github.gfx.android.orma.example.databinding.CardTodoBinding
com.github.gfx.android.orma.example.orma.OrmaDatabase
Relation<T>
is a relation, or a view of a table, produces Selector<T>
, Updater<T>
, and Deleter<T>
tSelector<T>
has a Relation<T>
, which can execute SELECT
queryUpdater<T>
has a Relation<T>
, which can execute UPDATE
queryDeleter<T>
has a Relation<T>
, which can execute DELETE
querye.g.
Todo_Relation<Todo> todos = orma.getTodoRelation();
todos().toList(); # uses Selector<Todo>
todos().orderByIdAsc().todo(); # also uses Selector<T>
todos().deleter();
...
Not sure if this is a bug yet but i'm using squareup dagger https://github.com/square/dagger and i'm getting this error because that also generates classes:
/Users/gravener/AndroidStudioProjects/draft-android/app/build/generated/source/apt/stagingLollipop/debug/com/playdraft/draft/support/DraftModule$$ModuleAdapter.java
Error:(886, 85) error: cannot find symbol class OrmaDatabase
Error:(887, 27) error: cannot find symbol class OrmaDatabase
Error:(921, 12) error: cannot find symbol class OrmaDatabase
I thought this would work by order it is defined in build.gradle:
apt 'com.github.gfx.android.orma:orma-processor:0.22.0'
compile('com.github.gfx.android.orma:orma:0.22.0') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'recyclerview'
}
compile 'com.squareup.dagger:dagger:1.2.2'
apt 'com.squareup.dagger:dagger-compiler:1.2.2'
but no dice.
https://github.com/gfx/Android-Helium can't compile with Orma v0.15.0.
Not supported:
boolean isX()
@Column("foo_bar") String mFooBar
Like @Table(constraint = "UNIQUE (author, title) ON CONFLICT ROLLBACK")
There are, but not yet tested.
SQLite Query Language: CREATE VIEW
@TableView(from = Foo.class)
public class MaxMinValue {
@Column("max(value)")
public double max;
@Column("min(value)")
public double min;
}
Orma uses JSQLParser, which cannot parse some SQLite query like UNIQUE(..) ON CONFLICT ...
clause in CREATE TABLE
.
It is better if Orma has a built-in SQLite DDL parser.
As of v0.19.0, it is difficult to use. e.g. defaultExpr = "''"
for an empty string.
e.g. https://github.com/pardom/ActiveAndroid/tree/master/src/com/activeandroid/serializer
BigDecimal
UUID
SparseArray<String>
Rational
ref. #67
@Column(defaultExpr = "('')")
causes StackOverflowError
on migration.
In fact, SQLiteParser
can't parse "CREATE TABLE foo (title TEXT DEFAULT (''))"
on Android devices.
Currently, SQLiteParserUtils raises errors with "SQL is too complex: CREATE TABLE ...".
Realm Java https://realm.io/docs/java/latest/#queries
// Build the query looking at all users:
RealmQuery<User> query = realm.where(User.class);
// Add query conditions:
query.equalTo("name", "John");
query.or().equalTo("name", "Peter");
// Execute the query:
RealmResults<User> result1 = query.findAll();
// Or alternatively do the same all at once (the "Fluent interface"):
RealmResults<User> result2 = realm.where(User.class)
.equalTo("name", "John")
.or()
.equalTo("name", "Peter")
.findAll();
Ebean ORM http://ebean-orm.github.io/docs/queries
// find all the orders shipped since a week ago
List<Order> list = Ebean.find(Order.class)
.where()
.eq("status", Order.Status.SHIPPED)
.gt("shipDate", lastWeek)
.findList();
GreenDAO http://greendao-orm.com/documentation/queries/
QueryBuilder qb = userDao.queryBuilder();
qb.where(Properties.FirstName.eq("Joe"),
qb.or(Properties.YearOfBirth.gt(1970),
qb.and(Properties.YearOfBirth.eq(1970), Properties.MonthOfBirth.ge(10))));
List youngJoes = qb.list();
This issue occurs if existing table has these constraints. Hmm...
Related to #59
There are existing code to use CursorAdapter
easily.
Current:
Todo todo = OrmaDatabase.schemaTodo
.createModelFromCursor(orma.getConnection(), cursor);
Better:
Todo todo = orma.loadTodoFromCursor(cursor);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.