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

Generate mappers for queries #36

Closed
AlecKazakova opened this issue Jan 11, 2016 · 3 comments
Closed

Generate mappers for queries #36

AlecKazakova opened this issue Jan 11, 2016 · 3 comments

Comments

@AlecKazakova
Copy link
Collaborator

If a sql_stmt inside the .sq file is a query, generate a custom mapper for it

@AlecKazakova
Copy link
Collaborator Author

Relevant: http://stackoverflow.com/questions/9114086/optimizing-access-to-cursors-in-android-position-vs-column-names

Once we know which columns we're grabbing and what order we can make mapping 20% faster woo!

@JakeWharton
Copy link
Member

payments:
SELECT customer.*, payment.*
FROM ...

// generates:
interface Payments {
  Customer customer();
  Payment payment();
} 


payments:
SELECT customer.*, payment.*, COUNT(something) AS something
FROM ...

// generates:
interface Payments {
  Customer customer();
  Payment payment();
  long something()
} 


payments:
SELECT customer.*, payment.*, something.date
FROM ...

// generates:
interface Payments {
  Customer customer();
  Payment payment();
  Date date();
} 


payments:
SELECT customer.*, payment.*, something.date AS created_date
FROM ...

// generates:
interface Payments {
  Customer customer();
  Payment payment();
  Date created_date();
} 


payments:
SELECT sender.*, recipient.*, payment.*
FROM customer AS sender
JOIN customer AS recipient ON ...

// generates:
interface Payments {
  Customer sender();
  Customer recipient();
  Payment payment();
} 

@AlecKazakova
Copy link
Collaborator Author

a thought - instead of having the implementing class creating new mapper, potentially having to repeatedly specify column adapters, there could be a single factory class they instantiate which has paymentsMapper() : Mapper<PaymentModel> countMapper(): Mapper<Integer> marshal(): Marshal<PaymentModel> marshal(copy: PaymentModel): Marshal<PaymentModel> etc. methods.

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

No branches or pull requests

2 participants