diesel-rs / diesel

A safe, extensible ORM and Query Builder for Rust
https://diesel.rs
Apache License 2.0
12.79k stars 1.08k forks source link

Macro define_sql_function imposes diesel as direct dependency #4317

Closed Elrendio closed 4 weeks ago

Elrendio commented 1 month ago

Setup

Versions

Feature Flags

Problem Description

Use of ::diesel in procedural macro define_sql_function forces to diesel as direct dependency instead of simply in scope, which is bothersome when diesel is re-exported.

What are you trying to accomplish?

Use macro define_sql_function without having diesel as direct dependency

What is the expected output?

Code compiles

What is the actual output?

error[E0433]: failed to resolve: could not find `diesel` in the list of imported crates
  --> /home/elrendio/Stockly/Main/operations/Service/src/supply/Suppliers/src/auto_block/high_at_submission_price_changes.rs:95:4
   |
95 | /             diesel::define_sql_function! {
96 | |                 fn greatest(a: Nullable<Timestamptz>, b: Nullable<Timestamptz>, c: Timestamptz) -> Timestamptz;
97 | |             }
   | |_____________^ could not find `diesel` in the list of imported crates
   |
   = note: this error originates in the macro `diesel::define_sql_function` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this module

Are you seeing any additional errors?

/

Steps to reproduce

  1. Create a crate that re-exports diesel, let's call it diesel_helpers
  2. Create a second crate with dependency diesel_helpers, let's call it diesel_consumer
  3. In crate diesel_consumer, use diesel_helpers::diesel::define_sql_function

Checklist