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

Can't debug_sql! query that contains time::Timespec; trait not implemented #978

Closed
carols10cents opened this Issue Jun 29, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@carols10cents

carols10cents commented Jun 29, 2017

Setup

Versions

  • Rust: stable 1.18.0
  • Diesel: 0.13.0
  • Database: postgres
  • Operating System osx

Feature Flags

  • diesel: features = ["postgres", "serde_json", "deprecated-time", "chrono"]
  • diesel_codegen: none

Problem Description

What are you trying to accomplish?

I'm trying to debug a query in crates.io (essentially this code but i'm changing some things for debugging), because i'm having a timezone issue:

    let downloads_query = VersionDownload::belonging_to(&version)
        .filter(version_downloads::date.between(
            date(cutoff_start_date)..
                date(cutoff_end_date),
        ))
        .order(version_downloads::date);

    debug_sql!(downloads_query);

What is the expected output?

I expect to see a printed version of the SQL generated by this diesel code.

What is the actual output?

I get a compilation error:

error[E0277]: the trait bound `time::Timespec: diesel::types::ToSql<diesel::types::Timestamp, diesel::backend::Debug>` is not satisfied
   --> src/version.rs:475:5
    |
475 |     debug_sql!(downloads_query);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `diesel::types::ToSql<diesel::types::Timestamp, diesel::backend::Debug>` is not implemented for `time::Timespec`
    |

Steps to reproduce

Check out this branch of crates.io: https://github.com/integer32llc/crates.io/tree/diesel-debug-sql-error and try to build it.

Checklist

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

Eijebong added a commit to Eijebong/diesel that referenced this issue Jun 30, 2017

@Eijebong

This comment has been minimized.

Member

Eijebong commented Jun 30, 2017

Thanks for the report. It is indeed a bug (we're missing a debug_to_sql! call for Timespec).

Here is what you would get with the debug_sql! function if it worked, I hope it can help you while you're waiting on this to be fixed :)

SELECT `version_downloads`.`id`, `version_downloads`.`version_id`, `version_downloads`.`downloads`, `version_downloads`.`counted`, `version_downloads`.`date`, `version_downloads`.`processed` FROM `version_downloads` WHERE `version_downloads`.`version_id` = ? AND `version_downloads`.`date` BETWEEN date(?) AND date(?) ORDER BY `version_downloads`.`date`

mcgoo added a commit to mcgoo/diesel that referenced this issue Oct 12, 2017

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