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

Nullable Timestamptz unsupported with now #1031

Closed
lancecarlson opened this Issue Jul 19, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@lancecarlson
Contributor

lancecarlson commented Jul 19, 2017

Setup

Versions

  • Rust:
    nightly
  • Diesel:
    0.14.1
  • Database:
    postgres
  • Operating System
    Fedora

Feature Flags

  • diesel:
  • diesel_codegen:

Problem Description

I was attempting to write a query that updated a timestamp column that was nullable and received a compile error. Example query:

diesel::update(import_jobs.filter(completed_at.is_null()))
        .set(completed_at.eq(diesel::expression::dsl::now))
        .execute(conn)?;

What are you trying to accomplish?

^^^

What is the expected output?

Successful compile

What is the actual output?

error[E0271]: type mismatch resolving `<diesel::expression::nullable::Nullable<diesel::expression::now> as diesel::Expression>::SqlType == diesel::types::Nullable<diesel::types::Timestamptz>` --> src/importer.rs:52:25 | 52 | .set((failed_at.eq(diesel::expression::dsl::now.nullable()), failed_reason.eq("aborted"))) | ^^ expected struct `diesel::types::Timestamp`, found struct `diesel::types::Timestamptz` | = note: expected type `diesel::types::Nullable<diesel::types::Timestamp>` found type `diesel::types::Nullable<diesel::types::Timestamptz>`

Current work around

@sgrif Recommended this for now:

let nullable_timestamptz = AsExpression::<Timestamptz>::as_expression(diesel::expression::dsl::now).nullable();

diesel::update(import_jobs.filter(completed_at.is_null()))
        .set(completed_at.eq(nullable_timestamptz))
        .execute(conn)?;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment