Skip to content

Commit

Permalink
feat: integrate mongodb fix for ipv6 (prisma#4981)
Browse files Browse the repository at this point in the history
  • Loading branch information
laplab authored Aug 20, 2024
1 parent cb8fbf2 commit c356d1b
Show file tree
Hide file tree
Showing 33 changed files with 166 additions and 142 deletions.
232 changes: 129 additions & 103 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ wasm-bindgen-test = { version = "0.3.0" }
url = { version = "2.5.0" }

bson = { version = "2.11.0", features = ["chrono-0_4", "uuid-1"] }
mongodb = "3"
mongodb = { git = "https://github.com/prisma/mongo-rust-driver.git", branch = "RUST-1994/happy-eyeballs" }

[workspace.dependencies.quaint]
path = "quaint"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{orderby::OrderByData, IntoBson};
use mongodb::bson::{doc, Document};
use bson::{doc, Document};
use query_structure::{OrderBy, SelectionResult, SortOrder};

#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{constants::group_by, error::MongoError, join::JoinStage, query_builder::AggregationType, IntoBson};
use mongodb::bson::{doc, Bson, Document};
use bson::{doc, Bson, Document};
use query_structure::*;

#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::filter::MongoFilter;
use mongodb::bson::{doc, Document};
use bson::{doc, Document};
use query_structure::{walkers, RelationFieldRef, ScalarFieldRef};

/// A join stage describes a tree of joins and nested joins to be performed on a collection.
Expand Down
7 changes: 3 additions & 4 deletions query-engine/connectors/mongodb-query-connector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ mod query_strings;
mod root_queries;
mod value;

use bson::Bson;
use bson::Document;
use error::MongoError;
use mongodb::{
bson::{Bson, Document},
ClientSession, SessionCursor,
};
use mongodb::{ClientSession, SessionCursor};

pub use interface::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::join::JoinStage;
use bson::{doc, Document};
use itertools::Itertools;
use mongodb::bson::{doc, Document};
use query_structure::{OrderBy, OrderByHop, OrderByToManyAggregation, SortOrder};
use std::{fmt::Display, iter};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::IntoBson;
use mongodb::bson::{Bson, Document};
use bson::{Bson, Document};
use query_structure::{FieldSelection, SelectedField};

/// Used as projection document for Mongo queries.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::constants::*;

use bson::{doc, Bson, Document};
use connector_interface::AggregationSelection;
use mongodb::bson::{doc, Bson, Document};
use query_structure::{AggregationFilter, Filter, ScalarFieldRef};
use std::collections::HashSet;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ use crate::{
root_queries::observing,
vacuum_cursor, BsonTransform, IntoBson,
};
use bson::{doc, Document};
use connector_interface::AggregationSelection;
use itertools::Itertools;
use mongodb::{
bson::{doc, Document},
options::AggregateOptions,
ClientSession, Collection,
};
use mongodb::{options::AggregateOptions, ClientSession, Collection};
use query_structure::{FieldSelection, Filter, Model, QueryArguments, ScalarFieldRef, VirtualSelection};
use std::convert::TryFrom;
use std::future::IntoFuture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//! There is a struct for each different type of query to generate. Each of them implement the
//! QueryStringBuilder trait, which is dynamically dispatched to a specific query string builder by
//! `root_queries::observing`
use bson::{Bson, Document};
use derive_more::Constructor;
use mongodb::bson::{Bson, Document};
use std::fmt::Write;

pub(crate) trait QueryString: Sync + Send {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::query_strings::QueryString;
use crate::{
error::DecorateErrorWithFieldInformationExtension, output_meta::OutputMetaMapping, value::value_from_bson,
};
use bson::Bson;
use bson::Document;
use futures::Future;
use mongodb::bson::Bson;
use mongodb::bson::Document;
use query_engine_metrics::{
histogram, increment_counter, metrics, PRISMA_DATASOURCE_QUERIES_DURATION_HISTOGRAM_MS,
PRISMA_DATASOURCE_QUERIES_TOTAL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::{into_expression::IntoUpdateExpression, operation};

use bson::{doc, Bson, Document};
use connector_interface::FieldPath;
use indexmap::IndexMap;
use mongodb::bson::{doc, Bson, Document};

/// `UpdateExpression` is an intermediary AST that's used to represent MongoDB expressions.
/// It is meant to be transformed into `BSON`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::expression::*;
use crate::IntoBson;

use bson::{doc, Bson, Document};
use itertools::Itertools;
use mongodb::bson::{doc, Bson, Document};

impl IntoBson for Set {
fn into_bson(self) -> crate::Result<Bson> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::{expression::*, operation::*};
use crate::{filter, IntoBson};

use bson::{doc, Bson};
use itertools::Itertools;
use mongodb::bson::{doc, Bson};

pub(crate) trait IntoUpdateExpression {
fn into_update_expression(self) -> crate::Result<UpdateExpression>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::operation::*;
use crate::*;

use bson::doc;
use connector_interface::{CompositeWriteOperation, FieldPath, ScalarWriteOperation, WriteOperation};
use mongodb::bson::doc;
use query_structure::{Field, PrismaValue};

pub(crate) trait IntoUpdateOperation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ mod operation;
use super::*;
use crate::*;

use bson::Document;
use connector_interface::{FieldPath, WriteOperation};
use into_expression::IntoUpdateExpressions;
use into_operation::IntoUpdateOperation;
use mongodb::bson::Document;

pub(crate) trait IntoUpdateDocumentExtension {
fn into_update_docs(self, field: &Field, path: FieldPath) -> crate::Result<Vec<Document>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{expression, into_expression::IntoUpdateExpression};
use bson::{doc, Document};
use connector_interface::FieldPath;
use mongodb::bson::{doc, Document};
use query_structure::Filter;

/// `UpdateOperation` is an intermediary AST used to perform preliminary transformations from a `WriteOperation`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::{
IntoBson, MongoError,
};
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
use bson::{oid::ObjectId, spec::BinarySubtype, Binary, Bson, Document, Timestamp};
use chrono::{TimeZone, Utc};
use itertools::Itertools;
use mongodb::bson::{oid::ObjectId, spec::BinarySubtype, Binary, Bson, Document, Timestamp};
use psl::builtin_connectors::MongoDbType;
use query_structure::{
CompositeFieldRef, Field, PrismaValue, RelationFieldRef, ScalarFieldRef, SelectedField, TypeIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ user-facing-errors = { path = "../../../libs/user-facing-errors", features = [
enumflags2.workspace = true
futures = "0.3"
mongodb.workspace = true
bson.workspace = true
serde_json.workspace = true
tokio.workspace = true
tracing.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
migration::{MongoDbMigration, MongoDbMigrationStep},
MongoDbSchemaConnector,
};
use mongodb::bson::{self, Bson, Document};
use bson::{self, Bson, Document};
use schema_connector::{ConnectorResult, Migration, SchemaConnector};

impl MongoDbSchemaConnector {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::statistics::Name;
use mongodb::bson::Bson;
use bson::Bson;
use std::fmt;

#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use schema_connector::{
};

use super::field_type::FieldType;
use bson::{Bson, Document};
use convert_case::{Case, Casing};
use datamodel_renderer as renderer;
use mongodb::bson::{Bson, Document};
use mongodb_schema_describer::{CollectionWalker, IndexWalker};
use once_cell::sync::Lazy;
use psl::datamodel_connector::constraint_names::ConstraintNames;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::introspection::test_api::*;
use mongodb::bson::{doc, Bson, DateTime, Timestamp};
use bson::{doc, Bson, DateTime, Timestamp};

#[test]
fn explicit_id_field() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::introspection::test_api::*;
use mongodb::bson::doc;
use bson::doc;

#[test]
fn a_model_with_reserved_name() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::introspection::test_api::*;
use mongodb::bson::doc;
use bson::doc;

// Composite types
// reintrospect_removed_model_single_file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::introspection::test_api::*;
use mongodb::bson::doc;
use bson::doc;

#[test]
fn remapping_fields_with_invalid_characters() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::introspection::test_api::*;
use mongodb::bson::{doc, oid::ObjectId, Bson};
use bson::{doc, oid::ObjectId, Bson};
use schema_connector::CompositeTypeDepth;

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod composite;

use crate::introspection::test_api::*;
use mongodb::bson::{doc, oid::ObjectId, Binary, Bson, DateTime, Decimal128, Timestamp};
use bson::{doc, oid::ObjectId, Binary, Bson, DateTime, Decimal128, Timestamp};

#[test]
fn string() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bson::{self, doc};
use enumflags2::BitFlags;
use futures::TryStreamExt;
use mongodb::bson::{self, doc};
use mongodb_schema_connector::MongoDbSchemaConnector;
use once_cell::sync::Lazy;
use psl::{parser_database::SourceFile, PreviewFeature};
Expand Down
1 change: 1 addition & 0 deletions schema-engine/mongodb-schema-describer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ edition = "2021"

[dependencies]
mongodb.workspace = true
bson.workspace = true
futures = "0.3"
serde.workspace = true
4 changes: 2 additions & 2 deletions schema-engine/mongodb-schema-describer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ mod walkers;
pub use schema::*;
pub use walkers::*;

use bson::{Bson, Document};
use futures::stream::TryStreamExt;
use mongodb::bson::{Bson, Document};

/// Describe the contents of the given database. Only bothers about the schema, meaning the
/// collection names and indexes created. Does a bit of magic to the indexes, so if having a
Expand Down Expand Up @@ -122,7 +122,7 @@ pub async fn describe(client: &mongodb::Client, db_name: &str) -> mongodb::error
/// Get the version.
pub async fn version(client: &mongodb::Client, db_name: &str) -> mongodb::error::Result<String> {
let database = client.database(db_name);
use mongodb::bson::doc;
use bson::doc;
let version_cmd = doc! {"buildInfo": 1};
let res = database.run_command(version_cmd).await?;
let version = res
Expand Down
2 changes: 1 addition & 1 deletion schema-engine/mongodb-schema-describer/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use mongodb::bson::Bson;
use bson::Bson;
use serde::{Deserialize, Serialize};
use std::{
collections::BTreeMap,
Expand Down

0 comments on commit c356d1b

Please sign in to comment.