Skip to content

Commit

Permalink
chore: merge main, fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Jan 18, 2024
2 parents 94ce58a + 9c3f205 commit 5c99c02
Show file tree
Hide file tree
Showing 26 changed files with 179 additions and 135 deletions.
12 changes: 6 additions & 6 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ else
export INIT_WAIT_SEC="2"
fi

# Source the gitignored .envrc.local if it exists.
if test -f .envrc.local; then
watch_file .envrc.local
source .envrc.local
fi

# (Example env vars if you're not using the make commands, i.e. the config files, to set up query engine tests)
# export TEST_RUNNER="direct"
# export TEST_CONNECTOR="postgres"
Expand All @@ -50,9 +56,3 @@ then
use flake
fi
fi

# Source the gitignored .envrc.local if it exists.
if test -f .envrc.local; then
watch_file .envrc.local
source .envrc.local
fi
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CONFIG_FILE = .test_config
SCHEMA_EXAMPLES_PATH = ./query-engine/example_schemas
DEV_SCHEMA_FILE = dev_datamodel.prisma
DRIVER_ADAPTERS_BRANCH ?= main
NIX := $(shell command -v nix 2> /dev/null)
NIX := $(shell type nix 2> /dev/null)

LIBRARY_EXT := $(shell \
case "$$(uname -s)" in \
Expand Down Expand Up @@ -335,6 +335,10 @@ else
cd query-engine/query-engine-wasm && ./build.sh
endif

measure-qe-wasm: build-qe-wasm
@cd query-engine/query-engine-wasm/pkg; \
gzip -k -c query_engine_bg.wasm | wc -c | awk '{$$1/=(1024*1024); printf "Current wasm query-engine size compressed: %.3fMB\n", $$1}'

build-driver-adapters-kit: build-driver-adapters
cd query-engine/driver-adapters && pnpm i && pnpm build

Expand Down
6 changes: 6 additions & 0 deletions libs/user-facing-errors/src/quaint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ pub fn render_quaint_error(kind: &ErrorKind, connection_info: &ConnectionInfo) -
database_host: url.host().to_owned(),
}))
}
(NativeErrorKind::ConnectionError(_), ConnectionInfo::Native(NativeConnectionInfo::Mssql(url))) => {
Some(KnownError::new(common::DatabaseNotReachable {
database_port: url.port(),
database_host: url.host().to_owned(),
}))
}
(NativeErrorKind::TlsError { message }, _) => Some(KnownError::new(common::TlsConnectionError {
message: message.into(),
})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ const CAPABILITIES: ConnectorCapabilities = enumflags2::make_bitflags!(Connector
NativeUpsert |
FilteredInlineChildNestedToOneDisconnect |
RowIn |
// InsertReturning, DeleteReturning, UpdateReturning - While SQLite does support RETURNING, it does not return column information on the
// way back from the database. This column type information is necessary in order to preserve consistency for some data types such as int,
// where values could overflow.
// Since we care to stay consistent with reads, it is not enabled.
InsertReturning |
DeleteReturning |
UpdateReturning |
SupportsFiltersOnRelationsWithoutJoins
});

Expand Down
35 changes: 35 additions & 0 deletions quaint/src/visitor/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,41 @@ impl<'a> Visitor<'a> for Sqlite<'a> {

Ok(())
}

