Skip to content

dsl::max doesn't work with dsl::auto_type #3745

@Elrendio

Description

@Elrendio

Setup

Versions

  • Rust: rustc --version = rustc 1.70.0 (90c541806 2023-05-31)
  • Diesel: master
  • Database: _
  • Operating System Archlinux

Feature Flags

  • diesel: "postgres", "r2d2", "serde_json", "chrono",

Problem Description

FYI @Ten0 knows and says it's a blocker for the release of auto_type so he'll try to fix.

When deriving on a struct Selectable with one field having a select_expression containing dsl::max compilation breaks with error:

error[E0573]: expected type, found function `diesel::dsl::max`
   --> mod.rs:463:6
    |
463 |                     diesel::dsl::max<table::column>,
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a type
    |
help: consider importing this type alias instead
    |
8   + use diesel::helper_types::max;
    |
help: if you import `max`, refer to it directly
    |
463 -                     diesel::dsl::max<table::column>,
463 +                     max<table::column>,
    |

What are you trying to accomplish?

Use Selectable derive

What is the expected output?

Code compiles

What is the actual output?

Compilation fails

Are you seeing any additional errors?

No

Steps to reproduce

mod schema {

    diesel::table! {
	    table (id) {
		    id -> Int4,
                    other_id -> Int4,,
		    column -> Int4,
	    }
    }
    diesel::table! {
	    other_table (id) {
		    id -> Int4,
		    column -> Int4,
	    }
    }
}

#[derive(Queryable, Serialize, Selectable)]
#[diesel(table_name = table)]
pub(crate) struct Struct {
	#[diesel(
		select_expression = schema::table::table
			.filter(schema::table::other_id.eq(schema::other_table::id))
			.select(dsl::max(table::column))
			.single_value(),
	)]
	pub(crate) max_val: Option<i32>,
}

Checklist

  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
  • This issue can be reproduced without requiring a third party crate

Metadata

Metadata

Assignees

Labels

Release BlockerThis issue needs to be solved before we can release a new version, it can't be punted to the nextbug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions