rust serde diesel table column limit

Problem

I have the following sql table:

CREATE TABLE system (
  id SERIAL PRIMARY KEY,
  name VARCHAR NOT NULL UNIQUE,
  allegiance_id SERIAL REFERENCES allegiance (id),
  state_id SERIAL REFERENCES state (id),
  government_id SERIAL REFERENCES government (id),
  security_id SERIAL REFERENCES security (id),
  needs_permit BOOLEAN DEFAULT FALSE,
  power_state_id SERIAL REFERENCES power_state (id),
  x DOUBLE PRECISION NOT NULL,
  y DOUBLE PRECISION NOT NULL,
  z DOUBLE PRECISION NOT NULL,
  simbad_ref VARCHAR DEFAULT '',
  controlling_minor_faction_id SERIAL, -- TODO REF
  reserve_type_id SERIAL REFERENCES reserve_type (id),
  is_populated BOOLEAN DEFAULT FALSE,
  edsm_id SERIAL,
  updated_at TIMESTAMPTZ
);

Running diesel print-schema > src/schema.rs generates the following schema code:

table! {
    system (id) {
        id -> Int4,
        name -> Varchar,
        allegiance_id -> Int4,
        state_id -> Int4,
        government_id -> Int4,
        security_id -> Int4,
        needs_permit -> Nullable<Bool>,
        power_state_id -> Int4,
        x -> Float8,
        y -> Float8,
        z -> Float8,
        simbad_ref -> Nullable<Varchar>,
        controlling_minor_faction_id -> Int4,
        reserve_type_id -> Int4,
        is_populated -> Nullable<Bool>,
        edsm_id -> Int4,
        updated_at -> Nullable<Timestamptz>,
    }
}

Compiling this gives the following error among things:

error[E0277]: the trait bound `(schema::system::columns::id, schema::system::columns::name, schema::system::columns::allegiance_id, schema::system::columns::state_id, schema::system::columns::government_id, schema::system::columns::security_id, schema::system::columns::needs_permit, schema::system::columns::power_state_id, schema::system::columns::x, schema::system::columns::y, schema::system::columns::z, schema::system::columns::simbad_ref, schema::system::columns::controlling_minor_faction_id, schema::system::columns::reserve_type_id, schema::system::columns::is_populated, schema::system::columns::edsm_id, schema::system::columns::updated_at): diesel::Expression` is not satisfied
  --> src/schema.rs:58:1
   |
58 | / table! {
59 | |     system (id) {
60 | |         id -> Int4,
61 | |         name -> Varchar,
...  |
77 | |     }
78 | | }

This is a bit unclear and I first thought that perhaps there is an issue with the Timestamptz type as commenting out that field makes it compiles fine. However further testing showed that commenting out any field solves it.

Solution

diesel has a default table column limit of 16. Our table has 17 columns. Adding large-tables to Cargo.toml solves it.

[dependencies]
diesel = { version = "1.0", features = ["postgres", "chrono", "large-tables"] }

Thinking about it this way the error actually makes sense. Diesel has no implementation for diesel::Expression for a 17 column table (which is implemented as a 17 size tuple).