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

Mysql and BLOB column #1089

Closed
bradleybeddoes opened this Issue Aug 11, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@bradleybeddoes

bradleybeddoes commented Aug 11, 2017

Setup

Versions

  • Rust: rustc 1.19.0
  • Diesel: 0.15.2
  • Database: Mysql
  • Operating System OSX

Feature Flags

  • diesel: mysql
  • diesel_codegen: mysql

Problem Description

When using infer_schema! on a table that includes a BLOB column compilation does not complete successfully.

What are you trying to accomplish?

Using a struct of the following definition:

#[derive(Queryable)]
struct RSAKeyPairData {
    pub id: i64,
    pub private_key_pem: Vec<u8>,
    pub certificate_pem: Vec<u8>,
    pub published: bool,
    pub active: bool,
}

What is the expected output?

Valid compilation.

What is the actual output?

error[E0412]: cannot find type `Blob` in this scope
 --> src/schema.rs:5:1
  |
5 | infer_schema!("dotenv:DATABASE_URL");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
  |
  = help: there is an enum variant `diesel::mysql::MysqlType::Blob`, did you mean to use `diesel::mysql::MysqlType`?
  = note: this error originates in a macro outside of the current crate

Are you seeing any additional errors?

No.

Steps to reproduce

CREATE TABLE rsakeypairs (
  id SERIAL PRIMARY KEY,
  private_key_pem BLOB NOT NULL,
  certificate_pem BLOB NOT NULL,
  published BOOLEAN NOT NULL DEFAULT 0,
  active BOOLEAN NOT NULL DEFAULT 0
)

Use infer_schema! to trigger.

n.b. diesel print-schema outputs:

table! {
    rsakeypairs (id) {
        id -> Bigint,
        private_key_pem -> Blob,
        certificate_pem -> Blob,
        published -> Bool,
        active -> Bool,
    }
}

Manually supplying the following table! definition as opposed to using infer_schema! removes the compilation fault and all appears to function correctly, I am not sure if Binary is correct here (though from docs it seems to be):

table! {
    rsakeypairs (id) {
        id -> Bigint,
        private_key_pem -> Binary,
        certificate_pem -> Binary,
        published -> Bool,
        active -> Bool,
    }
}

Checklist

  • I have already looked over the issue tracker for similar issues.

Eijebong added a commit to Eijebong/diesel that referenced this issue Aug 11, 2017

Add the Blob type to diesel
As for tiny/medium/bigblob, it's just an alias to binary

Fixes diesel-rs#1089

Eijebong added a commit to Eijebong/diesel that referenced this issue Aug 11, 2017

Add the Blob type to diesel
As for tiny/medium/bigblob, it's just an alias to binary

Fixes diesel-rs#1089

@killercup killercup added the mysql label Aug 11, 2017

@killercup

This comment has been minimized.

Member

killercup commented Aug 11, 2017

Thanks for the report! Seems like this is just a small missing piece. And @Eijebong already opened #1090 to fix it :)

@bradleybeddoes

This comment has been minimized.

bradleybeddoes commented Aug 11, 2017

Can't argue with a response as quick as that!

Thanks folks :).

Eijebong added a commit to Eijebong/diesel that referenced this issue Aug 11, 2017

Add the Blob type to diesel
As for tiny/medium/longblob, it's just an alias to binary.
Also add some tests for every binary type we're supporting for MySQL.

Fixes diesel-rs#1089

Eijebong added a commit to Eijebong/diesel that referenced this issue Aug 11, 2017

Add the Blob type to diesel
As for tiny/medium/longblob, it's just an alias to binary.
Also add some tests for every binary type we're supporting for MySQL.

Fixes diesel-rs#1089

killercup added a commit that referenced this issue Aug 12, 2017

Add the Blob type to diesel
As for tiny/medium/longblob, it's just an alias to binary.
Also add some tests for every binary type we're supporting for MySQL.

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