diesel icon indicating copy to clipboard operation
diesel copied to clipboard

Compilation with `infer_schema!` panics when table has column named `ops`

Open Ameobea opened this issue 7 years ago • 5 comments

Somewhere in the macro expansion, there is code that imports ops from within diesel. If a column in a database is named ops, this causes conflicts within the macro.

I think that putting a note somewhere that this could happen may be enough; however, prefixing the internal variables or module names to something like _table_ops or something similar would be a more permanent solution.

Ameobea avatar Apr 06 '17 22:04 Ameobea

It's coming from the glob import on diesel::types::*. diesel::types::ops is not internal, it's public API. we just need a more scoped import.

sgrif avatar Apr 07 '17 11:04 sgrif

FWIW I just ran into this but with a column named builder.

alanhdu avatar Jun 05 '17 18:06 alanhdu

I don't think you're running into this issue. Diesel doesn't have any types or modules called builder.

sgrif avatar Jun 05 '17 18:06 sgrif

Huh... ok then, I've split the builder thing off into https://github.com/diesel-rs/diesel/issues/934.

alanhdu avatar Jun 05 '17 18:06 alanhdu

It's coming from the glob import on diesel::types::*. diesel::types::ops is not internal, it's public API. we just need a more scoped import.

I'd like to work on this but I could use a hand getting started.

Am I correct in thinking that https://github.com/diesel-rs/diesel/blob/6b4013d5e65fc4d988257afec403ad7db00882fa/diesel/src/macros/mod.rs#L275 is where we need to import something more specific? What should the import be?

Also, it looks like we're looking for imports of diesel::sql_types::* now, since there aren't diesel::types any more, after https://github.com/diesel-rs/diesel/commit/b95c9d2b0d78dbe597ade51f35dcee4130235399, correct?

willmurphyscode avatar Feb 08 '18 12:02 willmurphyscode