Comments (4)
A potential workaround is to tell Diesel not to generate missing SQL type definitions and then manually specify them yourself. For my MWE the [print_schema]
section of diesel.toml will become
[print_schema]
file = "src/schema.rs"
generate_missing_sql_type_definitions = false
import_types = ["diesel::sql_types::*", "diesel_ltree::sql_types::Ltree"]
And then the schema generated by diesel will work fine.
Edit: If you need the functionality provided by Diesel automatically generating missing types, an alternative is to use the patch file functionality described in the Diesel CLI docs. Using the patch file, I can target specific lines in schema.rs
to replace the auto-generated ltree type with the one provided by this library.
from diesel_ltree.
Can you let me know how I can reproduce this same compile error locally? What do your project's Cargo.toml
and Cargo.lock
look like? (or at least all the lines related to Diesel/diesel_ltree.) What line of which file is actually shown there?
I've spent half an hour trying to reproduce what I thought the problem would be, given what you've described, but no luck. Let me know!
from diesel_ltree.
I ran into this problem, given the lack of MWE I think I can help out by contributing one. The problem here seems to be with how diesel_ltree
interacts with the code generated by Diesel. In my MWE, this table
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
tree_path LTREE NOT NULL
);
Ends up creating the following schema.rs
:
// @generated automatically by Diesel CLI.
pub mod sql_types {
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "ltree"))]
pub struct Ltree;
}
diesel::table! {
use diesel::sql_types::*;
use super::sql_types::Ltree;
foo (id) {
id -> Int4,
tree_path -> Ltree,
}
}
And in its current state, if you attempt to do anything with the foo
table (select, insert etc) you will end up with the errors reported by the poster. If you replace use super::sql_types::Ltree;
with diesel_ltree::sql_types::Ltree;
, all of the traits implemented by diesel_ltree
are picked up and everything works fine.
from diesel_ltree.
Oof, I see. It looks like this is the best we can do with print_schema
, so I'd say import_types
+ patch_file
is indeed the path forward for such uses.
In #25 I'm updating the built-in tests to use this instead of issuing table!
manually.
@TheConner — thank you so much for putting that example together! I appreciate it a heap. ❤️
from diesel_ltree.
Related Issues (12)
- Retrieve the Ltree data naturally HOT 3
- Bring binary support to cargo.io? HOT 5
- no binary output function available for type ltree in version 0.2.5
- cannot insert ltree into postgres 13, missing version HOT 3
- How to query for descendents and ancestors? IE `@>` and `<@` HOT 2
- Array operators
- Contains_any with subquery as input is not possible
- HasSqlType impls are incorrect HOT 1
- `coerce_from_type!` is redundant HOT 2
- Most operators are redundant with those from Diesel HOT 1
- Ltree doesn't implement Insertable HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diesel_ltree.