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 table by deriving Queriable #40

Closed
defyrlt opened this Issue Dec 2, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@defyrlt

defyrlt commented Dec 2, 2015

In issue #36 I was trying to get example with #[derive(Queriable)] to work and one of the things that confused me is that you still have to make a table! call and hand-write all the column types.
Here I'm proposing to make Queriable smart enough to generate appropriate table stuff or even table! call so you won't have to do it manually. For some cases you might want to manually set the type of the column, e.g

#[derive(Queriable, Debug)]
pub struct User {
    #[column_type = Serial]
    id: i32,
    #[column_type = VarChar]
    name: String,
}

P.S @sgrif thanks for all the great work you've done! I'm very excited about query builder/ORM in Rust.

@sgrif

This comment has been minimized.

Member

sgrif commented Dec 2, 2015

I do not like the idea of generating a table from Queriable, as it implies too heavily that a struct has to be one to one with a database table, and puts too much schema information in the struct itself. I'd prefer a macro which generates the table! call for you based on the database schema at compile time.

@sgrif

This comment has been minimized.

Member

sgrif commented Dec 4, 2015

Forgot to reference this from the other PR. First pass at this is #49 -- There will be an additional macro which loads table names from schema and calls that one automatically.

@sgrif sgrif closed this in 272d63d Dec 5, 2015

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