Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove column name/type/behaviour knowledge from code, remove CursorRowMapper #4

Open
jdavo opened this issue Jun 6, 2012 · 1 comment
Assignees

Comments

@jdavo
Copy link
Collaborator

jdavo commented Jun 6, 2012

Some code (most noticeably CursorRowMapper) requires the developer to interact directly with the SQLite database and pushes knowledge about the column names from the model into other code.

If the model includes boolean (and other?) types then the developer must also know that the field ismapped to an SQLite Integer and that 1=true, 0=false.

Instead I believe that each ColumnType should encapsulate this knowledge so that each ColumnType understands how to map is value to the database and return it to the model layer.

Once this exists, the CursorRowMapper should no longer be required as the mapping of each field would be determined by the ColumnType annotation.

TODO: now need to column info from template/accessors :)

@jdavo
Copy link
Collaborator Author

jdavo commented Jun 13, 2012

Introduced ability for com.perfectworldprogramming.mobile.orm.AndroidSQLiteTemplate to perform domain to DB conversion based on class and column name, see com.perfectworldprogramming.mobile.orm.test.reflection.QueryParameterTest (currently on my fork until pulled)

The query mechanism using the column name still mixes DB and domain knowledge, so I'm looking at a light OQL (object query language) which allows queries to be written in the domain layer and converted to SQL for the DB

eg
select * from Person where [lastName] = ? and [pets] > ?
becomes
select * from Person where LAST_NAME = ? and PETS > ?

select * from Person p, Address a where p.[Person.lastName] = ? p.[Person.id] = a.[Address.person]
becomes
select * from Person p, Address a where p.LAST_NAME = ? p.PERSON_ID = a.PERSON_ID

Note that this assumes that the table name is the same as the class.getSimpleType(). As shown above it is not perfect since it still assumes knowledge about the column names and the need to distinguish the different PERSON_ID references.

@ghost ghost assigned jdavo Jun 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant