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

Column limits? #359

Closed
thejefflarson opened this issue Jun 22, 2016 · 7 comments
Closed

Column limits? #359

thejefflarson opened this issue Jun 22, 2016 · 7 comments

Comments

@thejefflarson
Copy link

Are there column limits for tables used with diesel? For example if I use the code in diesel demo and add thirteen more fields:

CREATE TABLE posts (
  id SERIAL PRIMARY KEY,
  title VARCHAR NOT NULL,
  body TEXT NOT NULL,
  published BOOLEAN NOT NULL DEFAULT 'f',
  one integer,
  two integer,
  three integer,
  four integer,
  five integer,
  six integer,
  seven varchar,
  eight varchar,
  nine varchar,
  ten varchar,
  eleven varchar,
  twelve varchar,
  thirteen varchar
)

I get a trait bound error after running diesel migration redo:

<diesel macros>:18:64: 18:71 error: the trait bound `(schema::posts::columns::id, schema::posts::columns::title, schema::posts::columns::body, schema::posts::columns::published, schema::posts::columns::one, schema::posts::columns::two, schema::posts::columns::three, schema::posts::columns::four, schema::posts::columns::five, schema::posts::columns::six, schema::posts::columns::seven, schema::posts::columns::eight, schema::posts::columns::nine, schema::posts::columns::ten, schema::posts::columns::eleven, schema::posts::columns::twelve, schema::posts::columns::thirteen): diesel::SelectableExpression<schema::posts::table, (diesel::types::Integer, diesel::types::VarChar, diesel::types::Text, diesel::types::Bool, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>)>` is not satisfied [E0277]
<diesel macros>:18 :: FromClause { Identifier ( stringify ! ( $ name ) ) } } impl AsQuery for
                                                                                  ^~~~~~~
<diesel macros>:5:1: 5:71 note: in this expansion of table_body! (defined in <diesel macros>)
src/schema.rs:1:1: 1:40 note: in this expansion of table! (defined in <diesel macros>)
src/schema.rs:1:1: 1:40 note: in this expansion of infer_schema! (defined in src/lib.rs)
src/lib.rs:9:1: 9:23 note: in this expansion of include!
<diesel macros>:18:64: 18:71 help: run `rustc --explain E0277` to see a detailed explanation
<diesel macros>:18:64: 18:71 note: required because of the requirements on the impl of `diesel::query_builder::Query` for `diesel::query_builder::SelectStatement<(diesel::types::Integer, diesel::types::VarChar, diesel::types::Text, diesel::types::Bool, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::Integer>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>, diesel::types::Nullable<diesel::types::VarChar>), (schema::posts::columns::id, schema::posts::columns::title, schema::posts::columns::body, schema::posts::columns::published, schema::posts::columns::one, schema::posts::columns::two, schema::posts::columns::three, schema::posts::columns::four, schema::posts::columns::five, schema::posts::columns::six, schema::posts::columns::seven, schema::posts::columns::eight, schema::posts::columns::nine, schema::posts::columns::ten, schema::posts::columns::eleven, schema::posts::columns::twelve, schema::posts::columns::thirteen), schema::posts::table>`

If I remove the thirteen column that error disappears.

@thejefflarson
Copy link
Author

thejefflarson commented Jun 22, 2016

Nevermind, I should read the docs:

/// Specifies that a table exists, and what columns it has. This will create a

Thanks for the fantastic library!

@killercup
Copy link
Member

We may be able to add an on_unimplemented annotation for better errors in these cases (on nightly), but it seems like there are some problems with blanket impls (which funnily enough Sean found while building diesel): rust-lang/rust#29628

@thejefflarson
Copy link
Author

One question, suppose I have a table with hundreds of fields (I know, I know -- I'm a journalist and we get crazy data) is there anything I can do?

@killercup
Copy link
Member

killercup commented Jun 22, 2016

@thejefflarson Well, that depends on how much time and effort you want to put into this :) Here are some options:

  1. Normalize that database so it uses a more sane schema :) Edit: You can also use Views for that, of course.
  2. Submit a PR to diesel to add a "really-huge-tables" feature, where you repeat this stuff for far longer.
  3. Improve Rust itself to have more generic tuple support

@thejefflarson
Copy link
Author

@killercup Ha ok. 1 is sometimes not possible (I'm side-eying the census here, though I almost always don't need the whole thing).

I might take you up on 2 -- though even for me I can only think of a handful of datasets that may need more than 52 fields. I think I can do it if I need it, thanks for the pointer! And thanks for taking the time!

@sgrif
Copy link
Member

sgrif commented Jun 23, 2016

Option 4: Fix the linear growth in compile time that is linked to number of trait implementations in Rust itself and then I can implement this to be as large as people ask and turned on by default. (Easy, right? :trollface:)

@sgrif
Copy link
Member

sgrif commented Jun 23, 2016

For the record, I will accept a really-huge-tables feature.

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

3 participants