Skip to content

Commit

Permalink
Fixing deprecation of ViewMappings
Browse files Browse the repository at this point in the history
It turns out you can't #[deprecated] a re-export -- it won't generate a
warning when it is used. Using a type alias fixes this.
  • Loading branch information
ecton committed Sep 13, 2023
1 parent e9b3b35 commit 2a05301
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
26 changes: 18 additions & 8 deletions crates/bonsaidb-core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ use crate::document::{
};
use crate::key::{ByteSource, IntoPrefixRange, Key, KeyEncoding, KeyKind, KeyVisitor};
use crate::permissions::Permissions;
use crate::schema::view::map::MappedDocuments;
#[deprecated(
since = "0.5.0",
note = "ViewMappings has been moved to bonsaidb_core::schema::view::ViewMappings"
)]
pub use crate::schema::view::map::ViewMappings;
use crate::schema::view::map::{MappedDocuments, ViewMappings as ViewMappingsCurrent};
use crate::schema::{
self, MappedValue, Nameable, NamedReference, Schema, SchemaName, SchemaSummary,
SerializedCollection,
Expand Down Expand Up @@ -913,7 +908,7 @@ where
/// # Ok(())
/// # }
/// ```
pub fn query(self) -> Result<ViewMappings<V>, Error> {
pub fn query(self) -> Result<ViewMappingsCurrent<V>, Error> {
self.connection
.query::<V, Key>(self.key, self.sort, self.limit, self.access_policy)
}
Expand Down Expand Up @@ -2126,7 +2121,7 @@ where
/// # })
/// # }
/// ```
pub async fn query(self) -> Result<ViewMappings<V>, Error> {
pub async fn query(self) -> Result<ViewMappingsCurrent<V>, Error> {
self.connection
.query::<V, Key>(self.key, self.sort, self.limit, self.access_policy)
.await
Expand Down Expand Up @@ -3873,3 +3868,18 @@ pub enum IdentityId {
/// A [`Role`](crate::admin::Role) id.
Role(u64),
}

/// This type is the result of `query()`. It is a list of mappings, which
/// contains:
///
/// - The key emitted during the map function.
/// - The value emitted during the map function.
/// - The source document header that the mappings originated from.
///
/// This type alias is being moved to [`schema::view::map::ViewMappings`] and
/// will be removed in v0.6.0.
#[deprecated(
since = "0.5.0",
note = "ViewMappings has been moved to bonsaidb_core::schema::view::ViewMappings"
)]
pub type ViewMappings<V> = schema::view::map::ViewMappings<V>;
6 changes: 4 additions & 2 deletions crates/bonsaidb-core/src/connection/lowlevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ use async_trait::async_trait;

use super::GroupedReductions;
use crate::connection::{
AccessPolicy, HasSession, QueryKey, Range, RangeRef, SerializedQueryKey, Sort, ViewMappings,
AccessPolicy, HasSession, QueryKey, Range, RangeRef, SerializedQueryKey, Sort,
};
use crate::document::{
CollectionDocument, CollectionHeader, Document, DocumentId, HasHeader, Header, OwnedDocument,
};
use crate::key::{self, ByteSource, Key, KeyEncoding};
use crate::schema::view::map::{CollectionMap, MappedDocuments, MappedSerializedValue};
use crate::schema::view::map::{
CollectionMap, MappedDocuments, MappedSerializedValue, ViewMappings,
};
use crate::schema::view::{self};
use crate::schema::{self, CollectionName, MappedValue, Schematic, SerializedCollection, ViewName};
use crate::transaction::{OperationResult, Transaction};
Expand Down

0 comments on commit 2a05301

Please sign in to comment.