Giter Club home page Giter Club logo

android-orma's People

Contributors

anolivetree avatar chibatching avatar daisuke-nomura avatar gfx avatar gotokatsuya avatar hotchemi avatar k-kagurazaka avatar keima avatar kyokomi avatar muojp avatar operando avatar snkashis avatar sosuke-ito avatar yshrsmz avatar ytrino avatar yukimatsumura avatar zoff99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-orma's Issues

Better error handling

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.

Better asynchronous transactions

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;
            }
        });
    }

Accessor support

// 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) { ... }

Migration

SQLite ALTER TABLE

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.

Concepts

  • ADD COLUMN, CREATE TABLE, CREATE INDEX, and DROP INDEX are automatic
  • other modifications should be handled by code

Cannot build Example.

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

Model-specific database handle

  • Relation<T> is a relation, or a view of a table, produces Selector<T>, Updater<T>, and Deleter<T>t
  • Selector<T> has a Relation<T>, which can execute SELECT query
  • Updater<T> has a Relation<T>, which can execute UPDATE query
  • Deleter<T> has a Relation<T>, which can execute DELETE query

e.g.

Todo_Relation<Todo> todos = orma.getTodoRelation();
todos().toList(); # uses Selector<Todo>
todos().orderByIdAsc().todo(); # also uses Selector<T>
todos().deleter();
...

Trying to use with dagger, dagger can't find classes

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.

Table constraints

Like @Table(constraint = "UNIQUE (author, title) ON CONFLICT ROLLBACK")

Built-in SQLite DDL parser

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.

per-column condition helpers

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();

Easy-to-use createFromCursor()

There are existing code to use CursorAdapter easily.

Current:

Todo todo = OrmaDatabase.schemaTodo
                .createModelFromCursor(orma.getConnection(), cursor);

Better:

Todo todo = orma.loadTodoFromCursor(cursor);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.