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

Support postgress ltree type in schema #1262

Closed
carols10cents opened this Issue Oct 18, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@carols10cents

carols10cents commented Oct 18, 2017

We've got a pr in crates.io to use postgres' ltree type. Diesel seems to be quite happy to use this, except when it comes to the schema.

After running the migration in that PR, of which the important part is adding a column to a table of type ltree:

ALTER TABLE categories ADD COLUMN path ltree;

I can run diesel print-schema --with-docs > src/schema.rs, and the new column with the ltree type is printed as I would expect:

table! {
    /// Representation of the `categories` table.
    ///
    /// (Automatically generated by Diesel.)
    categories (id) {

        // ...

        /// The `path` column of the `categories` table.
        ///
        /// Its SQL type is `Ltree`.
        ///
        /// (Automatically generated by Diesel.)
        path -> Ltree,
    }
}

but when I try to compile crates.io using this schema, I get these errors:

error[E0412]: cannot find type `Ltree` in this scope
   --> src/schema.rs:117:17
    |
117 |         path -> Ltree,
    |                 ^^^^^ not found in this scope

I have tried this with diesel 0.16.0 and diesel master at 75ba15a.

Checklist

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

This comment has been minimized.

Member

sgrif commented Oct 18, 2017

Are you ever using that column on anything Diesel related? If not you can just delete the column from schema.rs.

Otherwise you can create a struct Ltree; somewhere

@sgrif

This comment has been minimized.

Member

sgrif commented Oct 18, 2017

Since this type comes from an extension, which we don't support in Diesel, I'm going to close this. Proper support for this type would be better handled by a third party crate. (See diesel_full_text_search for an example implementation of one)

@sgrif sgrif closed this Oct 18, 2017

@carols10cents

This comment has been minimized.

carols10cents commented Oct 18, 2017

Then I have to either delete the column for schema.rs every time I run diesel print-schema, or I have to add use Ltree every time i run diesel print-schema, and everyone who adds a migration to diesel and runs print-schema has to know this...

@sgrif

This comment has been minimized.

Member

sgrif commented Oct 20, 2017

Yeah I think it's worth having us keep a diff file that can be easily re-applied in crates.io

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