Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qe-wasm: Fix consistent now() value #4650

Merged
merged 3 commits into from Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -26,11 +26,7 @@ mod prisma_12572 {
.to_owned()
}

#[connector_test(exclude(
Postgres("pg.js.wasm", "neon.js.wasm"),
Sqlite("libsql.js.wasm"),
Vitess("planetscale.js.wasm")
))]
#[connector_test]
async fn all_generated_timestamps_are_the_same(runner: Runner) -> TestResult<()> {
runner
.query(r#"mutation { createOneTest1(data: {id:"one", test2s: { create: {id: "two"}}}) { id }}"#)
Expand Down
15 changes: 7 additions & 8 deletions query-engine/core/src/executor/request_context.rs
Expand Up @@ -18,14 +18,13 @@ tokio::task_local! {
///
/// If we had a query context we carry for the entire lifetime of the query, it would belong there.
pub(crate) fn get_request_now() -> PrismaValue {
// FIXME: we want to bypass task locals if this code is executed outside of a tokio context. As
// of this writing, it happens only in the query validation test suite.
//
// Eventually, this will go away when we have a plain query context reference we pass around.
if tokio::runtime::Handle::try_current().is_err() {
SevInf marked this conversation as resolved.
Show resolved Hide resolved
return PrismaValue::DateTime(chrono::Utc::now().into());
}
REQUEST_CONTEXT.with(|rc| rc.request_now.clone())
REQUEST_CONTEXT.try_with(|rc| rc.request_now.clone()).unwrap_or_else(|_|
// FIXME: we want to bypass task locals if this code is executed outside of a tokio context. As
// of this writing, it happens only in the query validation test suite.
//
// Eventually, this will go away when we have a plain query context reference we pass around.
// Skipping the branch for WASM since there we never have a running tokio runtime
SevInf marked this conversation as resolved.
Show resolved Hide resolved
PrismaValue::DateTime(chrono::Utc::now().into()))
}

/// The engine protocol used for the whole duration of a request.
Expand Down