Skip to content

Commit c4aa716

Browse files
committed
Revert macro re-export "fix"
(Doesn't actually help; mis-remembered how rustc handles these things)
1 parent f2ac4f5 commit c4aa716

File tree

6 files changed

+27
-32
lines changed

6 files changed

+27
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### v0.33.0
1+
### v0.34.0
22
- (Routine Maintenance) Updated `rusqlite` from `0.33` to `0.34`.
33
- This is a *breaking change,* requiring you to upgrade your `rusqlite` to match - trying to link against two different copies of `libsqlite3` will cause a compile fail.
44
- Fixed issue with macros failing if Rusqlite is not linked to the current crate.

exemplar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ all-features = true
1515
rustdoc-args = ["--cfg", "docsrs"]
1616

1717
[dependencies]
18-
exemplar_proc_macro = { version = "0.34.0" }
18+
exemplar_proc_macro = { path = "../exemplar_proc_macro" }
1919
rusqlite = "0.34"
2020

2121
[dev-dependencies]

exemplar/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ use rusqlite::types::{
9696
FromSqlResult
9797
};
9898

99-
// We re-export rusqlite to maximize macro compatibility.
100-
// (See https://github.com/Colonial-Dev/exemplar/issues/5)
101-
#[doc(hidden)]
102-
pub use rusqlite;
103-
10499
pub use crate::macros::*;
105100

106101
/// Type alias for the outcome of converting a value to an SQL-friendly representation.

exemplar/src/macros.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,17 @@ macro_rules! record {
214214
}
215215

216216
impl $name {
217-
fn from_row(row: &::exemplar::rusqlite::Row) -> ::exemplar::rusqlite::Result<Self> {
217+
fn from_row(row: &::rusqlite::Row) -> ::rusqlite::Result<Self> {
218218
Ok(Self {
219219
$($fname : row.get(stringify!($fname))?),*
220220
})
221221
}
222222
}
223223

224-
impl<'a> ::std::convert::TryFrom<&'a ::exemplar::rusqlite::Row<'_>> for $name {
225-
type Error = ::exemplar::rusqlite::Error;
224+
impl<'a> ::std::convert::TryFrom<&'a ::rusqlite::Row<'_>> for $name {
225+
type Error = ::rusqlite::Error;
226226

227-
fn try_from(value: &'a ::exemplar::rusqlite::Row) -> Result<Self, Self::Error> {
227+
fn try_from(value: &'a ::rusqlite::Row) -> Result<Self, Self::Error> {
228228
Self::from_row(value)
229229
}
230230
}
@@ -313,28 +313,28 @@ macro_rules! sql_enum {
313313
}
314314

315315
#[automatically_derived]
316-
impl ::exemplar::rusqlite::ToSql for $name {
317-
fn to_sql(&self) -> ::exemplar::rusqlite::Result<::exemplar::rusqlite::types::ToSqlOutput<'_>> {
318-
let value = ::exemplar::rusqlite::types::Value::Integer(*self as i64);
319-
let value = ::exemplar::rusqlite::types::ToSqlOutput::Owned(value);
316+
impl ::rusqlite::ToSql for $name {
317+
fn to_sql(&self) -> ::rusqlite::Result<::rusqlite::types::ToSqlOutput<'_>> {
318+
let value = ::rusqlite::types::Value::Integer(*self as i64);
319+
let value = ::rusqlite::types::ToSqlOutput::Owned(value);
320320
Ok(value)
321321
}
322322
}
323323

324324
#[automatically_derived]
325-
impl ::exemplar::rusqlite::types::FromSql for $name {
326-
fn column_result(value: ::exemplar::rusqlite::types::ValueRef<'_>) -> ::exemplar::rusqlite::types::FromSqlResult<Self> {
325+
impl ::rusqlite::types::FromSql for $name {
326+
fn column_result(value: ::rusqlite::types::ValueRef<'_>) -> ::rusqlite::types::FromSqlResult<Self> {
327327
value.as_i64()
328328
.map(<$name>::try_from)?
329329
.map_err(|err| {
330-
::exemplar::rusqlite::types::FromSqlError::Other(Box::new(err))
330+
::rusqlite::types::FromSqlError::Other(Box::new(err))
331331
})
332332
}
333333
}
334334

335335
#[automatically_derived]
336336
impl ::std::convert::TryFrom<i64> for $name {
337-
type Error = ::exemplar::rusqlite::types::FromSqlError;
337+
type Error = ::rusqlite::types::FromSqlError;
338338

339339
fn try_from(value: i64) -> Result<Self, Self::Error> {
340340
match value {
@@ -345,7 +345,7 @@ macro_rules! sql_enum {
345345
stringify!($name)
346346
);
347347

348-
Err(::exemplar::rusqlite::types::FromSqlError::Other(
348+
Err(::rusqlite::types::FromSqlError::Other(
349349
msg.into()
350350
))
351351
}

exemplar_proc_macro/src/codegen.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn from_row(derivee: &Derivee) -> QuoteStream {
2222

2323
quote! {
2424
#[inline]
25-
fn from_row(row: &::exemplar::rusqlite::Row) -> ::exemplar::rusqlite::Result<Self>
25+
fn from_row(row: &::rusqlite::Row) -> ::rusqlite::Result<Self>
2626
where
2727
Self: ::std::marker::Sized,
2828
{
@@ -64,15 +64,15 @@ pub fn inserts(derivee: &Derivee) -> QuoteStream {
6464

6565
quote! {
6666
#[inline]
67-
fn insert(&self, conn: &::exemplar::rusqlite::Connection) -> ::exemplar::rusqlite::Result<()> {
67+
fn insert(&self, conn: &::rusqlite::Connection) -> ::rusqlite::Result<()> {
6868
self.insert_or(conn, ::exemplar::OnConflict::Abort)
6969
}
7070

7171
#[inline]
72-
fn insert_or(&self, conn: &::exemplar::rusqlite::Connection, strategy: ::exemplar::OnConflict) -> ::exemplar::rusqlite::Result<()> {
72+
fn insert_or(&self, conn: &::rusqlite::Connection, strategy: ::exemplar::OnConflict) -> ::rusqlite::Result<()> {
7373
use ::exemplar::OnConflict::*;
7474

75-
let exec = |sql: &str| -> ::exemplar::rusqlite::Result<()> {
75+
let exec = |sql: &str| -> ::rusqlite::Result<()> {
7676
let mut stmt = conn.prepare_cached(sql)?;
7777

7878
stmt.execute(rusqlite::named_params! {
@@ -92,7 +92,7 @@ pub fn inserts(derivee: &Derivee) -> QuoteStream {
9292
}
9393

9494
#[inline]
95-
fn insert_with(&self, stmt: &mut::exemplar::rusqlite::Statement) -> ::exemplar::rusqlite::Result<()> {
95+
fn insert_with(&self, stmt: &mut::rusqlite::Statement) -> ::rusqlite::Result<()> {
9696
stmt.execute(rusqlite::named_params! {
9797
#(#col_names: #field_idents),*
9898
})?;
@@ -116,17 +116,17 @@ pub fn to_params(derivee: &Derivee) -> QuoteStream {
116116
.map(|(ident, field)| {
117117
if let Some(bind) = util::get_bind_path(field) {
118118
// If the field has a #[bind] attribute, then we execute it now and box the result.
119-
quote! { Boxed(Box::new(#bind(&self.#ident)?) as Box<dyn ::exemplar::rusqlite::ToSql>) }
119+
quote! { Boxed(Box::new(#bind(&self.#ident)?) as Box<dyn ::rusqlite::ToSql>) }
120120
}
121121
else {
122122
// Otherwise, we're good to just borrow directly from self and cast to a dyn ToSql.
123-
quote! { Borrowed(&self.#ident as &dyn ::exemplar::rusqlite::ToSql) }
123+
quote! { Borrowed(&self.#ident as &dyn ::rusqlite::ToSql) }
124124
}
125125
});
126126

127127
quote! {
128128
#[inline]
129-
fn to_params(&self) -> ::exemplar::rusqlite::Result<::exemplar::Parameters> {
129+
fn to_params(&self) -> ::rusqlite::Result<::exemplar::Parameters> {
130130
use ::std::boxed::Box;
131131
use ::exemplar::Parameter::*;
132132

@@ -206,7 +206,7 @@ pub fn check_test(derivee: &Derivee) -> QuoteStream {
206206
#[test]
207207
fn #func() {
208208
use ::std::collections::HashSet;
209-
use ::exemplar::rusqlite::Connection;
209+
use ::rusqlite::Connection;
210210

211211
let schema = include_str!(#path);
212212

exemplar_proc_macro/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ pub fn derive_model(input: TokenStream) -> TokenStream {
8585
}
8686

8787
#[automatically_derived]
88-
impl<'a> ::std::convert::TryFrom<&'a ::exemplar::rusqlite::Row<'_>> for #name {
89-
type Error = ::exemplar::rusqlite::Error;
88+
impl<'a> ::std::convert::TryFrom<&'a ::rusqlite::Row<'_>> for #name {
89+
type Error = ::rusqlite::Error;
9090

91-
fn try_from(value: &'a ::exemplar::rusqlite::Row) -> Result<Self, Self::Error> {
91+
fn try_from(value: &'a ::rusqlite::Row) -> Result<Self, Self::Error> {
9292
Self::from_row(value)
9393
}
9494
}

0 commit comments

Comments
 (0)