fn visit_update(&mut self, update: Update<'a>) -> visitor::Result {
self.write("UPDATE ")?;
self.visit_table(update.table, true)?;

{
self.write(" SET ")?;
let pairs = update.columns.into_iter().zip(update.values);
let len = pairs.len();

for (i, (key, value)) in pairs.enumerate() {
self.visit_column(key)?;
self.write(" = ")?;
self.visit_expression(value)?;

if i < (len - 1) {
self.write(", ")?;
}
}
}

if let Some(conditions) = update.conditions {
self.write(" WHERE ")?;
self.visit_conditions(conditions)?;
}

self.returning(update.returning)?;

if let Some(comment) = update.comment {
self.write(" ")?;
self.visit_comment(comment)?;
}

Ok(())
}
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod metrics {
let total_operations = get_counter(&json, PRISMA_CLIENT_QUERIES_TOTAL);

match runner.connector_version() {
Sqlite(_) => assert_eq!(total_queries, 9),
Sqlite(_) => assert_eq!(total_queries, 2),
SqlServer(_) => assert_eq!(total_queries, 17),
MongoDb(_) => assert_eq!(total_queries, 5),
CockroachDb(_) => (), // not deterministic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
use query_engine_tests::*;

#[test_suite(
schema(common_nullable_types),
exclude(
Postgres("pg.js.wasm"),
Postgres("neon.js.wasm"),
Sqlite("libsql.js.wasm"),
Vitess("planetscale.js.wasm")
)
)]
#[test_suite(schema(common_nullable_types))]
mod bytes {
use query_engine_tests::{run_query, EngineProtocol, Runner};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ mod bigint_filter {
Ok(())
}

#[connector_test(
schema(setup::common_list_types),
exclude(Postgres("pg.js.wasm", "neon.js.wasm")),
capabilities(ScalarLists)
)]
#[connector_test(schema(setup::common_list_types), capabilities(ScalarLists))]
async fn scalar_list_filters(runner: Runner) -> TestResult<()> {
setup::test_data_list_common(&runner).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ mod bytes_filter {
use super::setup;
use query_engine_tests::run_query;

#[connector_test(
schema(setup::common_types),
exclude(Sqlite("libsql.js.wasm"), Vitess("planetscale.js.wasm"))
)]
#[connector_test(schema(setup::common_types))]
async fn basic_where(runner: Runner) -> TestResult<()> {
setup::test_data_common_types(&runner).await?;

Expand All @@ -31,11 +28,7 @@ mod bytes_filter {
Ok(())
}

#[connector_test(
schema(setup::common_mixed_types),
exclude(Postgres("pg.js.wasm", "neon.js.wasm")),
capabilities(ScalarLists)
)]
#[connector_test(schema(setup::common_mixed_types), capabilities(ScalarLists))]
async fn inclusion_filter(runner: Runner) -> TestResult<()> {
setup::test_data_common_mixed_types(&runner).await?;

Expand All @@ -57,11 +50,7 @@ mod bytes_filter {
Ok(())
}

#[connector_test(
schema(setup::common_list_types),
exclude(Postgres("pg.js.wasm", "neon.js.wasm")),
capabilities(ScalarLists)
)]
#[connector_test(schema(setup::common_list_types), capabilities(ScalarLists))]
async fn scalar_list_filters(runner: Runner) -> TestResult<()> {
setup::test_data_list_common(&runner).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ mod datetime_filter {
use super::setup;
use query_engine_tests::run_query;

#[connector_test(
schema(setup::common_types),
exclude(Sqlite("libsql.js.wasm"), Vitess("planetscale.js.wasm"))
)]
#[connector_test(schema(setup::common_types))]
async fn basic_where(runner: Runner) -> TestResult<()> {
setup::test_data_common_types(&runner).await?;

Expand All @@ -31,10 +28,7 @@ mod datetime_filter {
Ok(())
}

#[connector_test(
schema(setup::common_types),
exclude(Sqlite("libsql.js.wasm"), Vitess("planetscale.js.wasm"))
)]
#[connector_test(schema(setup::common_types))]
async fn numeric_comparison_filters(runner: Runner) -> TestResult<()> {
setup::test_data_common_types(&runner).await?;

Expand Down Expand Up @@ -143,11 +137,7 @@ mod datetime_filter {
Ok(())
}

#[connector_test(
schema(setup::common_list_types),
capabilities(ScalarLists),
exclude(Postgres("pg.js.wasm", "neon.js.wasm"))
)]
#[connector_test(schema(setup::common_list_types), capabilities(ScalarLists))]
async fn scalar_list_filters(runner: Runner) -> TestResult<()> {
setup::test_data_list_common(&runner).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ mod float_filter {
use super::setup;
use query_engine_tests::run_query;

#[connector_test(
schema(setup::common_types),
exclude(Sqlite("libsql.js.wasm"), Vitess("planetscale.js.wasm"))
)]
#[connector_test(schema(setup::common_types))]
async fn basic_where(runner: Runner) -> TestResult<()> {
setup::test_data_common_types(&runner).await?;

Expand All @@ -31,10 +28,7 @@ mod float_filter {
Ok(())
}

#[connector_test(
schema(setup::common_types),
exclude(Sqlite("libsql.js.wasm"), Vitess("planetscale.js.wasm"))
)]
#[connector_test(schema(setup::common_types))]
async fn numeric_comparison_filters(runner: Runner) -> TestResult<()> {
setup::test_data_common_types(&runner).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ mod int_filter {
use super::setup;
use query_engine_tests::run_query;

#[connector_test(
schema(setup::common_types),
exclude(Sqlite("libsql.js.wasm"), Vitess("planetscale.js.wasm"))
)]
#[connector_test(schema(setup::common_types))]
async fn basic_where(runner: Runner) -> TestResult<()> {
setup::test_data_common_types(&runner).await?;

Expand All @@ -31,10 +28,7 @@ mod int_filter {
Ok(())
}

#[connector_test(
schema(setup::common_types),
exclude(Sqlite("libsql.js.wasm"), Vitess("planetscale.js.wasm"))
)]
#[connector_test(schema(setup::common_types))]
async fn numeric_comparison_filters(runner: Runner) -> TestResult<()> {
setup::test_data_common_types(&runner).await?;

Expand Down Expand Up @@ -143,11 +137,7 @@ mod int_filter {
Ok(())
}

#[connector_test(
schema(setup::common_list_types),
exclude(Postgres("pg.js.wasm", "neon.js.wasm")),
capabilities(ScalarLists)
)]
#[connector_test(schema(setup::common_list_types), capabilities(ScalarLists))]
async fn scalar_list_filters(runner: Runner) -> TestResult<()> {
setup::test_data_list_common(&runner).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,7 @@ mod string_filter {
Ok(())
}

#[connector_test(
schema(setup::common_list_types),
exclude(Postgres("pg.js.wasm", "neon.js.wasm")),
capabilities(ScalarLists)
)]
#[connector_test(schema(setup::common_list_types), capabilities(ScalarLists))]
async fn scalar_list_filters_sensitive(runner: Runner) -> TestResult<()> {
setup::test_data_list_common(&runner).await?;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use query_engine_tests::*;

#[test_suite(
schema(common_list_types),
exclude(Postgres("pg.js.wasm", "neon.js.wasm")),
capabilities(ScalarLists)
)]
#[test_suite(schema(common_list_types), capabilities(ScalarLists))]
mod lists {
use indoc::indoc;
use query_engine_tests::run_query;
Expand Down Expand Up @@ -627,7 +623,7 @@ mod lists {
}

// Cockroachdb does not like the bytes empty array check in v21 but this will be fixed in 22.
#[connector_test(exclude(CockroachDB), exclude(Postgres("pg.js.wasm", "neon.js.wasm")))]
#[connector_test(exclude(CockroachDB))]
async fn is_empty_bytes(runner: Runner) -> TestResult<()> {
test_data(&runner).await?;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use query_engine_tests::*;

#[test_suite(exclude(
Postgres("pg.js.wasm", "neon.js.wasm"),
Sqlite("libsql.js.wasm"),
Vitess("planetscale.js.wasm")
))]
#[test_suite]
mod bytes {
use indoc::indoc;
use query_engine_tests::run_query;
Expand Down Expand Up @@ -81,16 +77,7 @@ mod bytes {
Ok(())
}

#[connector_test(
schema(bytes_id),
exclude(
MySQL,
Vitess,
SqlServer,
Postgres("pg.js.wasm", "neon.js.wasm"),
Sqlite("libsql.js.wasm")
)
)]
#[connector_test(schema(bytes_id), exclude(MySQL, Vitess, SqlServer,))]
async fn byte_id_coercion(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(runner, r#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,7 @@ mod postgres {
}

// "Other Postgres native types" should "work"
#[connector_test(
schema(schema_other_types),
only(Postgres),
exclude(CockroachDb, Postgres("pg.js.wasm", "neon.js.wasm"))
)]
#[connector_test(schema(schema_other_types), only(Postgres), exclude(CockroachDb,))]
async fn native_other_types(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod basic_types {
schema.to_owned()
}

#[connector_test(exclude(Postgres("pg.js.wasm", "neon.js.wasm")))]
#[connector_test]
async fn set_base(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, format!(r#"mutation {{
Expand Down Expand Up @@ -59,7 +59,7 @@ mod basic_types {

// "Scalar lists" should "be behave like regular values for create and update operations"
// Skipped for CockroachDB as enum array concatenation is not supported (https://github.com/cockroachdb/cockroach/issues/71388).
#[connector_test(exclude(CockroachDb, Postgres("pg.js.wasm", "neon.js.wasm")))]
#[connector_test(exclude(CockroachDb))]
async fn behave_like_regular_val_for_create_and_update(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, format!(r#"mutation {{
Expand Down Expand Up @@ -158,7 +158,7 @@ mod basic_types {
}

// "A Create Mutation" should "create and return items with list values with shorthand notation"
#[connector_test(exclude(Postgres("pg.js.wasm", "neon.js.wasm")))]
#[connector_test]
async fn create_mut_work_with_list_vals(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, format!(r#"mutation {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod basic {
schema.to_owned()
}

#[connector_test(exclude(Postgres("pg.js.wasm", "neon.js.wasm")))]
#[connector_test]
async fn basic_write(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
Expand Down
Loading

0 comments on commit 5c99c02

Please sign in to comment.