Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln authored Jul 24, 2023
2 parents b9c3081 + 6a4762d commit 5444263
Show file tree
Hide file tree
Showing 44 changed files with 180 additions and 214 deletions.
8 changes: 2 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ members = [
"query-engine/black-box-tests",
"query-engine/dmmf",
"query-engine/metrics",
"query-engine/js-drivers",
"query-engine/js-connectors",
"query-engine/prisma-models",
"query-engine/query-engine",
"query-engine/query-engine-node-api",
Expand Down
8 changes: 0 additions & 8 deletions libs/context/Cargo.toml

This file was deleted.

87 changes: 0 additions & 87 deletions libs/context/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions psl/psl-core/src/common/preview_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ features!(
NamedConstraints,
NApi,
NativeTypes,
NodeDrivers,
JsConnectors,
OrderByAggregateGroup,
OrderByNulls,
OrderByRelation,
Expand Down Expand Up @@ -124,7 +124,7 @@ pub const ALL_PREVIEW_FEATURES: FeatureMap = FeatureMap {
| UncheckedScalarInputs
}),
hidden: enumflags2::make_bitflags!(PreviewFeature::{
NodeDrivers
JsConnectors
}),
};

Expand Down
2 changes: 1 addition & 1 deletion quaint/src/ast/function/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn uuid_to_bin_swapped() -> Expression<'static> {
/// # Ok(())
/// # }
/// ```
#[cfg(any(feature = "mysql"))]
#[cfg(feature = "mysql")]
pub fn native_uuid() -> Expression<'static> {
let func = Function {
typ_: FunctionType::Uuid,
Expand Down
8 changes: 4 additions & 4 deletions quaint/src/connector/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,16 +603,16 @@ mod tests {
fn should_parse_prefer_socket() {
let url =
MysqlUrl::new(Url::parse("mysql://root:root@localhost:3307/testdb?prefer_socket=false").unwrap()).unwrap();
assert_eq!(false, url.prefer_socket().unwrap());
assert!(!url.prefer_socket().unwrap());
}

#[test]
fn should_parse_sslaccept() {
let url =
MysqlUrl::new(Url::parse("mysql://root:root@localhost:3307/testdb?sslaccept=strict").unwrap()).unwrap();
assert_eq!(true, url.query_params.use_ssl);
assert_eq!(false, url.query_params.ssl_opts.skip_domain_validation());
assert_eq!(false, url.query_params.ssl_opts.accept_invalid_certs());
assert!(url.query_params.use_ssl);
assert!(!url.query_params.ssl_opts.skip_domain_validation());
assert!(!url.query_params.ssl_opts.accept_invalid_certs());
}

#[test]
Expand Down
53 changes: 25 additions & 28 deletions quaint/src/connector/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1501,41 +1501,38 @@ mod tests {
#[test]
fn test_safe_ident() {
// Safe
assert_eq!(is_safe_identifier("hello"), true);
assert_eq!(is_safe_identifier("_hello"), true);
assert_eq!(is_safe_identifier("àbracadabra"), true);
assert_eq!(is_safe_identifier("h3ll0"), true);
assert_eq!(is_safe_identifier("héllo"), true);
assert_eq!(is_safe_identifier("héll0$"), true);
assert_eq!(is_safe_identifier("héll_0$"), true);
assert_eq!(
is_safe_identifier("disconnect_security_must_honor_connect_scope_one2m"),
true
);
assert!(is_safe_identifier("hello"));
assert!(is_safe_identifier("_hello"));
assert!(is_safe_identifier("àbracadabra"));
assert!(is_safe_identifier("h3ll0"));
assert!(is_safe_identifier("héllo"));
assert!(is_safe_identifier("héll0$"));
assert!(is_safe_identifier("héll_0$"));
assert!(is_safe_identifier("disconnect_security_must_honor_connect_scope_one2m"));

// Not safe
assert_eq!(is_safe_identifier(""), false);
assert_eq!(is_safe_identifier("Hello"), false);
assert_eq!(is_safe_identifier("hEllo"), false);
assert_eq!(is_safe_identifier("$hello"), false);
assert_eq!(is_safe_identifier("hello!"), false);
assert_eq!(is_safe_identifier("hello#"), false);
assert_eq!(is_safe_identifier("he llo"), false);
assert_eq!(is_safe_identifier(" hello"), false);
assert_eq!(is_safe_identifier("he-llo"), false);
assert_eq!(is_safe_identifier("hÉllo"), false);
assert_eq!(is_safe_identifier("1337"), false);
assert_eq!(is_safe_identifier("_HELLO"), false);
assert_eq!(is_safe_identifier("HELLO"), false);
assert_eq!(is_safe_identifier("HELLO$"), false);
assert_eq!(is_safe_identifier("ÀBRACADABRA"), false);
assert!(!is_safe_identifier(""));
assert!(!is_safe_identifier("Hello"));
assert!(!is_safe_identifier("hEllo"));
assert!(!is_safe_identifier("$hello"));
assert!(!is_safe_identifier("hello!"));
assert!(!is_safe_identifier("hello#"));
assert!(!is_safe_identifier("he llo"));
assert!(!is_safe_identifier(" hello"));
assert!(!is_safe_identifier("he-llo"));
assert!(!is_safe_identifier("hÉllo"));
assert!(!is_safe_identifier("1337"));
assert!(!is_safe_identifier("_HELLO"));
assert!(!is_safe_identifier("HELLO"));
assert!(!is_safe_identifier("HELLO$"));
assert!(!is_safe_identifier("ÀBRACADABRA"));

for ident in RESERVED_KEYWORDS {
assert_eq!(is_safe_identifier(ident), false);
assert!(!is_safe_identifier(ident));
}

for ident in RESERVED_TYPE_FUNCTION_NAMES {
assert_eq!(is_safe_identifier(ident), false);
assert!(!is_safe_identifier(ident));
}
}

Expand Down
4 changes: 2 additions & 2 deletions quaint/src/tests/query/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ async fn unique_constraint_violation(api: &mut dyn TestApi) -> crate::Result<()>
let fields = fields.iter().map(|s| s.as_str()).collect::<Vec<_>>();
assert_eq!(vec!["id1", "id2"], fields)
}
DatabaseConstraint::ForeignKey => assert!(false, "Expecting index or field constraints."),
DatabaseConstraint::CannotParse => assert!(false, "Couldn't parse the error message."),
DatabaseConstraint::ForeignKey => panic!("Expecting index or field constraints."),
DatabaseConstraint::CannotParse => panic!("Couldn't parse the error message."),
},
_ => panic!("{}", err),
}
Expand Down
2 changes: 2 additions & 0 deletions quaint/src/tests/types/mssql.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::approx_constant)]

