Skip to content
This repository has been archived by the owner on Jul 23, 2022. It is now read-only.

Improvement: Support to ignore fields #61

Closed
nevess opened this issue Apr 11, 2017 · 2 comments
Closed

Improvement: Support to ignore fields #61

nevess opened this issue Apr 11, 2017 · 2 comments

Comments

@nevess
Copy link

nevess commented Apr 11, 2017

Add support to ignore fields in the fromCursor and toContentValues implementation.

@gabrielittner
Copy link
Owner

You can use ColumnTypeAdapters that don't read or write anything to achieve this. Beyond that I have no plans to support ignoring fields.

@luisyng
Copy link

luisyng commented Jul 4, 2018

Hi @gabrielittner,

I am trying to to follow the approach you suggested, but I am having issues with the types.

I have implemented a generic ColumnTypeAdapter:

public abstract class IgnoreColumnAdapter<T> implements ColumnTypeAdapter<T> {

    public final T fromCursor(Cursor cursor, String columnName) {
        return null;
    }
    public final void toContentValues(ContentValues values, String columnName, T value) {
    }
}

Having this class:

public class User {
    // Column needs to be ignored
    public abstract UserCredentials userCredentials();
}

I have to create an specific class IgnoreUserCredentialsAdapter extends IgnoreColumnAdapter<UserCredentials> to ensure the generated code in fromCursor() has the expected type.

We have many types we would like to ignore. Is there a way to achieve this without creating an specific type for each of them?

Thanks a lot!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants