File tree Expand file tree Collapse file tree 6 files changed +61
-60
lines changed Expand file tree Collapse file tree 6 files changed +61
-60
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ RUN curl -sSL https://www.sqlite.org/2024/sqlite-autoconf-$SQLITE_VER.tar.gz | t
138138# See https://github.com/sgrif/pq-sys/pull/18
139139ENV PATH=/root/.cargo/bin:$PREFIX/bin:$PATH \
140140 RUSTUP_HOME=/root/.rustup \
141- CARGO_BUILD_TARGET=x86_64-unknown-linux-musl \
141+ CARGO_BUILD_TARGET=x86_64-unknown-linux-musl \
142142 PKG_CONFIG_ALLOW_CROSS=true \
143143 PKG_CONFIG_ALL_STATIC=true \
144144 PQ_LIB_STATIC_X86_64_UNKNOWN_LINUX_MUSL=true \
Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ name = "dieselpgcrate"
44version = " 0.1.0"
55
66[dependencies ]
7- diesel = { version = " 1.4 .*" , features = [" postgres" ] }
7+ diesel = { version = " 2.1 .*" , features = [" postgres" ] }
88openssl = " *"
Original file line number Diff line number Diff line change 11// The order of these extern crate lines matter for ssl!
22extern crate openssl;
3- #[ macro_use] extern crate diesel;
3+ #[ macro_use]
4+ extern crate diesel;
45// openssl must be included before diesel atm.
56
67mod schema {
7- table ! {
8- posts ( id) {
9- id -> Int4 ,
10- title -> Varchar ,
11- body -> Text ,
12- published -> Bool ,
13- }
14- }
8+ table ! {
9+ posts ( id) {
10+ id -> Int4 ,
11+ title -> Varchar ,
12+ body -> Text ,
13+ published -> Bool ,
14+ }
15+ }
1516}
1617
1718mod models {
18- use schema:: posts;
19- #[ derive( Queryable ) ]
20- pub struct Post {
21- pub id : i32 ,
22- pub title : String ,
23- pub body : String ,
24- pub published : bool ,
25- }
19+ use schema:: posts;
20+ #[ derive( Queryable ) ]
21+ pub struct Post {
22+ pub id : i32 ,
23+ pub title : String ,
24+ pub body : String ,
25+ pub published : bool ,
26+ }
2627
27- // apparently this can be done without heap storage, but lifetimes spread far..
28- #[ derive( Insertable ) ]
29- # [ table_name= " posts" ]
30- pub struct NewPost {
31- pub title : String ,
32- pub body : String ,
33- }
28+ // apparently this can be done without heap storage, but lifetimes spread far..
29+ #[ derive( Insertable ) ]
30+ # [ diesel ( table_name = posts) ]
31+ pub struct NewPost {
32+ pub title : String ,
33+ pub body : String ,
34+ }
3435}
3536
36- use diesel:: prelude:: * ;
3737use diesel:: pg:: PgConnection ;
38+ use diesel:: prelude:: * ;
3839
3940fn main ( ) {
4041 let database_url = std:: env:: var ( "DATABASE_URL" )
41- . unwrap_or ( "postgres://localhost?connect_timeout=1&sslmode=require" . into ( ) ) ;
42+ . unwrap_or ( "postgres://localhost?connect_timeout=1&sslmode=require" . into ( ) ) ;
4243 match PgConnection :: establish ( & database_url) {
43- Err ( e) => {
44- println ! ( "Should fail to connect here:" ) ;
45- println ! ( "{}" , e) ;
46- }
47- Ok ( _) => {
48- unreachable ! ( ) ;
49- }
44+ Err ( e) => {
45+ println ! ( "Should fail to connect here:" ) ;
46+ println ! ( "{}" , e) ;
47+ }
48+ Ok ( _) => {
49+ unreachable ! ( ) ;
50+ }
5051 }
5152}
Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ name = "dieselsqlitecrate"
44version = " 0.1.0"
55
66[dependencies ]
7- diesel = { version = " 1.4 .*" , features = [" sqlite" ] }
7+ diesel = { version = " 2.1 .*" , features = [" sqlite" ] }
Original file line number Diff line number Diff line change 22extern crate diesel;
33
44mod schema {
5- table ! {
6- posts ( id) {
7- id -> Int4 ,
8- title -> Varchar ,
9- body -> Text ,
10- published -> Bool ,
11- }
12- }
5+ table ! {
6+ posts ( id) {
7+ id -> Int4 ,
8+ title -> Varchar ,
9+ body -> Text ,
10+ published -> Bool ,
11+ }
12+ }
1313}
1414
1515mod models {
16- use schema:: posts;
17- #[ derive( Queryable ) ]
18- pub struct Post {
19- pub id : i32 ,
20- pub title : String ,
21- pub body : String ,
22- pub published : bool ,
23- }
16+ use schema:: posts;
17+ #[ derive( Queryable ) ]
18+ pub struct Post {
19+ pub id : i32 ,
20+ pub title : String ,
21+ pub body : String ,
22+ pub published : bool ,
23+ }
2424
25- // apparently this can be done without heap storage, but lifetimes spread far..
26- #[ derive( Insertable ) ]
27- # [ table_name= " posts" ]
28- pub struct NewPost {
29- pub title : String ,
30- pub body : String ,
31- }
25+ // apparently this can be done without heap storage, but lifetimes spread far..
26+ #[ derive( Insertable ) ]
27+ # [ diesel ( table_name = posts) ]
28+ pub struct NewPost {
29+ pub title : String ,
30+ pub body : String ,
31+ }
3232}
3333
3434use diesel:: prelude:: * ;
Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ name = "pqcrate"
44version = " 0.1.0"
55
66[dependencies ]
7- pq-sys = " 0.4. 5"
7+ pq-sys = " 0.5"
88openssl = " *"
You can’t perform that action at this time.
0 commit comments