#[cfg(feature = "bigdecimal")]
mod bigdecimal;

Expand Down
2 changes: 2 additions & 0 deletions quaint/src/tests/types/mysql.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::approx_constant)]

use crate::tests::test_api::*;

#[cfg(feature = "bigdecimal")]
Expand Down
2 changes: 2 additions & 0 deletions quaint/src/tests/types/sqlite.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::approx_constant)]

use crate::tests::test_api::sqlite_test_api;
#[cfg(feature = "chrono")]
use crate::tests::test_api::TestApi;
Expand Down
2 changes: 1 addition & 1 deletion quaint/src/visitor/mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ mod tests {
(String::from(sql), params.into_iter().map(|p| p.into()).collect())
}

fn default_params<'a>(mut additional: Vec<Value<'a>>) -> Vec<Value<'a>> {
fn default_params(mut additional: Vec<Value<'_>>) -> Vec<Value<'_>> {
let mut result = Vec::new();

for param in additional.drain(0..) {
Expand Down
2 changes: 1 addition & 1 deletion quaint/src/visitor/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ mod tests {
(String::from(sql), params.into_iter().map(|p| p.into()).collect())
}

fn default_params<'a>(mut additional: Vec<Value<'a>>) -> Vec<Value<'a>> {
fn default_params(mut additional: Vec<Value<'_>>) -> Vec<Value<'_>> {
let mut result = Vec::new();

for param in additional.drain(0..) {
Expand Down
2 changes: 1 addition & 1 deletion quaint/src/visitor/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ mod tests {
(String::from(sql), params.into_iter().map(|p| p.into()).collect())
}

fn default_params<'a>(mut additional: Vec<Value<'a>>) -> Vec<Value<'a>> {
fn default_params(mut additional: Vec<Value<'_>>) -> Vec<Value<'_>> {
let mut result = Vec::new();

for param in additional.drain(0..) {
Expand Down
2 changes: 1 addition & 1 deletion quaint/src/visitor/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ mod tests {
(String::from(sql), params.into_iter().map(|p| p.into()).collect())
}

fn default_params<'a>(mut additional: Vec<Value<'a>>) -> Vec<Value<'a>> {
fn default_params(mut additional: Vec<Value<'_>>) -> Vec<Value<'_>> {
let mut result = Vec::new();

for param in additional.drain(0..) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,46 @@ mod singular_batch {
Ok(())
}

fn enum_id() -> String {
let schema = indoc! {
r#"
enum IdEnum {
A
B
}
model TestModel {
#id(id, IdEnum, @id)
}
"#
};

schema.to_owned()
}

#[connector_test(schema(enum_id), capabilities(Enums))]
async fn batch_enum(runner: Runner) -> TestResult<()> {
run_query!(&runner, r#"mutation { createOneTestModel(data: { id: "A" }) { id } }"#);
run_query!(&runner, r#"mutation { createOneTestModel(data: { id: "B" }) { id } }"#);

let (res, compact_doc) = compact_batch(
&runner,
vec![
r#"{ findUniqueTestModel(where: { id: "A" }) { id } }"#.to_string(),
r#"{ findUniqueTestModel(where: { id: "B" }) { id } }"#.to_string(),
],
)
.await?;

insta::assert_snapshot!(
res.to_string(),
@r###"{"batchResult":[{"data":{"findUniqueTestModel":{"id":"A"}}},{"data":{"findUniqueTestModel":{"id":"B"}}}]}"###
);
assert!(compact_doc.is_compact());

Ok(())
}

// Regression test for https://github.com/prisma/prisma/issues/16548
#[connector_test(schema(schemas::generic))]
async fn repro_16548(runner: Runner) -> TestResult<()> {
Expand Down
2 changes: 1 addition & 1 deletion query-engine/connectors/sql-query-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.1.0"

[features]
vendored-openssl = ["quaint/vendored-openssl"]
js-drivers = []
js-connectors = []

[dependencies]
psl.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(feature = "js-drivers")]
#[cfg(feature = "js-connectors")]
pub mod js;
mod runtime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl FromSource for Mysql {
features: psl::PreviewFeatures,
) -> connector_interface::Result<Mysql> {
if source.provider == "@prisma/mysql" {
#[cfg(feature = "js-drivers")]
#[cfg(feature = "js-connectors")]
{
let driver = super::js::registered_driver();
let connection_info = get_connection_info(url)?;
Expand All @@ -56,10 +56,10 @@ impl FromSource for Mysql {
});
}

#[cfg(not(feature = "js-drivers"))]
#[cfg(not(feature = "js-connectors"))]
{
return Err(ConnectorError::from_kind(ErrorKind::UnsupportedConnector(
"The @prisma/mysql connector requires the `nodeDrivers` preview feature to be enabled.".into(),
"The @prisma/mysql connector requires the `jsConnectors` preview feature to be enabled.".into(),
)));
}
}
Expand Down
Loading

0 comments on commit 5444263

Please sign in to comment.