Skip to content

Commit c5b9b49

Browse files
committed
remove stream logic b/c underlying sqlx bug is fixed
1 parent a40c049 commit c5b9b49

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

macro/src/codegen/insert.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ pub fn impl_Model__insert(db: &dyn OrmliteCodegen, attr: &ModelMeta, metadata_ca
5555
#(
5656
#query_bindings
5757
)*
58-
// using fetch instead of fetch_one because of https://github.com/launchbadge/sqlx/issues/1370
59-
let mut stream = q.fetch(&mut *conn);
60-
let mut model: Self = ::ormlite::StreamExt::try_next(&mut stream)
61-
.await?
62-
.ok_or_else(|| ::ormlite::Error::from(::ormlite::SqlxError::RowNotFound))?;
63-
::ormlite::StreamExt::try_next(&mut stream).await?;
58+
let mut model = q.fetch_one(&mut *conn).await?;
6459
#(
6560
#late_bind
6661
)*
@@ -100,12 +95,7 @@ pub fn impl_ModelBuilder__insert(db: &dyn OrmliteCodegen, attr: &TableMeta) -> T
10095
);
10196
let mut q = ::ormlite::query_as::<#db, Self::Model>(&query);
10297
#(#bind_parameters)*
103-
// using fetch instead of fetch_one because of https://github.com/launchbadge/sqlx/issues/1370
104-
let mut stream = q.fetch(db);
105-
let model = ::ormlite::StreamExt::try_next(&mut stream)
106-
.await?
107-
.ok_or_else(|| ::ormlite::Error::from(::ormlite::SqlxError::RowNotFound))?;
108-
::ormlite::StreamExt::try_next(&mut stream).await?;
98+
let mut model = q.fetch_one(db).await?;
10999
Ok(model)
110100
})
111101
}
@@ -172,11 +162,7 @@ pub fn impl_Insert(db: &dyn OrmliteCodegen, meta: &TableMeta, model: &Ident, ret
172162
let mut model = self;
173163
#(#insert_join)*
174164
#(#query_bindings)*
175-
let mut stream = q.fetch(&mut *conn);
176-
let mut model = ::ormlite::StreamExt::try_next(&mut stream)
177-
.await?
178-
.ok_or_else(|| ::ormlite::Error::from(::ormlite::SqlxError::RowNotFound))?;
179-
::ormlite::StreamExt::try_next(&mut stream).await?;
165+
let mut model = q.fetch_one(&mut *conn).await?;
180166
#(#late_bind)*
181167
Ok(model)
182168
})

0 commit comments

Comments
 (0)