Skip to content
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

Using with changesets #25

Open
ElysaSrc opened this issue Mar 20, 2024 · 1 comment
Open

Using with changesets #25

ElysaSrc opened this issue Mar 20, 2024 · 1 comment

Comments

@ElysaSrc
Copy link

Maybe it's not an issue, but I cannot figure out how to use this library with Diesel Changesets ?

I have the following Changeset:

#[derive(AsChangeset, Debug)]
#[diesel(table_name = entities)]
pub struct EntityChangeSet {
    pub display_name: Option<String>,
    pub category_id: Option<Uuid>,
    pub data: Option<Value>,
    pub locations: Option<MultiPoint<Point>>,

    last_update_by: Option<Uuid>,
    updated_at: Option<chrono::NaiveDateTime>,
}

It outputs the following error:

error[E0277]: the trait bound `postgis_diesel::types::MultiPoint<postgis_diesel::types::Point>: AppearsOnTable<schema::entities::table>` is not satisfied
  --> src/models/entities.rs:31:10
   |
31 | #[derive(AsChangeset, Debug)]
   |          ^^^^^^^^^^^ the trait `AppearsOnTable<schema::entities::table>` is not implemented for `postgis_diesel::types::MultiPoint<postgis_diesel::types::Point>`
   |

Is there a way for this library to support Changesets ?

@vitaly-m
Copy link
Owner

Hi @ElysaSrc, can you provide complete minimal code example to reproduce that compilation error? I've tried to add AsChangeset derive into test structures like so, in integration_test.rs

#[derive(Insertable, AsChangeset)]
#[diesel(table_name = geometry_samples)]
struct NewGeometrySample {
    name: String,
    point: Point,
    point_z: PointZ,
    point_m: PointM,
    point_zm: PointZM,
    linestring: LineString<Point>,
    polygon: Polygon<Point>,
    multipoint: MultiPoint<Point>,
    multiline: MultiLineString<Point>,
    multipolygon: MultiPolygon<Point>,
    geometrycollection: GeometryCollection<Point>,
    geometrycontainer: GeometryContainer<Point>,
}

It compiled without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants